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

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

Issue 10274018: ninja windows: more support for VS macros (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: guard convertvsmacros on win Created 8 years, 7 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 | pylib/gyp/msvs_emulation.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
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 env = self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR') 488 env = self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR')
489 all_outputs = [] 489 all_outputs = []
490 for action in actions: 490 for action in actions:
491 # First write out a rule for the action. 491 # First write out a rule for the action.
492 name = re.sub(r'[ {}$]', '_', action['action_name']) 492 name = re.sub(r'[ {}$]', '_', action['action_name'])
493 description = self.GenerateDescription('ACTION', 493 description = self.GenerateDescription('ACTION',
494 action.get('message', None), 494 action.get('message', None),
495 name) 495 name)
496 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) 496 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
497 if self.flavor == 'win' else False) 497 if self.flavor == 'win' else False)
498 rule_name = self.WriteNewNinjaRule(name, action['action'], description, 498 args = action['action']
499 args = [self.msvs_settings.ConvertVSMacros(arg, self.base_to_build)
500 for arg in args] if self.flavor == 'win' else args
501 rule_name = self.WriteNewNinjaRule(name, args, description,
499 is_cygwin, env=env) 502 is_cygwin, env=env)
500 503
501 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] 504 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
502 if int(action.get('process_outputs_as_sources', False)): 505 if int(action.get('process_outputs_as_sources', False)):
503 extra_sources += action['outputs'] 506 extra_sources += action['outputs']
504 if int(action.get('process_outputs_as_mac_bundle_resources', False)): 507 if int(action.get('process_outputs_as_mac_bundle_resources', False)):
505 extra_mac_bundle_resources += action['outputs'] 508 extra_mac_bundle_resources += action['outputs']
506 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] 509 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
507 510
508 # Then write out an edge using the rule. 511 # Then write out an edge using the rule.
(...skipping 11 matching lines...) Expand all
520 for rule in rules: 523 for rule in rules:
521 # First write out a rule for the rule action. 524 # First write out a rule for the rule action.
522 name = rule['rule_name'] 525 name = rule['rule_name']
523 args = rule['action'] 526 args = rule['action']
524 description = self.GenerateDescription( 527 description = self.GenerateDescription(
525 'RULE', 528 'RULE',
526 rule.get('message', None), 529 rule.get('message', None),
527 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) 530 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name)
528 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) 531 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule)
529 if self.flavor == 'win' else False) 532 if self.flavor == 'win' else False)
533 args = [self.msvs_settings.ConvertVSMacros(arg, self.base_to_build)
534 for arg in args] if self.flavor == 'win' else args
530 rule_name = self.WriteNewNinjaRule(name, args, description, is_cygwin) 535 rule_name = self.WriteNewNinjaRule(name, args, description, is_cygwin)
531 536
532 # TODO: if the command references the outputs directly, we should 537 # TODO: if the command references the outputs directly, we should
533 # simplify it to just use $out. 538 # simplify it to just use $out.
534 539
535 # Rules can potentially make use of some special variables which 540 # Rules can potentially make use of some special variables which
536 # must vary per source file. 541 # must vary per source file.
537 # Compute the list of variables we'll need to provide. 542 # Compute the list of variables we'll need to provide.
538 special_locals = ('source', 'root', 'dirname', 'ext', 'name') 543 special_locals = ('source', 'root', 'dirname', 'ext', 'name')
539 needed_variables = set(['source']) 544 needed_variables = set(['source'])
540 for argument in args: 545 for argument in args:
Nico 2012/05/01 00:11:29 Ah, so that it's converted here. Got it.
541 for var in special_locals: 546 for var in special_locals:
542 if ('${%s}' % var) in argument: 547 if ('${%s}' % var) in argument:
543 needed_variables.add(var) 548 needed_variables.add(var)
544 549
545 def cygwin_munge(path): 550 def cygwin_munge(path):
546 if is_cygwin: 551 if is_cygwin:
547 return path.replace('\\', '/') 552 return path.replace('\\', '/')
548 return path 553 return path
549 554
550 # For each source file, write an edge that generates all the outputs. 555 # For each source file, write an edge that generates all the outputs.
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 # currently the ninja rule namespace is global, but it really 1072 # currently the ninja rule namespace is global, but it really
1068 # should be scoped to the subninja. 1073 # should be scoped to the subninja.
1069 rule_name = self.name 1074 rule_name = self.name
1070 if self.toolset == 'target': 1075 if self.toolset == 'target':
1071 rule_name += '.' + self.toolset 1076 rule_name += '.' + self.toolset
1072 rule_name += '.' + name 1077 rule_name += '.' + name
1073 rule_name = rule_name.translate(string.maketrans(' ()', '___')) 1078 rule_name = rule_name.translate(string.maketrans(' ()', '___'))
1074 1079
1075 args = args[:] 1080 args = args[:]
1076 1081
1082 if self.flavor == 'win':
1083 description = self.msvs_settings.ConvertVSMacros(description)
1084
1077 # gyp dictates that commands are run from the base directory. 1085 # gyp dictates that commands are run from the base directory.
1078 # cd into the directory before running, and adjust paths in 1086 # cd into the directory before running, and adjust paths in
1079 # the arguments to point to the proper locations. 1087 # the arguments to point to the proper locations.
1080 if self.flavor == 'win': 1088 if self.flavor == 'win':
1081 cd = 'cmd /s /c "' 1089 cd = 'cmd /s /c "'
1082 if not is_cygwin: 1090 if not is_cygwin:
1083 # cd command added by BuildCygwinBashCommandLine in cygwin case. 1091 # cd command added by BuildCygwinBashCommandLine in cygwin case.
1084 cd += 'cd %s && ' % self.build_to_base 1092 cd += 'cd %s && ' % self.build_to_base
1085 else: 1093 else:
1086 cd = 'cd %s; ' % self.build_to_base 1094 cd = 'cd %s; ' % self.build_to_base
1087 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] 1095 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args]
1088 env = self.ComputeExportEnvString(env) if self.flavor != 'win' else '' 1096 env = self.ComputeExportEnvString(env) if self.flavor != 'win' else ''
1089 if self.flavor == 'win': 1097 if self.flavor == 'win':
1090 args = [self.msvs_settings.ConvertVSMacros(a, self.base_to_build)
1091 for a in args]
1092 if is_cygwin: 1098 if is_cygwin:
1093 command = self.msvs_settings.BuildCygwinBashCommandLine( 1099 command = self.msvs_settings.BuildCygwinBashCommandLine(
1094 args, self.build_to_base) 1100 args, self.build_to_base)
1095 else: 1101 else:
1096 # If there's no command, fake one to match the dangling |&&| above. 1102 # If there's no command, fake one to match the dangling |&&| above.
1097 command = gyp.msvs_emulation.EncodeRspFileList(args) or 'cmd /c' 1103 command = gyp.msvs_emulation.EncodeRspFileList(args) or 'cmd /c'
1098 command += '"' # Close quote opened in |cd|. 1104 command += '"' # Close quote opened in |cd|.
1099 else: 1105 else:
1100 command = gyp.common.EncodePOSIXShellList(args) 1106 command = gyp.common.EncodePOSIXShellList(args)
1101 if env: 1107 if env:
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 1483
1478 user_config = params.get('generator_flags', {}).get('config', None) 1484 user_config = params.get('generator_flags', {}).get('config', None)
1479 if user_config: 1485 if user_config:
1480 GenerateOutputForConfig(target_list, target_dicts, data, params, 1486 GenerateOutputForConfig(target_list, target_dicts, data, params,
1481 user_config) 1487 user_config)
1482 else: 1488 else:
1483 config_names = target_dicts[target_list[0]]['configurations'].keys() 1489 config_names = target_dicts[target_list[0]]['configurations'].keys()
1484 for config_name in config_names: 1490 for config_name in config_names:
1485 GenerateOutputForConfig(target_list, target_dicts, data, params, 1491 GenerateOutputForConfig(target_list, target_dicts, data, params,
1486 config_name) 1492 config_name)
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698