Bug 970298 - Allows to run the simulator on a custom gaia and/or gecko. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 23 Apr 2014 10:43:00 +0200
changeset 179884 1d0a4cd6ec208089412293f3344252a1be3d3dc1
parent 179883 7392985b21179ad1977cf3f7cb572d1b5812243e
child 179885 1d7b9a01b8cf2759e071e2b120dc588aafc5f34a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjryans
bugs970298
milestone31.0a1
Bug 970298 - Allows to run the simulator on a custom gaia and/or gecko. r=jryans
b2g/simulator/lib/simulator-process.js
b2g/simulator/package.json
--- a/b2g/simulator/lib/simulator-process.js
+++ b/b2g/simulator/lib/simulator-process.js
@@ -13,16 +13,17 @@ const { EventTarget } = require("sdk/eve
 const { emit, off } = require("sdk/event/core");
 const { Class } = require("sdk/core/heritage");
 const Environment = require("sdk/system/environment").env;
 const Runtime = require("sdk/system/runtime");
 const Self = require("sdk/self");
 const URL = require("sdk/url");
 const Subprocess = require("subprocess");
 const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
+const Prefs = require("sdk/simple-prefs").prefs;
 
 const { rootURI: ROOT_URI } = require('@loader/options');
 const PROFILE_URL = ROOT_URI + "profile/";
 const BIN_URL = ROOT_URI + "b2g/";
 
 // Log subprocess error and debug messages to the console.  This logs messages
 // for all consumers of the API.  We trim the messages because they sometimes
 // have trailing newlines.  And note that registerLogHandler actually registers
@@ -131,17 +132,25 @@ exports.SimulatorProcess = Class({
 
   // compute current b2g filename
   get b2gFilename() {
     return this._executable ? this._executableFilename : "B2G";
   },
 
   // compute current b2g file handle
   get b2gExecutable() {
-    if (this._executable) return this._executable;
+    if (this._executable) {
+      return this._executable;
+    }
+
+    if (Prefs.customRuntime) {
+      this._executable = Prefs.customRuntime;
+      this._executableFilename = "Custom runtime";
+      return this._executable;
+    }
 
     let bin = URL.toFilename(BIN_URL);
     let executables = {
       WINNT: "b2g-bin.exe",
       Darwin: "B2G.app/Contents/MacOS/b2g-bin",
       Linux: "b2g-bin",
     };
 
@@ -163,19 +172,19 @@ exports.SimulatorProcess = Class({
 
     return executable;
   },
 
   // compute b2g CLI arguments
   get b2gArguments() {
     let args = [];
 
-    let profile = URL.toFilename(PROFILE_URL);
+    let profile = Prefs.gaiaProfile || URL.toFilename(PROFILE_URL);
     args.push("-profile", profile);
-    Cu.reportError(profile);
+    console.log("profile", profile);
 
     // NOTE: push dbgport option on the b2g-desktop commandline
     args.push("-start-debugger-server", "" + this.remoteDebuggerPort);
 
     // Ignore eventual zombie instances of b2g that are left over
     args.push("-no-remote");
 
     return args;
--- a/b2g/simulator/package.json
+++ b/b2g/simulator/package.json
@@ -26,12 +26,21 @@
     "Nick Desaulniers (https://github.com/nickdesaulniers)",
     "Soumen Ganguly (https://github.com/SoumenG)",
     "Sudheesh Singanamalla (https://github.com/sudheesh001)",
     "Victor Bjelkholm (https://github.com/VictorBjelkholm)"
   ],
   "permissions": {
     "private-browsing": true
   },
+  "preferences": [{
+    "type": "directory",
+    "name": "gaiaProfile",
+    "title": "Select a custom Gaia profile directory"
+  }, {
+    "type": "file",
+    "name": "customRuntime",
+    "title": "Select a custom runtime executable"
+  }],
   "license": "MPL 2.0",
   "unpack": true,
   "dependencies": ["subprocess"]
 }