summaryrefslogtreecommitdiffstats
path: root/b2g/gaia/run-b2g.c
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /b2g/gaia/run-b2g.c
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'b2g/gaia/run-b2g.c')
-rw-r--r--b2g/gaia/run-b2g.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/b2g/gaia/run-b2g.c b/b2g/gaia/run-b2g.c
new file mode 100644
index 000000000..184fa3400
--- /dev/null
+++ b/b2g/gaia/run-b2g.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <libgen.h>
+
+#ifndef B2G_NAME
+#define B2G_NAME "b2g-bin"
+#endif
+#ifndef GAIA_PATH
+#define GAIA_PATH "gaia/profile"
+#endif
+#define NOMEM "Could not allocate enough memory"
+
+void error(char* msg){
+ fprintf(stderr, "ERROR: %s\n", msg);
+}
+
+int main(int argc, char* argv[], char* envp[]){
+ char* cwd = NULL;
+ char* full_path = NULL;
+ char* full_profile_path = NULL;
+ printf("Starting %s\n", B2G_NAME);
+ cwd = realpath(dirname(argv[0]), NULL);
+ full_path = (char*) malloc(strlen(cwd) + strlen(B2G_NAME) + 2);
+ if (!full_path) {
+ error(NOMEM);
+ return -2;
+ }
+ full_profile_path = (char*) malloc(strlen(cwd) + strlen(GAIA_PATH) + 2);
+ if (!full_profile_path) {
+ free(full_path);
+ error(NOMEM);
+ return -2;
+ }
+ sprintf(full_path, "%s/%s", cwd, B2G_NAME);
+ sprintf(full_profile_path, "%s/%s", cwd, GAIA_PATH);
+ free(cwd);
+ printf("Running: %s --profile %s\n", full_path, full_profile_path);
+ fflush(stdout);
+ fflush(stderr);
+ // XXX: yes, the printf above says --profile and this execle uses -profile.
+ // Bug 1088430 will change the execle to use --profile.
+ execle(full_path, full_path, "-profile", full_profile_path, NULL, envp);
+ error("unable to start");
+ perror(argv[0]);
+ free(full_path);
+ free(full_profile_path);
+ return -1;
+}