Bug 1265796 - fix mach devtools-css-db for linux, debug builds; r?gregtatum draft
authorTom Tromey <tom@tromey.com>
Tue, 20 Sep 2016 11:56:22 -0600
changeset 416173 bbc5ae354f49d194b1027563a5e6b9b153ad8fab
parent 416172 ab46d921bf6be5790c192b7c32ffe03aa1ac970c
child 416174 b913b21120784658ab883ea16c71ab77854e9425
push id30051
push userbmo:ttromey@mozilla.com
push dateWed, 21 Sep 2016 16:39:05 +0000
reviewersgregtatum
bugs1265796
milestone52.0a1
Bug 1265796 - fix mach devtools-css-db for linux, debug builds; r?gregtatum MozReview-Commit-ID: 57s2Pqzc31S
devtools/shared/css/generated/generate-properties-db.js
devtools/shared/css/generated/mach_commands.py
--- a/devtools/shared/css/generated/generate-properties-db.js
+++ b/devtools/shared/css/generated/generate-properties-db.js
@@ -11,16 +11,20 @@
 var {require} = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
 var {generateCssProperties} = require("devtools/server/actors/css-properties");
 
 // Output JSON
 dump(JSON.stringify({
   cssProperties: cssProperties(),
   pseudoElements: pseudoElements()
 }));
+// In a debug build, xpcshell might print extra debugging information,
+// so we emit a trailing newline and then arrange to just read a
+// single (long) line of JSON from the output.
+dump("\n");
 
 /*
  * A list of CSS Properties and their various characteristics. This is used on the
  * client-side when the CssPropertiesActor is not found, or when the client and server
  * are the same version. A single property takes the form:
  *
  *  "animation": {
  *    "isInherited": false,
--- a/devtools/shared/css/generated/mach_commands.py
+++ b/devtools/shared/css/generated/mach_commands.py
@@ -53,17 +53,20 @@ class MachCommands(MachCommandBase):
 
         cpp = self.substs['CPP']
 
         if not cpp:
             print("Unable to find the cpp program. Please do a full, non-artifact")
             print("build and try this again.")
             sys.exit(1)
 
-        cmd = shellutil.split(cpp)
+        if type(cpp) is list:
+            cmd = cpp
+        else:
+            cmd = shellutil.split(cpp)
         cmd += shellutil.split(self.substs['ACDEFINES'])
         cmd.append(headerPath)
 
         # The preprocessed list takes the following form:
         # [ (name, prop, id, flags, pref, proptype), ... ]
         preprocessed = eval(subprocess.check_output(cmd))
 
         # Map this list
@@ -77,24 +80,34 @@ class MachCommands(MachCommandBase):
 
     def get_properties_db_from_xpcshell(self):
         """Generate the static css properties db for devtools from an xpcshell script."""
         build = MozbuildObject.from_environment()
 
         # Get the paths
         script_path = resolve_path(self.topsrcdir,
             'devtools/shared/css/generated/generate-properties-db.js')
+        gre_path = resolve_path(self.topobjdir, 'dist/bin')
         browser_path = resolve_path(self.topobjdir, 'dist/bin/browser')
         xpcshell_path = build.get_binary_path(what='xpcshell')
         print(browser_path)
 
+        sub_env = dict(os.environ)
+        if sys.platform.startswith('linux'):
+            sub_env["LD_LIBRARY_PATH"] = gre_path
+
         # Run the xcpshell script, and set the appdir flag to the browser path so that
         # we have the proper dependencies for requiring the loader.
-        contents = subprocess.check_output([xpcshell_path, '-a', browser_path,
-                                            script_path])
+        contents = subprocess.check_output([xpcshell_path, '-g', gre_path,
+                                            '-a', browser_path, script_path],
+                                           env = sub_env)
+        # Extract just the first line of output, since a debug-build
+        # xpcshell might emit extra output that we don't want.
+        contents = contents.split('\n')[0]
+
         return json.loads(contents)
 
     def output_template(self, substitutions):
         """Output a the properties-db.js from a template."""
         js_template_path = resolve_path(self.topsrcdir,
             'devtools/shared/css/generated/properties-db.js.in')
         destination_path = resolve_path(self.topsrcdir,
             'devtools/shared/css/generated/properties-db.js')