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

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

Issue 10665008: ninja windows: workaround for too long names (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: hash rule_name too :( 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 | 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 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 hashlib
12 import os.path 13 import os.path
13 import re 14 import re
14 import subprocess 15 import subprocess
15 import sys 16 import sys
16 17
17 import gyp.ninja_syntax as ninja_syntax 18 import gyp.ninja_syntax as ninja_syntax
18 19
19 generator_default_variables = { 20 generator_default_variables = {
20 'EXECUTABLE_PREFIX': '', 21 'EXECUTABLE_PREFIX': '',
21 'EXECUTABLE_SUFFIX': '', 22 'EXECUTABLE_SUFFIX': '',
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 537
537 self.ninja.newline() 538 self.ninja.newline()
538 539
539 return all_outputs 540 return all_outputs
540 541
541 def WriteRules(self, rules, extra_sources, prebuild, 542 def WriteRules(self, rules, extra_sources, prebuild,
542 extra_mac_bundle_resources): 543 extra_mac_bundle_resources):
543 all_outputs = [] 544 all_outputs = []
544 for rule in rules: 545 for rule in rules:
545 # First write out a rule for the rule action. 546 # First write out a rule for the rule action.
546 name = '%s_%s' % (self.qualified_target, rule['rule_name']) 547 name = '%s_%s' % (self.qualified_target, rule['rule_name'])
Nico 2012/06/22 23:47:39 Could we use target_ + hash(qualified_target) here
scottmg 2012/06/22 23:51:09 sgtm, let me give it a test.
Nico 2012/06/22 23:52:16 Cool. For actions too, and if qualified_target is
547 # Skip a rule with no action and no inputs. 548 # Skip a rule with no action and no inputs.
548 if 'action' not in rule and not rule.get('rule_sources', []): 549 if 'action' not in rule and not rule.get('rule_sources', []):
549 continue 550 continue
550 args = rule['action'] 551 args = rule['action']
551 description = self.GenerateDescription( 552 description = self.GenerateDescription(
552 'RULE', 553 'RULE',
553 rule.get('message', None), 554 rule.get('message', None),
554 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) 555 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name)
555 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) 556 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule)
556 if self.flavor == 'win' else False) 557 if self.flavor == 'win' else False)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 elif var == 'ext': 610 elif var == 'ext':
610 extra_bindings.append(('ext', ext)) 611 extra_bindings.append(('ext', ext))
611 elif var == 'name': 612 elif var == 'name':
612 extra_bindings.append(('name', cygwin_munge(basename))) 613 extra_bindings.append(('name', cygwin_munge(basename)))
613 else: 614 else:
614 assert var == None, repr(var) 615 assert var == None, repr(var)
615 616
616 inputs = map(self.GypPathToNinja, inputs) 617 inputs = map(self.GypPathToNinja, inputs)
617 outputs = map(self.GypPathToNinja, outputs) 618 outputs = map(self.GypPathToNinja, outputs)
618 extra_bindings.append(('unique_name', 619 extra_bindings.append(('unique_name',
619 re.sub('[^a-zA-Z0-9_]', '_', outputs[0]))) 620 hashlib.md5(re.sub('[^a-zA-Z0-9_]', '_', outputs[0])).hexdigest()))
620 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), 621 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source),
621 implicit=inputs, 622 implicit=inputs,
622 order_only=prebuild, 623 order_only=prebuild,
623 variables=extra_bindings) 624 variables=extra_bindings)
624 625
625 all_outputs.extend(outputs) 626 all_outputs.extend(outputs)
626 627
627 return all_outputs 628 return all_outputs
628 629
629 def WriteCopies(self, copies, prebuild): 630 def WriteCopies(self, copies, prebuild):
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 1095
1095 Returns the name of the new rule.""" 1096 Returns the name of the new rule."""
1096 1097
1097 # TODO: we shouldn't need to qualify names; we do it because 1098 # TODO: we shouldn't need to qualify names; we do it because
1098 # currently the ninja rule namespace is global, but it really 1099 # currently the ninja rule namespace is global, but it really
1099 # should be scoped to the subninja. 1100 # should be scoped to the subninja.
1100 rule_name = self.name 1101 rule_name = self.name
1101 if self.toolset == 'target': 1102 if self.toolset == 'target':
1102 rule_name += '.' + self.toolset 1103 rule_name += '.' + self.toolset
1103 rule_name += '.' + name 1104 rule_name += '.' + name
1104 rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name) 1105 rule_name = hashlib.md5(re.sub('[^a-zA-Z0-9_]', '_', rule_name)).hexdigest()
1105 1106
1106 args = args[:] 1107 args = args[:]
1107 1108
1108 if self.flavor == 'win': 1109 if self.flavor == 'win':
1109 description = self.msvs_settings.ConvertVSMacros(description) 1110 description = self.msvs_settings.ConvertVSMacros(description)
1110 1111
1111 # gyp dictates that commands are run from the base directory. 1112 # gyp dictates that commands are run from the base directory.
1112 # cd into the directory before running, and adjust paths in 1113 # cd into the directory before running, and adjust paths in
1113 # the arguments to point to the proper locations. 1114 # the arguments to point to the proper locations.
1114 rspfile = None 1115 rspfile = None
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 1543
1543 user_config = params.get('generator_flags', {}).get('config', None) 1544 user_config = params.get('generator_flags', {}).get('config', None)
1544 if user_config: 1545 if user_config:
1545 GenerateOutputForConfig(target_list, target_dicts, data, params, 1546 GenerateOutputForConfig(target_list, target_dicts, data, params,
1546 user_config) 1547 user_config)
1547 else: 1548 else:
1548 config_names = target_dicts[target_list[0]]['configurations'].keys() 1549 config_names = target_dicts[target_list[0]]['configurations'].keys()
1549 for config_name in config_names: 1550 for config_name in config_names:
1550 GenerateOutputForConfig(target_list, target_dicts, data, params, 1551 GenerateOutputForConfig(target_list, target_dicts, data, params,
1551 config_name) 1552 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