Quote DEFINES more aggressively in WSL draft
authorTed Mielczarek <ted@mielczarek.org>
Wed, 20 Sep 2017 11:57:47 -0400
changeset 668600 2de521fa07b277d35b08a15bbe50f0bc27f87e60
parent 668599 b38dc73ab4624f5e277dbde31543ccf9d93b5302
child 668601 b97f8df825b55f7464916d42890b900651d18f6e
push id81087
push userbmo:ted@mielczarek.org
push dateThu, 21 Sep 2017 20:59:05 +0000
milestone57.0a1
Quote DEFINES more aggressively in WSL MozReview-Commit-ID: EstrNKnSzyE
python/mozbuild/mozbuild/backend/recursivemake.py
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -977,19 +977,25 @@ class RecursiveMakeBackend(CommonBackend
                 dirs=relativize(self.environment.topobjdir, obj.dirs))
 
         # The directory needs to be registered whether subdirectories have been
         # registered or not.
         self._traversal.add(backend_file.relobjdir)
 
     def _process_defines(self, obj, backend_file, which='DEFINES'):
         """Output the DEFINES rules to the given backend file."""
+        def q(s):
+            # In WSL quotes in DEFINES need to be doubly-escaped to survive shell execution
+            # as well as cl.exe's commandline parsing.
+            if mozpath.host_is_wsl():
+                s = s.replace('"', '\\"')
+            return shell_quote(s)
         defines = list(obj.get_defines())
         if defines:
-            defines = ' '.join(shell_quote(d) for d in defines)
+            defines = ' '.join(q(d) for d in defines)
             backend_file.write_once('%s += %s\n' % (which, defines))
 
     def _process_installation_target(self, obj, backend_file):
         # A few makefiles need to be able to override the following rules via
         # make XPI_NAME=blah commands, so we default to the lazy evaluation as
         # much as possible here to avoid breaking things.
         if obj.xpiname:
             backend_file.write('XPI_NAME = %s\n' % (obj.xpiname))