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

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

Issue 10990023: make: drop all system tests (Closed) Base URL: http://git.chromium.org/external/gyp.git@master
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | pylib/gyp/generator/ninja.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 #
11 # The code below generates a separate .mk file for each target, but 11 # The code below generates a separate .mk file for each target, but
12 # all are sourced by the top-level Makefile. This means that all 12 # all are sourced by the top-level Makefile. This means that all
13 # variables in .mk-files clobber one another. Be careful to use := 13 # variables in .mk-files clobber one another. Be careful to use :=
14 # where appropriate for immediate evaluation, and similarly to watch 14 # where appropriate for immediate evaluation, and similarly to watch
15 # that you're not relying on a variable value to last beween different 15 # that you're not relying on a variable value to last beween different
16 # .mk files. 16 # .mk files.
17 # 17 #
18 # TODOs: 18 # TODOs:
19 # 19 #
20 # Global settings and utility functions are currently stuffed in the 20 # Global settings and utility functions are currently stuffed in the
21 # toplevel Makefile. It may make sense to generate some .mk files on 21 # toplevel Makefile. It may make sense to generate some .mk files on
22 # the side to keep the the files readable. 22 # the side to keep the the files readable.
23 23
24 import os 24 import os
25 import re 25 import re
26 import sys 26 import sys
27 import subprocess 27 import subprocess
28 import gyp 28 import gyp
29 import gyp.common 29 import gyp.common
30 import gyp.system_test
31 import gyp.xcode_emulation 30 import gyp.xcode_emulation
32 from gyp.common import GetEnvironFallback 31 from gyp.common import GetEnvironFallback
33 32
34 generator_default_variables = { 33 generator_default_variables = {
35 'EXECUTABLE_PREFIX': '', 34 'EXECUTABLE_PREFIX': '',
36 'EXECUTABLE_SUFFIX': '', 35 'EXECUTABLE_SUFFIX': '',
37 'STATIC_LIB_PREFIX': 'lib', 36 'STATIC_LIB_PREFIX': 'lib',
38 'SHARED_LIB_PREFIX': 'lib', 37 'SHARED_LIB_PREFIX': 'lib',
39 'STATIC_LIB_SUFFIX': '.a', 38 'STATIC_LIB_SUFFIX': '.a',
40 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni', 39 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni',
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 # file for 118 # file for
120 # Chromium\ Framework.framework/foo 119 # Chromium\ Framework.framework/foo
121 # is for example 120 # is for example
122 # out/Release/.deps/out/Release/Chromium?Framework.framework/foo 121 # out/Release/.deps/out/Release/Chromium?Framework.framework/foo
123 # This is the replacement character. 122 # This is the replacement character.
124 SPACE_REPLACEMENT = '?' 123 SPACE_REPLACEMENT = '?'
125 124
126 125
127 LINK_COMMANDS_LINUX = """\ 126 LINK_COMMANDS_LINUX = """\
128 quiet_cmd_alink = AR($(TOOLSET)) $@ 127 quiet_cmd_alink = AR($(TOOLSET)) $@
129 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$ ^) 128 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
130 129
131 # Due to circular dependencies between libraries :(, we wrap the 130 # Due to circular dependencies between libraries :(, we wrap the
132 # special "figure out circular dependencies" flags around the entire 131 # special "figure out circular dependencies" flags around the entire
133 # input list during linking. 132 # input list during linking.
134 quiet_cmd_link = LINK($(TOOLSET)) $@ 133 quiet_cmd_link = LINK($(TOOLSET)) $@
135 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(LD_INPUTS) -Wl,--end-group $(LIBS) 134 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
136 135
137 # We support two kinds of shared objects (.so): 136 # We support two kinds of shared objects (.so):
138 # 1) shared_library, which is just bundling together many dependent libraries 137 # 1) shared_library, which is just bundling together many dependent libraries
139 # into a link line. 138 # into a link line.
(...skipping 30 matching lines...) Expand all
170 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 169 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
171 170
172 # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass 171 # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass
173 # -bundle -single_module here (for osmesa.so). 172 # -bundle -single_module here (for osmesa.so).
174 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 173 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
175 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) 174 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
176 """ 175 """
177 176
178 LINK_COMMANDS_ANDROID = """\ 177 LINK_COMMANDS_ANDROID = """\
179 quiet_cmd_alink = AR($(TOOLSET)) $@ 178 quiet_cmd_alink = AR($(TOOLSET)) $@
180 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$ ^) 179 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
181 180
182 # Due to circular dependencies between libraries :(, we wrap the 181 # Due to circular dependencies between libraries :(, we wrap the
183 # special "figure out circular dependencies" flags around the entire 182 # special "figure out circular dependencies" flags around the entire
184 # input list during linking. 183 # input list during linking.
185 quiet_cmd_link = LINK($(TOOLSET)) $@ 184 quiet_cmd_link = LINK($(TOOLSET)) $@
186 quiet_cmd_link_host = LINK($(TOOLSET)) $@ 185 quiet_cmd_link_host = LINK($(TOOLSET)) $@
187 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(LD_INPUTS) -Wl,--end-group $(LIBS) 186 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
188 cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $( LD_INPUTS) $(LIBS) 187 cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $( LD_INPUTS) $(LIBS)
189 188
190 # Other shared-object link notes: 189 # Other shared-object link notes:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 # This will allow make to invoke N linker processes as specified in -jN. 255 # This will allow make to invoke N linker processes as specified in -jN.
257 LINK ?= %(flock)s $(builddir)/linker.lock $(CXX) 256 LINK ?= %(flock)s $(builddir)/linker.lock $(CXX)
258 257
259 CC.target ?= %(CC.target)s 258 CC.target ?= %(CC.target)s
260 CFLAGS.target ?= $(CFLAGS) 259 CFLAGS.target ?= $(CFLAGS)
261 CXX.target ?= %(CXX.target)s 260 CXX.target ?= %(CXX.target)s
262 CXXFLAGS.target ?= $(CXXFLAGS) 261 CXXFLAGS.target ?= $(CXXFLAGS)
263 LINK.target ?= %(LINK.target)s 262 LINK.target ?= %(LINK.target)s
264 LDFLAGS.target ?= $(LDFLAGS) 263 LDFLAGS.target ?= $(LDFLAGS)
265 AR.target ?= $(AR) 264 AR.target ?= $(AR)
266 ARFLAGS.target ?= %(ARFLAGS.target)s
267 265
268 # N.B.: the logic of which commands to run should match the computation done
269 # in gyp's make.py where ARFLAGS.host etc. is computed.
270 # TODO(evan): move all cross-compilation logic to gyp-time so we don't need 266 # TODO(evan): move all cross-compilation logic to gyp-time so we don't need
271 # to replicate this environment fallback in make as well. 267 # to replicate this environment fallback in make as well.
272 CC.host ?= %(CC.host)s 268 CC.host ?= %(CC.host)s
273 CFLAGS.host ?= 269 CFLAGS.host ?=
274 CXX.host ?= %(CXX.host)s 270 CXX.host ?= %(CXX.host)s
275 CXXFLAGS.host ?= 271 CXXFLAGS.host ?=
276 LINK.host ?= %(LINK.host)s 272 LINK.host ?= %(LINK.host)s
277 LDFLAGS.host ?= 273 LDFLAGS.host ?=
278 AR.host ?= %(AR.host)s 274 AR.host ?= %(AR.host)s
279 ARFLAGS.host := %(ARFLAGS.host)s
280 275
281 # Define a dir function that can handle spaces. 276 # Define a dir function that can handle spaces.
282 # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions 277 # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
283 # "leading spaces cannot appear in the text of the first argument as written. 278 # "leading spaces cannot appear in the text of the first argument as written.
284 # These characters can be put into the argument value by variable substitution." 279 # These characters can be put into the argument value by variable substitution."
285 empty := 280 empty :=
286 space := $(empty) $(empty) 281 space := $(empty) $(empty)
287 282
288 # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path- with-spaces 283 # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path- with-spaces
289 replace_spaces = $(subst $(space),""" + SPACE_REPLACEMENT + """,$1) 284 replace_spaces = $(subst $(space),""" + SPACE_REPLACEMENT + """,$1)
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 "%(makefile_name)s: %(deps)s\n" 1890 "%(makefile_name)s: %(deps)s\n"
1896 "\t$(call do_cmd,regen_makefile)\n\n" % { 1891 "\t$(call do_cmd,regen_makefile)\n\n" % {
1897 'makefile_name': makefile_name, 1892 'makefile_name': makefile_name,
1898 'deps': ' '.join(map(Sourceify, build_files)), 1893 'deps': ' '.join(map(Sourceify, build_files)),
1899 'cmd': gyp.common.EncodePOSIXShellList( 1894 'cmd': gyp.common.EncodePOSIXShellList(
1900 [gyp_binary, '-fmake'] + 1895 [gyp_binary, '-fmake'] +
1901 gyp.RegenerateFlags(options) + 1896 gyp.RegenerateFlags(options) +
1902 build_files_args)}) 1897 build_files_args)})
1903 1898
1904 1899
1905 def RunSystemTests(flavor):
1906 """Run tests against the system to compute default settings for commands.
1907
1908 Returns:
1909 dictionary of settings matching the block of command-lines used in
1910 SHARED_HEADER. E.g. the dictionary will contain a ARFLAGS.target
1911 key for the default ARFLAGS for the target ar command.
1912 """
1913 # Compute flags used for building static archives.
1914 # N.B.: this fallback logic should match the logic in SHARED_HEADER.
1915 # See comment there for more details.
1916 ar_target = GetEnvironFallback(('AR_target', 'AR'), 'ar')
1917 cc_target = GetEnvironFallback(('CC_target', 'CC'), 'cc')
1918 arflags_target = 'crs'
1919 # ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it
1920 # does something useless (it limits filenames in the archive to 15 chars).
1921 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_target,
1922 cc_command=cc_target):
1923 arflags_target = 'crsT'
1924
1925 ar_host = os.environ.get('AR_host', 'ar')
1926 cc_host = os.environ.get('CC_host', 'gcc')
1927 arflags_host = 'crs'
1928 # It feels redundant to compute this again given that most builds aren't
1929 # cross-compiles, but due to quirks of history CC_host defaults to 'gcc'
1930 # while CC_target defaults to 'cc', so the commands really are different
1931 # even though they're nearly guaranteed to run the same code underneath.
1932 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host,
1933 cc_command=cc_host):
1934 arflags_host = 'crsT'
1935
1936 return { 'ARFLAGS.target': arflags_target,
1937 'ARFLAGS.host': arflags_host }
1938
1939
1940 def PerformBuild(data, configurations, params): 1900 def PerformBuild(data, configurations, params):
1941 options = params['options'] 1901 options = params['options']
1942 for config in configurations: 1902 for config in configurations:
1943 arguments = ['make'] 1903 arguments = ['make']
1944 if options.toplevel_dir and options.toplevel_dir != '.': 1904 if options.toplevel_dir and options.toplevel_dir != '.':
1945 arguments += '-C', options.toplevel_dir 1905 arguments += '-C', options.toplevel_dir
1946 arguments.append('BUILDTYPE=' + config) 1906 arguments.append('BUILDTYPE=' + config)
1947 print 'Building [%s]: %s' % (config, arguments) 1907 print 'Building [%s]: %s' % (config, arguments)
1948 subprocess.check_call(arguments) 1908 subprocess.check_call(arguments)
1949 1909
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 header_params.update({ 1981 header_params.update({
2022 'flock': './gyp-sun-tool flock', 1982 'flock': './gyp-sun-tool flock',
2023 'flock_index': 2, 1983 'flock_index': 2,
2024 'extra_commands': SHARED_HEADER_SUN_COMMANDS, 1984 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
2025 }) 1985 })
2026 elif flavor == 'freebsd': 1986 elif flavor == 'freebsd':
2027 header_params.update({ 1987 header_params.update({
2028 'flock': 'lockf', 1988 'flock': 'lockf',
2029 }) 1989 })
2030 1990
2031 header_params.update(RunSystemTests(flavor))
2032 header_params.update({ 1991 header_params.update({
2033 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), 1992 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'),
2034 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'), 1993 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'),
2035 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'), 1994 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'),
2036 'LINK.target': GetEnvironFallback(('LD_target', 'LD'), '$(LINK)'), 1995 'LINK.target': GetEnvironFallback(('LD_target', 'LD'), '$(LINK)'),
2037 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'), 1996 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'),
2038 'AR.host': GetEnvironFallback(('AR_host',), 'ar'), 1997 'AR.host': GetEnvironFallback(('AR_host',), 'ar'),
2039 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'), 1998 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'),
2040 'LINK.host': GetEnvironFallback(('LD_host',), 'g++'), 1999 'LINK.host': GetEnvironFallback(('LD_host',), 'g++'),
2041 }) 2000 })
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 root_makefile.write("endif\n") 2127 root_makefile.write("endif\n")
2169 root_makefile.write('\n') 2128 root_makefile.write('\n')
2170 2129
2171 if (not generator_flags.get('standalone') 2130 if (not generator_flags.get('standalone')
2172 and generator_flags.get('auto_regeneration', True)): 2131 and generator_flags.get('auto_regeneration', True)):
2173 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2132 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2174 2133
2175 root_makefile.write(SHARED_FOOTER) 2134 root_makefile.write(SHARED_FOOTER)
2176 2135
2177 root_makefile.close() 2136 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/generator/ninja.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698