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

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

Issue 10893030: ninja windows: Fix special variables not getting emitted when expanded from VS macros (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 hashlib 6 import hashlib
7 import os.path 7 import os.path
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 for action in actions: 542 for action in actions:
543 # First write out a rule for the action. 543 # First write out a rule for the action.
544 name = '%s_%s' % (action['action_name'], 544 name = '%s_%s' % (action['action_name'],
545 hashlib.md5(self.qualified_target).hexdigest()) 545 hashlib.md5(self.qualified_target).hexdigest())
546 description = self.GenerateDescription('ACTION', 546 description = self.GenerateDescription('ACTION',
547 action.get('message', None), 547 action.get('message', None),
548 name) 548 name)
549 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) 549 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
550 if self.flavor == 'win' else False) 550 if self.flavor == 'win' else False)
551 args = action['action'] 551 args = action['action']
552 rule_name = self.WriteNewNinjaRule(name, args, description, 552 rule_name, _ = self.WriteNewNinjaRule(name, args, description,
553 is_cygwin, env=env) 553 is_cygwin, env=env)
554 554
555 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] 555 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
556 if int(action.get('process_outputs_as_sources', False)): 556 if int(action.get('process_outputs_as_sources', False)):
557 extra_sources += action['outputs'] 557 extra_sources += action['outputs']
558 if int(action.get('process_outputs_as_mac_bundle_resources', False)): 558 if int(action.get('process_outputs_as_mac_bundle_resources', False)):
559 extra_mac_bundle_resources += action['outputs'] 559 extra_mac_bundle_resources += action['outputs']
560 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] 560 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
561 561
562 # Then write out an edge using the rule. 562 # Then write out an edge using the rule.
(...skipping 15 matching lines...) Expand all
578 # Skip a rule with no action and no inputs. 578 # Skip a rule with no action and no inputs.
579 if 'action' not in rule and not rule.get('rule_sources', []): 579 if 'action' not in rule and not rule.get('rule_sources', []):
580 continue 580 continue
581 args = rule['action'] 581 args = rule['action']
582 description = self.GenerateDescription( 582 description = self.GenerateDescription(
583 'RULE', 583 'RULE',
584 rule.get('message', None), 584 rule.get('message', None),
585 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) 585 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name)
586 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) 586 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule)
587 if self.flavor == 'win' else False) 587 if self.flavor == 'win' else False)
588 rule_name = self.WriteNewNinjaRule(name, args, description, is_cygwin) 588 rule_name, args = self.WriteNewNinjaRule(
589 name, args, description, is_cygwin)
589 590
590 # TODO: if the command references the outputs directly, we should 591 # TODO: if the command references the outputs directly, we should
591 # simplify it to just use $out. 592 # simplify it to just use $out.
592 593
593 # Rules can potentially make use of some special variables which 594 # Rules can potentially make use of some special variables which
594 # must vary per source file. 595 # must vary per source file.
595 # Compute the list of variables we'll need to provide. 596 # Compute the list of variables we'll need to provide.
596 special_locals = ('source', 'root', 'dirname', 'ext', 'name') 597 special_locals = ('source', 'root', 'dirname', 'ext', 'name')
597 needed_variables = set(['source']) 598 needed_variables = set(['source'])
598 for argument in args: 599 for argument in args:
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 # currently the ninja rule namespace is global, but it really 1162 # currently the ninja rule namespace is global, but it really
1162 # should be scoped to the subninja. 1163 # should be scoped to the subninja.
1163 rule_name = self.name 1164 rule_name = self.name
1164 if self.toolset == 'target': 1165 if self.toolset == 'target':
1165 rule_name += '.' + self.toolset 1166 rule_name += '.' + self.toolset
1166 rule_name += '.' + name 1167 rule_name += '.' + name
1167 rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name) 1168 rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name)
1168 1169
1169 description = re.sub('[^ a-zA-Z0-9_]', '_', description) 1170 description = re.sub('[^ a-zA-Z0-9_]', '_', description)
1170 1171
1171 args = args[:]
scottmg 2012/08/29 16:35:35 (assuming this is pointless since it's immediately
1172
1173 # gyp dictates that commands are run from the base directory. 1172 # gyp dictates that commands are run from the base directory.
1174 # cd into the directory before running, and adjust paths in 1173 # cd into the directory before running, and adjust paths in
1175 # the arguments to point to the proper locations. 1174 # the arguments to point to the proper locations.
1176 rspfile = None 1175 rspfile = None
1177 rspfile_content = None 1176 rspfile_content = None
1178 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] 1177 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args]
1179 if self.flavor == 'win': 1178 if self.flavor == 'win':
1180 rspfile = rule_name + '.$unique_name.rsp' 1179 rspfile = rule_name + '.$unique_name.rsp'
1181 # The cygwin case handles this inside the bash sub-shell. 1180 # The cygwin case handles this inside the bash sub-shell.
1182 run_in = '' if is_cygwin else ' ' + self.build_to_base 1181 run_in = '' if is_cygwin else ' ' + self.build_to_base
(...skipping 13 matching lines...) Expand all
1196 command = ninja_syntax.escape(command) 1195 command = ninja_syntax.escape(command)
1197 command = 'cd %s; ' % self.build_to_base + env + command 1196 command = 'cd %s; ' % self.build_to_base + env + command
1198 1197
1199 # GYP rules/actions express being no-ops by not touching their outputs. 1198 # GYP rules/actions express being no-ops by not touching their outputs.
1200 # Avoid executing downstream dependencies in this case by specifying 1199 # Avoid executing downstream dependencies in this case by specifying
1201 # restat=1 to ninja. 1200 # restat=1 to ninja.
1202 self.ninja.rule(rule_name, command, description, restat=True, 1201 self.ninja.rule(rule_name, command, description, restat=True,
1203 rspfile=rspfile, rspfile_content=rspfile_content) 1202 rspfile=rspfile, rspfile_content=rspfile_content)
1204 self.ninja.newline() 1203 self.ninja.newline()
1205 1204
1206 return rule_name 1205 return rule_name, args
1207 1206
1208 1207
1209 def CalculateVariables(default_variables, params): 1208 def CalculateVariables(default_variables, params):
1210 """Calculate additional variables for use in the build (called by gyp).""" 1209 """Calculate additional variables for use in the build (called by gyp)."""
1211 global generator_additional_non_configuration_keys 1210 global generator_additional_non_configuration_keys
1212 global generator_additional_path_sections 1211 global generator_additional_path_sections
1213 flavor = gyp.common.GetFlavor(params) 1212 flavor = gyp.common.GetFlavor(params)
1214 if flavor == 'mac': 1213 if flavor == 'mac':
1215 default_variables.setdefault('OS', 'mac') 1214 default_variables.setdefault('OS', 'mac')
1216 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') 1215 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 1711
1713 user_config = params.get('generator_flags', {}).get('config', None) 1712 user_config = params.get('generator_flags', {}).get('config', None)
1714 if user_config: 1713 if user_config:
1715 GenerateOutputForConfig(target_list, target_dicts, data, params, 1714 GenerateOutputForConfig(target_list, target_dicts, data, params,
1716 user_config) 1715 user_config)
1717 else: 1716 else:
1718 config_names = target_dicts[target_list[0]]['configurations'].keys() 1717 config_names = target_dicts[target_list[0]]['configurations'].keys()
1719 for config_name in config_names: 1718 for config_name in config_names:
1720 GenerateOutputForConfig(target_list, target_dicts, data, params, 1719 GenerateOutputForConfig(target_list, target_dicts, data, params,
1721 config_name) 1720 config_name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698