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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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']) |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 description = self.msvs_settings.ConvertVSMacros(description) | |
Nico
2012/04/30 23:33:27
This will crash on non-windows systems due to msvs
scottmg
2012/04/30 23:42:27
Oops, thanks. Done.
| |
1083 | |
1077 # gyp dictates that commands are run from the base directory. | 1084 # gyp dictates that commands are run from the base directory. |
1078 # cd into the directory before running, and adjust paths in | 1085 # cd into the directory before running, and adjust paths in |
1079 # the arguments to point to the proper locations. | 1086 # the arguments to point to the proper locations. |
1080 if self.flavor == 'win': | 1087 if self.flavor == 'win': |
1081 cd = 'cmd /s /c "' | 1088 cd = 'cmd /s /c "' |
1082 if not is_cygwin: | 1089 if not is_cygwin: |
1083 # cd command added by BuildCygwinBashCommandLine in cygwin case. | 1090 # cd command added by BuildCygwinBashCommandLine in cygwin case. |
1084 cd += 'cd %s && ' % self.build_to_base | 1091 cd += 'cd %s && ' % self.build_to_base |
1085 else: | 1092 else: |
1086 cd = 'cd %s; ' % self.build_to_base | 1093 cd = 'cd %s; ' % self.build_to_base |
1087 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] | 1094 args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] |
1088 env = self.ComputeExportEnvString(env) if self.flavor != 'win' else '' | 1095 env = self.ComputeExportEnvString(env) if self.flavor != 'win' else '' |
1089 if self.flavor == 'win': | 1096 if self.flavor == 'win': |
1090 args = [self.msvs_settings.ConvertVSMacros(a, self.base_to_build) | |
1091 for a in args] | |
Nico
2012/04/30 23:33:27
Why did this have to move up (to two places)?
scottmg
2012/04/30 23:42:27
It has to happen outside for WriteRules (the note
| |
1092 if is_cygwin: | 1097 if is_cygwin: |
1093 command = self.msvs_settings.BuildCygwinBashCommandLine( | 1098 command = self.msvs_settings.BuildCygwinBashCommandLine( |
1094 args, self.build_to_base) | 1099 args, self.build_to_base) |
1095 else: | 1100 else: |
1096 # If there's no command, fake one to match the dangling |&&| above. | 1101 # If there's no command, fake one to match the dangling |&&| above. |
1097 command = gyp.msvs_emulation.EncodeRspFileList(args) or 'cmd /c' | 1102 command = gyp.msvs_emulation.EncodeRspFileList(args) or 'cmd /c' |
1098 command += '"' # Close quote opened in |cd|. | 1103 command += '"' # Close quote opened in |cd|. |
1099 else: | 1104 else: |
1100 command = gyp.common.EncodePOSIXShellList(args) | 1105 command = gyp.common.EncodePOSIXShellList(args) |
1101 if env: | 1106 if env: |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1477 | 1482 |
1478 user_config = params.get('generator_flags', {}).get('config', None) | 1483 user_config = params.get('generator_flags', {}).get('config', None) |
1479 if user_config: | 1484 if user_config: |
1480 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1485 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1481 user_config) | 1486 user_config) |
1482 else: | 1487 else: |
1483 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1488 config_names = target_dicts[target_list[0]]['configurations'].keys() |
1484 for config_name in config_names: | 1489 for config_name in config_names: |
1485 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1490 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1486 config_name) | 1491 config_name) |
OLD | NEW |