diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-09-03 18:32:44 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-09-08 09:03:15 (GMT) |
commit | e21308e44dcfe2e1a6da8386d2ef0c36792119f3 (patch) | |
tree | 254026e181892428ccec7f740e40c9f78d22ac93 /BuildTools/scons2ninja.py | |
parent | a0ac7f269aeea190cbaa41210849d541dd6a5dcc (diff) | |
download | swift-contrib-e21308e44dcfe2e1a6da8386d2ef0c36792119f3.zip swift-contrib-e21308e44dcfe2e1a6da8386d2ef0c36792119f3.tar.bz2 |
scons2ninja: Support quoted flags.
Change-Id: Iea4206b281400995734263fc39062196d2d0446f
Diffstat (limited to 'BuildTools/scons2ninja.py')
-rwxr-xr-x | BuildTools/scons2ninja.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/BuildTools/scons2ninja.py b/BuildTools/scons2ninja.py index 4a7631a..2666ae6 100755 --- a/BuildTools/scons2ninja.py +++ b/BuildTools/scons2ninja.py @@ -12,5 +12,5 @@ ################################################################################ -import re, os, os.path, subprocess, sys, fnmatch +import re, os, os.path, subprocess, sys, fnmatch, shlex ################################################################################ @@ -42,4 +42,10 @@ def escape(s) : return s.replace(' ', '$ ').replace(':', '$:') +def quote_spaces(s) : + if ' ' in s : + return '"' + s + '"' + else : + return s + def to_list(l) : if not l : @@ -115,5 +121,5 @@ def get_built_libs(libs, libpaths, outputs) : def parse_tool_command(line) : - command = line.split(' ') + command = shlex.split(line) flags = command[1:] tool = os.path.splitext(os.path.basename(command[0]))[0] @@ -174,5 +180,5 @@ class NinjaBuilder : if var in ['deps', 'order_deps'] : continue - value = self.to_string(value) + value = self.to_string(value, quote = True) if var.endswith("flags") : value = self.get_flags_variable(var, value) @@ -196,6 +202,9 @@ class NinjaBuilder : return result - def to_string(self, lst) : + def to_string(self, lst, quote = False) : if is_list(lst) : + if quote : + return ' '.join([quote_spaces(x) for x in lst]) + else : return ' '.join([escape(x) for x in lst]) if is_regexp(lst) : |