Bumping manifests a=b2g-bump
[gecko.git] / b2g / gaia / run-b2g.c
blob2fffa9f176cf4743bca72e89ff71c45f56b16082
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 // XXX: yes, the printf above says --profile and this execle uses -profile.
42 // Bug 1088430 will change the execle to use --profile.
43 execle(full_path, full_path, "-profile", full_profile_path, NULL, envp);
44 error("unable to start");
45 perror(argv[0]);
46 free(full_path);
47 free(full_profile_path);
48 return -1;