Bug 839650: Add debugs to MediaStreamGraph to ease investigation of issues in the...
[gecko.git] / b2g / gaia / run-b2g.c
blob325182e75ec5a57b1fd8e9489c3bba6669c32206
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <libgen.h>
7 #ifndef B2G_NAME
8 #define B2G_NAME "b2g-bin"
9 #endif
10 #ifndef GAIA_PATH
11 #define GAIA_PATH "gaia/profile"
12 #endif
13 #define NOMEM "Could not allocate enough memory"
15 void error(char* msg){
16 fprintf(stderr, "ERROR: %s\n", msg);
19 int main(int argc, char* argv[], char* envp[]){
20 char* cwd = NULL;
21 char* full_path = NULL;
22 char* full_profile_path = NULL;
23 printf("Starting %s\n", B2G_NAME);
24 cwd = realpath(dirname(argv[0]), NULL);
25 full_path = (char*) malloc(strlen(cwd) + strlen(B2G_NAME) + 2);
26 if (!full_path) {
27 error(NOMEM);
28 return -2;
30 full_profile_path = (char*) malloc(strlen(cwd) + strlen(GAIA_PATH) + 2);
31 if (!full_profile_path) {
32 error(NOMEM);
33 return -2;
35 sprintf(full_path, "%s/%s", cwd, B2G_NAME);
36 sprintf(full_profile_path, "%s/%s", cwd, GAIA_PATH);
37 free(cwd);
38 printf("Running: %s -profile %s\n", full_path, full_profile_path);
39 fflush(stdout);
40 fflush(stderr);
41 execle(full_path, full_path, "-profile", full_profile_path, NULL, envp);
42 error("unable to start");
43 perror(argv[0]);
44 free(full_path);
45 free(full_profile_path);
46 return -1;