| OLD | NEW | 
|---|
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 import copy | 5 import copy | 
| 6 import gyp | 6 import gyp | 
| 7 import gyp.common | 7 import gyp.common | 
| 8 import gyp.msvs_emulation | 8 import gyp.msvs_emulation | 
| 9 import gyp.MSVSVersion | 9 import gyp.MSVSVersion | 
| 10 import gyp.system_test | 10 import gyp.system_test | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 64   by the shell.""" | 64   by the shell.""" | 
| 65   # Rather than attempting to enumerate the bad shell characters, just | 65   # Rather than attempting to enumerate the bad shell characters, just | 
| 66   # whitelist common OK ones and quote anything else. | 66   # whitelist common OK ones and quote anything else. | 
| 67   if re.match(r'^[a-zA-Z0-9_=.\\/-]+$', arg): | 67   if re.match(r'^[a-zA-Z0-9_=.\\/-]+$', arg): | 
| 68     return arg  # No quoting necessary. | 68     return arg  # No quoting necessary. | 
| 69   if flavor == 'win': | 69   if flavor == 'win': | 
| 70     return gyp.msvs_emulation.QuoteForRspFile(arg) | 70     return gyp.msvs_emulation.QuoteForRspFile(arg) | 
| 71   return "'" + arg.replace("'", "'" + '"\'"' + "'")  + "'" | 71   return "'" + arg.replace("'", "'" + '"\'"' + "'")  + "'" | 
| 72 | 72 | 
| 73 | 73 | 
|  | 74 def Define(d, flavor): | 
|  | 75   """Takes a preprocessor define and returns a -D parameter that's ninja- and | 
|  | 76   shell-escaped.""" | 
|  | 77   if flavor == 'win': | 
|  | 78     # cl.exe replaces literal # characters with = in preprocesor definitions for | 
|  | 79     # some reason. Octal-encode to work around that. | 
|  | 80     d = d.replace('#', '\\%03o' % ord('#')) | 
|  | 81   return QuoteShellArgument(ninja_syntax.escape('-D' + d), flavor) | 
|  | 82 | 
|  | 83 | 
| 74 def InvertRelativePath(path): | 84 def InvertRelativePath(path): | 
| 75   """Given a relative path like foo/bar, return the inverse relative path: | 85   """Given a relative path like foo/bar, return the inverse relative path: | 
| 76   the path from the relative path back to the origin dir. | 86   the path from the relative path back to the origin dir. | 
| 77 | 87 | 
| 78   E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path))) | 88   E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path))) | 
| 79   should always produce the empty string.""" | 89   should always produce the empty string.""" | 
| 80 | 90 | 
| 81   if not path: | 91   if not path: | 
| 82     return path | 92     return path | 
| 83   # Only need to handle relative paths into subdirectories for now. | 93   # Only need to handle relative paths into subdirectories for now. | 
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 628     """Write build rules for bundle Info.plist files.""" | 638     """Write build rules for bundle Info.plist files.""" | 
| 629     info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( | 639     info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( | 
| 630         self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), | 640         self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), | 
| 631         self.xcode_settings, self.GypPathToNinja) | 641         self.xcode_settings, self.GypPathToNinja) | 
| 632     if not info_plist: | 642     if not info_plist: | 
| 633       return | 643       return | 
| 634     if defines: | 644     if defines: | 
| 635       # Create an intermediate file to store preprocessed results. | 645       # Create an intermediate file to store preprocessed results. | 
| 636       intermediate_plist = self.GypPathToUniqueOutput( | 646       intermediate_plist = self.GypPathToUniqueOutput( | 
| 637           os.path.basename(info_plist)) | 647           os.path.basename(info_plist)) | 
| 638       defines = ' '.join( | 648       defines = ' '.join([Define(d, self.flavor) for d in defines]) | 
| 639           [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor) |  | 
| 640            for d in defines]) |  | 
| 641       info_plist = self.ninja.build(intermediate_plist, 'infoplist', info_plist, | 649       info_plist = self.ninja.build(intermediate_plist, 'infoplist', info_plist, | 
| 642                                     variables=[('defines',defines)]) | 650                                     variables=[('defines',defines)]) | 
| 643 | 651 | 
| 644     env = self.GetXcodeEnv(additional_settings=extra_env) | 652     env = self.GetXcodeEnv(additional_settings=extra_env) | 
| 645     env = self.ComputeExportEnvString(env) | 653     env = self.ComputeExportEnvString(env) | 
| 646 | 654 | 
| 647     self.ninja.build(out, 'mac_tool', info_plist, | 655     self.ninja.build(out, 'mac_tool', info_plist, | 
| 648                      variables=[('mactool_cmd', 'copy-info-plist'), | 656                      variables=[('mactool_cmd', 'copy-info-plist'), | 
| 649                                 ('env', env)]) | 657                                 ('env', env)]) | 
| 650     bundle_depends.append(out) | 658     bundle_depends.append(out) | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 672       cflags_c = self.msvs_settings.GetCflagsC(config_name) | 680       cflags_c = self.msvs_settings.GetCflagsC(config_name) | 
| 673       cflags_cc = self.msvs_settings.GetCflagsCC(config_name) | 681       cflags_cc = self.msvs_settings.GetCflagsCC(config_name) | 
| 674       extra_defines = self.msvs_settings.GetComputedDefines(config_name) | 682       extra_defines = self.msvs_settings.GetComputedDefines(config_name) | 
| 675       self.WriteVariableList('pdbname', [self.name + '.pdb']) | 683       self.WriteVariableList('pdbname', [self.name + '.pdb']) | 
| 676     else: | 684     else: | 
| 677       cflags = config.get('cflags', []) | 685       cflags = config.get('cflags', []) | 
| 678       cflags_c = config.get('cflags_c', []) | 686       cflags_c = config.get('cflags_c', []) | 
| 679       cflags_cc = config.get('cflags_cc', []) | 687       cflags_cc = config.get('cflags_cc', []) | 
| 680 | 688 | 
| 681     defines = config.get('defines', []) + extra_defines | 689     defines = config.get('defines', []) + extra_defines | 
| 682     self.WriteVariableList('defines', | 690     self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines]) | 
| 683         [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor) |  | 
| 684          for d in defines]) |  | 
| 685     if self.flavor == 'win': | 691     if self.flavor == 'win': | 
| 686       self.WriteVariableList('rcflags', | 692       self.WriteVariableList('rcflags', | 
| 687           [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) | 693           [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) | 
| 688            for f in self.msvs_settings.GetRcflags(config_name)]) | 694            for f in self.msvs_settings.GetRcflags(config_name)]) | 
| 689 | 695 | 
| 690     include_dirs = config.get('include_dirs', []) | 696     include_dirs = config.get('include_dirs', []) | 
| 691     if self.flavor == 'win': | 697     if self.flavor == 'win': | 
| 692       include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, | 698       include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, | 
| 693                                                           config_name) | 699                                                           config_name) | 
| 694     self.WriteVariableList('includes', | 700     self.WriteVariableList('includes', | 
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1489 | 1495 | 
| 1490   user_config = params.get('generator_flags', {}).get('config', None) | 1496   user_config = params.get('generator_flags', {}).get('config', None) | 
| 1491   if user_config: | 1497   if user_config: | 
| 1492     GenerateOutputForConfig(target_list, target_dicts, data, params, | 1498     GenerateOutputForConfig(target_list, target_dicts, data, params, | 
| 1493                             user_config) | 1499                             user_config) | 
| 1494   else: | 1500   else: | 
| 1495     config_names = target_dicts[target_list[0]]['configurations'].keys() | 1501     config_names = target_dicts[target_list[0]]['configurations'].keys() | 
| 1496     for config_name in config_names: | 1502     for config_name in config_names: | 
| 1497       GenerateOutputForConfig(target_list, target_dicts, data, params, | 1503       GenerateOutputForConfig(target_list, target_dicts, data, params, | 
| 1498                               config_name) | 1504                               config_name) | 
| OLD | NEW | 
|---|