summaryrefslogtreecommitdiffstats
path: root/b2g/gaia
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
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')
-rw-r--r--b2g/gaia/Makefile.in14
-rw-r--r--b2g/gaia/moz.build20
-rw-r--r--b2g/gaia/run-b2g.c50
-rw-r--r--b2g/gaia/run-b2g.cpp102
4 files changed, 186 insertions, 0 deletions
diff --git a/b2g/gaia/Makefile.in b/b2g/gaia/Makefile.in
new file mode 100644
index 000000000..0820b16a4
--- /dev/null
+++ b/b2g/gaia/Makefile.in
@@ -0,0 +1,14 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+GAIA_PATH := gaia/profile
+
+GENERATED_DIRS += $(DIST)/bin/$(GAIA_PATH)
+
+include $(topsrcdir)/config/rules.mk
+
+libs::
+ +$(MAKE) -j1 -C $(GAIADIR) clean
+ +$(MAKE) -j1 -C $(GAIADIR) profile
+ (cd $(GAIADIR)/profile && tar $(TAR_CREATE_FLAGS) - .) | (cd $(ABS_DIST)/bin/$(GAIA_PATH) && tar -xf -)
diff --git a/b2g/gaia/moz.build b/b2g/gaia/moz.build
new file mode 100644
index 000000000..ab98fd151
--- /dev/null
+++ b/b2g/gaia/moz.build
@@ -0,0 +1,20 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Program(CONFIG['MOZ_APP_NAME'])
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+ SOURCES += [
+ 'run-b2g.cpp',
+ ]
+ DEFINES['B2G_NAME'] = 'L"%s-bin%s"' % (PROGRAM, CONFIG['BIN_SUFFIX'])
+ DEFINES['GAIA_PATH'] = 'L"gaia\\\\profile"'
+else:
+ SOURCES += [
+ 'run-b2g.c',
+ ]
+ DEFINES['B2G_NAME'] = '"%s-bin%s"' % (PROGRAM, CONFIG['BIN_SUFFIX'])
+ DEFINES['GAIA_PATH'] = '"gaia/profile"'
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;
+}
diff --git a/b2g/gaia/run-b2g.cpp b/b2g/gaia/run-b2g.cpp
new file mode 100644
index 000000000..26fce08a2
--- /dev/null
+++ b/b2g/gaia/run-b2g.cpp
@@ -0,0 +1,102 @@
+#include <Windows.h>
+#include <Shlwapi.h>
+#include <strsafe.h>
+
+// Linker options
+#pragma comment(lib, "User32.lib")
+#pragma comment(lib, "shlwapi.lib")
+#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:wmainCRTStartup")
+
+#define NUM_MAX_PATH_BYTES sizeof(wchar_t) * MAX_PATH + 1
+#define PROFILE_ARG L" -profile "
+
+// Options that can be overridden at build time with -D
+#ifndef B2G_NAME
+#define B2G_NAME L"b2g.exe"
+#endif
+#ifndef GAIA_PATH
+#define GAIA_PATH L"gaia\\profile"
+#endif
+
+void error(wchar_t* msg){
+ MessageBoxW(nullptr, msg, L"Error starting program", MB_OK | MB_ICONERROR);
+}
+
+/* This function takes a string which represents a windows path, orig.
+ * The file portion of the path is stripped off and replaced with the
+ * path component, file. This function returns a string which represents
+ * a windows path with the modifications requested and needs to be freed
+ * explicitly by the calling function.
+ */
+wchar_t* make_path_with_leaf_file_name(wchar_t* orig, wchar_t* file){
+ wchar_t* buffer = (wchar_t*) malloc(NUM_MAX_PATH_BYTES);
+ if (!buffer) {
+ return nullptr;
+ }
+ if (FAILED(StringCchCopyW(buffer, NUM_MAX_PATH_BYTES, orig))) {
+ error(L"Error copying string");
+ free(buffer);
+ buffer = nullptr;
+ }
+ PathRemoveFileSpecW(buffer);
+ if (!PathAppendW(buffer, file)) {
+ error(L"Unable to append file to directory");
+ free(buffer);
+ buffer = nullptr;
+ }
+ return buffer;
+}
+
+BOOL execute(wchar_t* binary_path, wchar_t* args, int cp_flags) {
+ STARTUPINFOW si;
+ PROCESS_INFORMATION pi;
+
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+ ZeroMemory(&pi, sizeof(pi));
+
+ if (!CreateProcessW(
+ binary_path,
+ args,
+ nullptr,
+ nullptr,
+ FALSE,
+ cp_flags,
+ nullptr,
+ nullptr,
+ &si,
+ &pi)){
+ error(L"Could not execute program");
+ return FALSE;
+ }
+
+ WaitForInputIdle(pi.hProcess, 0);
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ return true;
+}
+
+int wmain(int argc, wchar_t *argv[], wchar_t *envp[]){
+ int cp_flags;
+ wchar_t* b2g_path = make_path_with_leaf_file_name(argv[0], B2G_NAME);
+ wchar_t* profile_path = make_path_with_leaf_file_name(argv[0], GAIA_PATH);
+ // 10 chars for the ' -profile ' portion of the argument
+ wchar_t* args = (wchar_t*) malloc(2 * NUM_MAX_PATH_BYTES + wcslen(PROFILE_ARG));
+ if (FAILED(StringCchPrintfW(args, NUM_MAX_PATH_BYTES, L"\"%ws\"%ws\"%ws\"", b2g_path, PROFILE_ARG, profile_path))) {
+ error(L"Could not create argument string");
+ ExitProcess(1);
+ }
+#ifdef SHOW_CONSOLE
+ cp_flags = 0;
+#else
+ cp_flags = DETACHED_PROCESS;
+#endif
+ if (!execute(b2g_path, args, cp_flags)) {
+ error(L"Failed to launch program");
+ }
+ free(profile_path);
+ free(b2g_path);
+ free(args);
+ profile_path = b2g_path = args = nullptr;
+
+}