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

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

Issue 3141004: make: Fixup variable names for actions and rules.... (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 4 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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2009 Google Inc. All rights reserved. 3 # Copyright (c) 2009 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Notes: 7 # Notes:
8 # 8 #
9 # This is all roughly based on the Makefile system used by the Linux 9 # This is all roughly based on the Makefile system used by the Linux
10 # kernel, but is a non-recursive make -- we put the entire dependency 10 # kernel, but is a non-recursive make -- we put the entire dependency
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 491
492 def QuoteIfNecessary(string): 492 def QuoteIfNecessary(string):
493 """TODO: Should this ideally be replaced with one or more of the above 493 """TODO: Should this ideally be replaced with one or more of the above
494 functions?""" 494 functions?"""
495 if '"' in string: 495 if '"' in string:
496 string = '"' + string.replace('"', '\\"') + '"' 496 string = '"' + string.replace('"', '\\"') + '"'
497 return string 497 return string
498 498
499 499
500 def StringToMakefileVariable(string):
501 """Convert a string to a value that is acceptable as a make variable name."""
502 # TODO: replace other metacharacters that we encounter.
503 return string.replace(' ', '_')
504
505
500 srcdir_prefix = '' 506 srcdir_prefix = ''
501 def Sourceify(path): 507 def Sourceify(path):
502 """Convert a path to its source directory form.""" 508 """Convert a path to its source directory form."""
503 if '$(' in path: 509 if '$(' in path:
504 return path 510 return path
505 if os.path.isabs(path): 511 if os.path.isabs(path):
506 return path 512 return path
507 return srcdir_prefix + path 513 return srcdir_prefix + path
508 514
509 515
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 """Write Makefile code for any 'actions' from the gyp input. 655 """Write Makefile code for any 'actions' from the gyp input.
650 656
651 extra_sources: a list that will be filled in with newly generated source 657 extra_sources: a list that will be filled in with newly generated source
652 files, if any 658 files, if any
653 extra_outputs: a list that will be filled in with any outputs of these 659 extra_outputs: a list that will be filled in with any outputs of these
654 actions (used to make other pieces dependent on these 660 actions (used to make other pieces dependent on these
655 actions) 661 actions)
656 part_of_all: flag indicating this target is part of 'all' 662 part_of_all: flag indicating this target is part of 'all'
657 """ 663 """
658 for action in actions: 664 for action in actions:
659 name = self.target + '_' + action['action_name'] 665 name = self.target + '_' + StringToMakefileVariable(action['action_name'])
660 self.WriteLn('### Rules for action "%s":' % action['action_name']) 666 self.WriteLn('### Rules for action "%s":' % action['action_name'])
661 inputs = action['inputs'] 667 inputs = action['inputs']
662 outputs = action['outputs'] 668 outputs = action['outputs']
663 669
664 # Build up a list of outputs. 670 # Build up a list of outputs.
665 # Collect the output dirs we'll need. 671 # Collect the output dirs we'll need.
666 dirs = set() 672 dirs = set()
667 for out in outputs: 673 for out in outputs:
668 dir = os.path.split(out)[0] 674 dir = os.path.split(out)[0]
669 if dir: 675 if dir:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 def WriteRules(self, rules, extra_sources, extra_outputs, part_of_all): 724 def WriteRules(self, rules, extra_sources, extra_outputs, part_of_all):
719 """Write Makefile code for any 'rules' from the gyp input. 725 """Write Makefile code for any 'rules' from the gyp input.
720 726
721 extra_sources: a list that will be filled in with newly generated source 727 extra_sources: a list that will be filled in with newly generated source
722 files, if any 728 files, if any
723 extra_outputs: a list that will be filled in with any outputs of these 729 extra_outputs: a list that will be filled in with any outputs of these
724 rules (used to make other pieces dependent on these rules) 730 rules (used to make other pieces dependent on these rules)
725 part_of_all: flag indicating this target is part of 'all' 731 part_of_all: flag indicating this target is part of 'all'
726 """ 732 """
727 for rule in rules: 733 for rule in rules:
728 name = self.target + '_' + rule['rule_name'] 734 name = self.target + '_' + StringToMakefileVariable(rule['rule_name'])
729 count = 0 735 count = 0
730 self.WriteLn('### Generated for rule %s:' % name) 736 self.WriteLn('### Generated for rule %s:' % name)
731 737
732 all_outputs = [] 738 all_outputs = []
733 739
734 for rule_source in rule['rule_sources']: 740 for rule_source in rule['rule_sources']:
735 dirs = set() 741 dirs = set()
736 rule_source_basename = os.path.basename(rule_source) 742 rule_source_basename = os.path.basename(rule_source)
737 (rule_source_root, rule_source_ext) = \ 743 (rule_source_root, rule_source_ext) = \
738 os.path.splitext(rule_source_basename) 744 os.path.splitext(rule_source_basename)
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 makefile_name, 1327 makefile_name,
1322 ' '.join(map(Sourceify, build_files)), 1328 ' '.join(map(Sourceify, build_files)),
1323 gyp.common.EncodePOSIXShellList( 1329 gyp.common.EncodePOSIXShellList(
1324 [gyp_binary, '-fmake'] + 1330 [gyp_binary, '-fmake'] +
1325 gyp.RegenerateFlags(options) + 1331 gyp.RegenerateFlags(options) +
1326 build_files_args))) 1332 build_files_args)))
1327 1333
1328 root_makefile.write(SHARED_FOOTER) 1334 root_makefile.write(SHARED_FOOTER)
1329 1335
1330 root_makefile.close() 1336 root_makefile.close()
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