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

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

Issue 10538055: Fix make backend to correctly handle rules with output files of the same name (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/same-rule-output-file-name/gyptest-all.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 # 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 for rule_source in rule.get('rule_sources', []): 943 for rule_source in rule.get('rule_sources', []):
944 dirs = set() 944 dirs = set()
945 (rule_source_dirname, rule_source_basename) = os.path.split(rule_source) 945 (rule_source_dirname, rule_source_basename) = os.path.split(rule_source)
946 (rule_source_root, rule_source_ext) = \ 946 (rule_source_root, rule_source_ext) = \
947 os.path.splitext(rule_source_basename) 947 os.path.splitext(rule_source_basename)
948 948
949 outputs = [self.ExpandInputRoot(out, rule_source_root, 949 outputs = [self.ExpandInputRoot(out, rule_source_root,
950 rule_source_dirname) 950 rule_source_dirname)
951 for out in rule['outputs']] 951 for out in rule['outputs']]
952 952
953 # If an output is just the file name, turn it into a path so
954 # FixupArgPath() will know to Absolutify() it.
955 outputs = map(
956 lambda x : os.path.dirname(x) and x or os.path.join('.', x),
957 outputs)
958
959 for out in outputs: 953 for out in outputs:
960 dir = os.path.dirname(out) 954 dir = os.path.dirname(out)
961 if dir: 955 if dir:
962 dirs.add(dir) 956 dirs.add(dir)
963 if int(rule.get('process_outputs_as_sources', False)): 957 if int(rule.get('process_outputs_as_sources', False)):
964 extra_sources += outputs 958 extra_sources += outputs
965 if int(rule.get('process_outputs_as_mac_bundle_resources', False)): 959 if int(rule.get('process_outputs_as_mac_bundle_resources', False)):
966 extra_mac_bundle_resources += outputs 960 extra_mac_bundle_resources += outputs
967 all_outputs += outputs
968 inputs = map(Sourceify, map(self.Absolutify, [rule_source] + 961 inputs = map(Sourceify, map(self.Absolutify, [rule_source] +
969 rule.get('inputs', []))) 962 rule.get('inputs', [])))
970 actions = ['$(call do_cmd,%s_%d)' % (name, count)] 963 actions = ['$(call do_cmd,%s_%d)' % (name, count)]
971 964
972 if name == 'resources_grit': 965 if name == 'resources_grit':
973 # HACK: This is ugly. Grit intentionally doesn't touch the 966 # HACK: This is ugly. Grit intentionally doesn't touch the
974 # timestamp of its output file when the file doesn't change, 967 # timestamp of its output file when the file doesn't change,
975 # which is fine in hash-based dependency systems like scons 968 # which is fine in hash-based dependency systems like scons
976 # and forge, but not kosher in the make world. After some 969 # and forge, but not kosher in the make world. After some
977 # discussion, hacking around it here seems like the least 970 # discussion, hacking around it here seems like the least
978 # amount of pain. 971 # amount of pain.
979 actions += ['@touch --no-create $@'] 972 actions += ['@touch --no-create $@']
980 973
974 outputs = map(self.Absolutify, outputs)
975 all_outputs += outputs
981 # Only write the 'obj' and 'builddir' rules for the "primary" output 976 # Only write the 'obj' and 'builddir' rules for the "primary" output
982 # (:1); it's superfluous for the "extra outputs", and this avoids 977 # (:1); it's superfluous for the "extra outputs", and this avoids
983 # accidentally writing duplicate dummy rules for those outputs. 978 # accidentally writing duplicate dummy rules for those outputs.
984 self.WriteLn('%s: obj := $(abs_obj)' % outputs[0]) 979 self.WriteLn('%s: obj := $(abs_obj)' % outputs[0])
985 self.WriteLn('%s: builddir := $(abs_builddir)' % outputs[0]) 980 self.WriteLn('%s: builddir := $(abs_builddir)' % outputs[0])
986 self.WriteMakeRule(outputs, inputs + ['FORCE_DO_CMD'], actions) 981 self.WriteMakeRule(outputs, inputs + ['FORCE_DO_CMD'], actions)
987 for output in outputs: 982 for output in outputs:
988 assert ' ' not in output, ( 983 assert ' ' not in output, (
989 "Spaces in rule filenames not yet supported (%s)" % output) 984 "Spaces in rule filenames not yet supported (%s)" % output)
990 self.WriteLn('all_deps += %s' % ' '.join(outputs)) 985 self.WriteLn('all_deps += %s' % ' '.join(outputs))
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 def Absolutify(self, path): 1826 def Absolutify(self, path):
1832 """Convert a subdirectory-relative path into a base-relative path. 1827 """Convert a subdirectory-relative path into a base-relative path.
1833 Skips over paths that contain variables.""" 1828 Skips over paths that contain variables."""
1834 if '$(' in path: 1829 if '$(' in path:
1835 # path is no existing file in this case, but calling normpath is still 1830 # path is no existing file in this case, but calling normpath is still
1836 # important for trimming trailing slashes. 1831 # important for trimming trailing slashes.
1837 return os.path.normpath(path) 1832 return os.path.normpath(path)
1838 return os.path.normpath(os.path.join(self.path, path)) 1833 return os.path.normpath(os.path.join(self.path, path))
1839 1834
1840 1835
1841 def FixupArgPath(self, arg):
1842 if '/' in arg or '.h.' in arg:
1843 return self.Absolutify(arg)
1844 return arg
1845
1846
1847 def ExpandInputRoot(self, template, expansion, dirname): 1836 def ExpandInputRoot(self, template, expansion, dirname):
1848 if '%(INPUT_ROOT)s' not in template and '%(INPUT_DIRNAME)s' not in template: 1837 if '%(INPUT_ROOT)s' not in template and '%(INPUT_DIRNAME)s' not in template:
1849 return template 1838 return template
1850 path = template % { 1839 path = template % {
1851 'INPUT_ROOT': expansion, 1840 'INPUT_ROOT': expansion,
1852 'INPUT_DIRNAME': dirname, 1841 'INPUT_DIRNAME': dirname,
1853 } 1842 }
1854 return path 1843 return path
1855 1844
1856 1845
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 root_makefile.write(" include " + include_file + "\n") 2121 root_makefile.write(" include " + include_file + "\n")
2133 root_makefile.write("endif\n") 2122 root_makefile.write("endif\n")
2134 root_makefile.write('\n') 2123 root_makefile.write('\n')
2135 2124
2136 if generator_flags.get('auto_regeneration', True): 2125 if generator_flags.get('auto_regeneration', True):
2137 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2126 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2138 2127
2139 root_makefile.write(SHARED_FOOTER) 2128 root_makefile.write(SHARED_FOOTER)
2140 2129
2141 root_makefile.close() 2130 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | test/same-rule-output-file-name/gyptest-all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698