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

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

Issue 10447063: Fix make and ninja backends to sensibly handle duplicate target names in different directories (Closed) Base URL: http://git.chromium.org/external/gyp.git@master
Patch Set: 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
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 # Notes: 5 # Notes:
6 # 6 #
7 # This is all roughly based on the Makefile system used by the Linux 7 # This is all roughly based on the Makefile system used by the Linux
8 # kernel, but is a non-recursive make -- we put the entire dependency 8 # kernel, but is a non-recursive make -- we put the entire dependency
9 # graph in front of make and let it figure it out. 9 # graph in front of make and let it figure it out.
10 # 10 #
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 output_filename: output .mk file name to write 687 output_filename: output .mk file name to write
688 spec, configs: gyp info 688 spec, configs: gyp info
689 part_of_all: flag indicating this target is part of 'all' 689 part_of_all: flag indicating this target is part of 'all'
690 """ 690 """
691 ensure_directory_exists(output_filename) 691 ensure_directory_exists(output_filename)
692 692
693 self.fp = open(output_filename, 'w') 693 self.fp = open(output_filename, 'w')
694 694
695 self.fp.write(header) 695 self.fp.write(header)
696 696
697 self.qualified_target = qualified_target
697 self.path = base_path 698 self.path = base_path
698 self.target = spec['target_name'] 699 self.target = spec['target_name']
699 self.type = spec['type'] 700 self.type = spec['type']
700 self.toolset = spec['toolset'] 701 self.toolset = spec['toolset']
701 702
702 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) 703 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec)
703 if self.flavor == 'mac': 704 if self.flavor == 'mac':
704 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) 705 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec)
705 else: 706 else:
706 self.xcode_settings = None 707 self.xcode_settings = None
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 """Write Makefile code for any 'actions' from the gyp input. 834 """Write Makefile code for any 'actions' from the gyp input.
834 835
835 extra_sources: a list that will be filled in with newly generated source 836 extra_sources: a list that will be filled in with newly generated source
836 files, if any 837 files, if any
837 extra_outputs: a list that will be filled in with any outputs of these 838 extra_outputs: a list that will be filled in with any outputs of these
838 actions (used to make other pieces dependent on these 839 actions (used to make other pieces dependent on these
839 actions) 840 actions)
840 part_of_all: flag indicating this target is part of 'all' 841 part_of_all: flag indicating this target is part of 'all'
841 """ 842 """
842 for action in actions: 843 for action in actions:
843 name = self.target + '_' + StringToMakefileVariable(action['action_name']) 844 name = StringToMakefileVariable('%s_%s' % (self.qualified_target,
845 action['action_name']))
844 self.WriteLn('### Rules for action "%s":' % action['action_name']) 846 self.WriteLn('### Rules for action "%s":' % action['action_name'])
845 inputs = action['inputs'] 847 inputs = action['inputs']
846 outputs = action['outputs'] 848 outputs = action['outputs']
847 849
848 # Build up a list of outputs. 850 # Build up a list of outputs.
849 # Collect the output dirs we'll need. 851 # Collect the output dirs we'll need.
850 dirs = set() 852 dirs = set()
851 for out in outputs: 853 for out in outputs:
852 dir = os.path.split(out)[0] 854 dir = os.path.split(out)[0]
853 if dir: 855 if dir:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 extra_mac_bundle_resources, part_of_all): 929 extra_mac_bundle_resources, part_of_all):
928 """Write Makefile code for any 'rules' from the gyp input. 930 """Write Makefile code for any 'rules' from the gyp input.
929 931
930 extra_sources: a list that will be filled in with newly generated source 932 extra_sources: a list that will be filled in with newly generated source
931 files, if any 933 files, if any
932 extra_outputs: a list that will be filled in with any outputs of these 934 extra_outputs: a list that will be filled in with any outputs of these
933 rules (used to make other pieces dependent on these rules) 935 rules (used to make other pieces dependent on these rules)
934 part_of_all: flag indicating this target is part of 'all' 936 part_of_all: flag indicating this target is part of 'all'
935 """ 937 """
936 for rule in rules: 938 for rule in rules:
937 name = self.target + '_' + StringToMakefileVariable(rule['rule_name']) 939 name = StringToMakefileVariable('%s_%s' % (self.qualified_target,
940 rule['rule_name']))
938 count = 0 941 count = 0
939 self.WriteLn('### Generated for rule %s:' % name) 942 self.WriteLn('### Generated for rule %s:' % name)
940 943
941 all_outputs = [] 944 all_outputs = []
942 945
943 for rule_source in rule.get('rule_sources', []): 946 for rule_source in rule.get('rule_sources', []):
944 dirs = set() 947 dirs = set()
945 (rule_source_dirname, rule_source_basename) = os.path.split(rule_source) 948 (rule_source_dirname, rule_source_basename) = os.path.split(rule_source)
946 (rule_source_root, rule_source_ext) = \ 949 (rule_source_root, rule_source_ext) = \
947 os.path.splitext(rule_source_basename) 950 os.path.splitext(rule_source_basename)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1045
1043 def WriteCopies(self, copies, extra_outputs, part_of_all): 1046 def WriteCopies(self, copies, extra_outputs, part_of_all):
1044 """Write Makefile code for any 'copies' from the gyp input. 1047 """Write Makefile code for any 'copies' from the gyp input.
1045 1048
1046 extra_outputs: a list that will be filled in with any outputs of this action 1049 extra_outputs: a list that will be filled in with any outputs of this action
1047 (used to make other pieces dependent on this action) 1050 (used to make other pieces dependent on this action)
1048 part_of_all: flag indicating this target is part of 'all' 1051 part_of_all: flag indicating this target is part of 'all'
1049 """ 1052 """
1050 self.WriteLn('### Generated for copy rule.') 1053 self.WriteLn('### Generated for copy rule.')
1051 1054
1052 variable = self.target + '_copies' 1055 variable = StringToMakefileVariable(self.qualified_target + '_copies')
1053 outputs = [] 1056 outputs = []
1054 for copy in copies: 1057 for copy in copies:
1055 for path in copy['files']: 1058 for path in copy['files']:
1056 # Absolutify() calls normpath, stripping trailing slashes. 1059 # Absolutify() calls normpath, stripping trailing slashes.
1057 path = Sourceify(self.Absolutify(path)) 1060 path = Sourceify(self.Absolutify(path))
1058 filename = os.path.split(path)[1] 1061 filename = os.path.split(path)[1]
1059 output = Sourceify(self.Absolutify(os.path.join(copy['destination'], 1062 output = Sourceify(self.Absolutify(os.path.join(copy['destination'],
1060 filename))) 1063 filename)))
1061 1064
1062 # If the output path has variables in it, which happens in practice for 1065 # If the output path has variables in it, which happens in practice for
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 root_makefile.write(" include " + include_file + "\n") 2135 root_makefile.write(" include " + include_file + "\n")
2133 root_makefile.write("endif\n") 2136 root_makefile.write("endif\n")
2134 root_makefile.write('\n') 2137 root_makefile.write('\n')
2135 2138
2136 if generator_flags.get('auto_regeneration', True): 2139 if generator_flags.get('auto_regeneration', True):
2137 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2140 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2138 2141
2139 root_makefile.write(SHARED_FOOTER) 2142 root_makefile.write(SHARED_FOOTER)
2140 2143
2141 root_makefile.close() 2144 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/generator/ninja.py » ('j') | test/same-target-name-different-directory/gyptest-all.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698