Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 10535052: Make Ninja backend robust to rules and actions containing slashes (Closed) Base URL: http://git.chromium.org/external/gyp.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pylib/gyp/generator/make.py ('k') | pylib/gyp/generator/scons.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import gyp.xcode_emulation 11 import gyp.xcode_emulation
12 import os.path 12 import os.path
13 import re 13 import re
14 import subprocess 14 import subprocess
15 import string
16 import sys 15 import sys
17 16
18 import gyp.ninja_syntax as ninja_syntax 17 import gyp.ninja_syntax as ninja_syntax
19 18
20 generator_default_variables = { 19 generator_default_variables = {
21 'EXECUTABLE_PREFIX': '', 20 'EXECUTABLE_PREFIX': '',
22 'EXECUTABLE_SUFFIX': '', 21 'EXECUTABLE_SUFFIX': '',
23 'STATIC_LIB_PREFIX': 'lib', 22 'STATIC_LIB_PREFIX': 'lib',
24 'STATIC_LIB_SUFFIX': '.a', 23 'STATIC_LIB_SUFFIX': '.a',
25 'SHARED_LIB_PREFIX': 'lib', 24 'SHARED_LIB_PREFIX': 'lib',
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 501
503 def WriteActions(self, actions, extra_sources, prebuild, 502 def WriteActions(self, actions, extra_sources, prebuild,
504 extra_mac_bundle_resources): 503 extra_mac_bundle_resources):
505 # Actions cd into the base directory. 504 # Actions cd into the base directory.
506 env = self.GetSortedXcodeEnv() 505 env = self.GetSortedXcodeEnv()
507 if self.flavor == 'win': 506 if self.flavor == 'win':
508 env = self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR') 507 env = self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR')
509 all_outputs = [] 508 all_outputs = []
510 for action in actions: 509 for action in actions:
511 # First write out a rule for the action. 510 # First write out a rule for the action.
512 name = re.sub(r'[ {}$]', '_', action['action_name']) 511 name = action['action_name']
513 description = self.GenerateDescription('ACTION', 512 description = self.GenerateDescription('ACTION',
514 action.get('message', None), 513 action.get('message', None),
515 name) 514 name)
516 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) 515 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
517 if self.flavor == 'win' else False) 516 if self.flavor == 'win' else False)
518 args = action['action'] 517 args = action['action']
519 args = [self.msvs_settings.ConvertVSMacros(arg, self.base_to_build) 518 args = [self.msvs_settings.ConvertVSMacros(arg, self.base_to_build)
520 for arg in args] if self.flavor == 'win' else args 519 for arg in args] if self.flavor == 'win' else args
521 rule_name = self.WriteNewNinjaRule(name, args, description, 520 rule_name = self.WriteNewNinjaRule(name, args, description,
522 is_cygwin, env=env) 521 is_cygwin, env=env)
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1090
1092 Returns the name of the new rule.""" 1091 Returns the name of the new rule."""
1093 1092
1094 # TODO: we shouldn't need to qualify names; we do it because 1093 # TODO: we shouldn't need to qualify names; we do it because
1095 # currently the ninja rule namespace is global, but it really 1094 # currently the ninja rule namespace is global, but it really
1096 # should be scoped to the subninja. 1095 # should be scoped to the subninja.
1097 rule_name = self.name 1096 rule_name = self.name
1098 if self.toolset == 'target': 1097 if self.toolset == 'target':
1099 rule_name += '.' + self.toolset 1098 rule_name += '.' + self.toolset
1100 rule_name += '.' + name 1099 rule_name += '.' + name
1101 rule_name = rule_name.translate(string.maketrans(' ()', '___')) 1100 rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name)
1102 1101
1103 args = args[:] 1102 args = args[:]
1104 1103
1105 if self.flavor == 'win': 1104 if self.flavor == 'win':
1106 description = self.msvs_settings.ConvertVSMacros(description) 1105 description = self.msvs_settings.ConvertVSMacros(description)
1107 1106
1108 # gyp dictates that commands are run from the base directory. 1107 # gyp dictates that commands are run from the base directory.
1109 # cd into the directory before running, and adjust paths in 1108 # cd into the directory before running, and adjust paths in
1110 # the arguments to point to the proper locations. 1109 # the arguments to point to the proper locations.
1111 if self.flavor == 'win': 1110 if self.flavor == 'win':
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 1532
1534 user_config = params.get('generator_flags', {}).get('config', None) 1533 user_config = params.get('generator_flags', {}).get('config', None)
1535 if user_config: 1534 if user_config:
1536 GenerateOutputForConfig(target_list, target_dicts, data, params, 1535 GenerateOutputForConfig(target_list, target_dicts, data, params,
1537 user_config) 1536 user_config)
1538 else: 1537 else:
1539 config_names = target_dicts[target_list[0]]['configurations'].keys() 1538 config_names = target_dicts[target_list[0]]['configurations'].keys()
1540 for config_name in config_names: 1539 for config_name in config_names:
1541 GenerateOutputForConfig(target_list, target_dicts, data, params, 1540 GenerateOutputForConfig(target_list, target_dicts, data, params,
1542 config_name) 1541 config_name)
OLDNEW
« no previous file with comments | « pylib/gyp/generator/make.py ('k') | pylib/gyp/generator/scons.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698