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

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

Issue 10833021: Honor $CC/$CC_host and friends in make generator. (Closed) Base URL: http://git.chromium.org/external/gyp.git@master
Patch Set: Remove docstring cleanups (better to commit seperately) Created 8 years, 5 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 | test/compiler-override/compiler.gyp » ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 generator_wants_sorted_dependencies = False 53 generator_wants_sorted_dependencies = False
54 54
55 # Placates pylint. 55 # Placates pylint.
56 generator_additional_non_configuration_keys = [] 56 generator_additional_non_configuration_keys = []
57 generator_additional_path_sections = [] 57 generator_additional_path_sections = []
58 generator_extra_sources_for_rules = [] 58 generator_extra_sources_for_rules = []
59 59
60 60
61 def CalculateVariables(default_variables, params): 61 def CalculateVariables(default_variables, params):
62 """Calculate additional variables for use in the build (called by gyp).""" 62 """Calculate additional variables for use in the build (called by gyp)."""
63 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc'))
64 flavor = gyp.common.GetFlavor(params) 63 flavor = gyp.common.GetFlavor(params)
65 if flavor == 'mac': 64 if flavor == 'mac':
66 default_variables.setdefault('OS', 'mac') 65 default_variables.setdefault('OS', 'mac')
67 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') 66 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
68 default_variables.setdefault('SHARED_LIB_DIR', 67 default_variables.setdefault('SHARED_LIB_DIR',
69 generator_default_variables['PRODUCT_DIR']) 68 generator_default_variables['PRODUCT_DIR'])
70 default_variables.setdefault('LIB_DIR', 69 default_variables.setdefault('LIB_DIR',
71 generator_default_variables['PRODUCT_DIR']) 70 generator_default_variables['PRODUCT_DIR'])
72 71
73 # Copy additional generator configuration data from Xcode, which is shared 72 # Copy additional generator configuration data from Xcode, which is shared
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 # 247 #
249 # Note: flock is used to seralize linking. Linking is a memory-intensive 248 # Note: flock is used to seralize linking. Linking is a memory-intensive
250 # process so running parallel links can often lead to thrashing. To disable 249 # process so running parallel links can often lead to thrashing. To disable
251 # the serialization, override LINK via an envrionment variable as follows: 250 # the serialization, override LINK via an envrionment variable as follows:
252 # 251 #
253 # export LINK=g++ 252 # export LINK=g++
254 # 253 #
255 # This will allow make to invoke N linker processes as specified in -jN. 254 # This will allow make to invoke N linker processes as specified in -jN.
256 LINK ?= %(flock)s $(builddir)/linker.lock $(CXX) 255 LINK ?= %(flock)s $(builddir)/linker.lock $(CXX)
257 256
258 CC.target ?= $(CC) 257 CC.target ?= %(CC.target)s
259 CFLAGS.target ?= $(CFLAGS) 258 CFLAGS.target ?= $(CFLAGS)
260 CXX.target ?= $(CXX) 259 CXX.target ?= %(CXX.target)s
261 CXXFLAGS.target ?= $(CXXFLAGS) 260 CXXFLAGS.target ?= $(CXXFLAGS)
262 LINK.target ?= $(LINK) 261 LINK.target ?= %(LINK.target)s
263 LDFLAGS.target ?= $(LDFLAGS) 262 LDFLAGS.target ?= $(LDFLAGS)
264 AR.target ?= $(AR) 263 AR.target ?= $(AR)
265 ARFLAGS.target ?= %(ARFLAGS.target)s 264 ARFLAGS.target ?= %(ARFLAGS.target)s
266 265
267 # N.B.: the logic of which commands to run should match the computation done 266 # N.B.: the logic of which commands to run should match the computation done
268 # in gyp's make.py where ARFLAGS.host etc. is computed. 267 # in gyp's make.py where ARFLAGS.host etc. is computed.
269 # TODO(evan): move all cross-compilation logic to gyp-time so we don't need 268 # TODO(evan): move all cross-compilation logic to gyp-time so we don't need
270 # to replicate this environment fallback in make as well. 269 # to replicate this environment fallback in make as well.
271 CC.host ?= gcc 270 CC.host ?= gcc
272 CFLAGS.host ?= 271 CFLAGS.host ?=
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 """Run tests against the system to compute default settings for commands. 1883 """Run tests against the system to compute default settings for commands.
1885 1884
1886 Returns: 1885 Returns:
1887 dictionary of settings matching the block of command-lines used in 1886 dictionary of settings matching the block of command-lines used in
1888 SHARED_HEADER. E.g. the dictionary will contain a ARFLAGS.target 1887 SHARED_HEADER. E.g. the dictionary will contain a ARFLAGS.target
1889 key for the default ARFLAGS for the target ar command. 1888 key for the default ARFLAGS for the target ar command.
1890 """ 1889 """
1891 # Compute flags used for building static archives. 1890 # Compute flags used for building static archives.
1892 # N.B.: this fallback logic should match the logic in SHARED_HEADER. 1891 # N.B.: this fallback logic should match the logic in SHARED_HEADER.
1893 # See comment there for more details. 1892 # See comment there for more details.
1894 ar_target = os.environ.get('AR.target', os.environ.get('AR', 'ar')) 1893 ar_target = os.environ.get('AR.target', os.environ.get('AR_target', 'ar'))
1895 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) 1894 cc_target = os.environ.get('CC.target', os.environ.get('CC_target', 'cc'))
1896 arflags_target = 'crs' 1895 arflags_target = 'crs'
1897 # ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it 1896 # ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it
1898 # does something useless (it limits filenames in the archive to 15 chars). 1897 # does something useless (it limits filenames in the archive to 15 chars).
1899 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_target, 1898 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_target,
1900 cc_command=cc_target): 1899 cc_command=cc_target):
1901 arflags_target = 'crsT' 1900 arflags_target = 'crsT'
1902 1901
1903 ar_host = os.environ.get('AR.host', 'ar') 1902 ar_host = os.environ.get('AR.host', 'ar')
1904 cc_host = os.environ.get('CC.host', 'gcc') 1903 cc_host = os.environ.get('CC.host', 'gcc')
1905 arflags_host = 'crs' 1904 arflags_host = 'crs'
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 header_params.update({ 1987 header_params.update({
1989 'flock': './gyp-sun-tool flock', 1988 'flock': './gyp-sun-tool flock',
1990 'flock_index': 2, 1989 'flock_index': 2,
1991 'extra_commands': SHARED_HEADER_SUN_COMMANDS, 1990 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
1992 }) 1991 })
1993 elif flavor == 'freebsd': 1992 elif flavor == 'freebsd':
1994 header_params.update({ 1993 header_params.update({
1995 'flock': 'lockf', 1994 'flock': 'lockf',
1996 }) 1995 })
1997 header_params.update(RunSystemTests(flavor)) 1996 header_params.update(RunSystemTests(flavor))
1997 header_params.update({
bradn 2012/07/27 23:08:54 Style guide wants these <=80 chars per line
1998 'CC.target': os.environ.get('CC.target', os.environ.get('CC_target', '$(CC)' )),
1999 'AR.target': os.environ.get('AR.target', os.environ.get('AR_target', '$(AR)' )),
2000 'CXX.target': os.environ.get('CXX.target', os.environ.get('CXX_target', '$(C XX)')),
2001 'LINK.target': os.environ.get('LINK.target', os.environ.get('LINK_target', ' $(LINK)')) ,
2002 })
1998 2003
1999 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) 2004 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
2000 make_global_settings_dict = data[build_file].get('make_global_settings', {}) 2005 make_global_settings_dict = data[build_file].get('make_global_settings', {})
2001 make_global_settings = '' 2006 make_global_settings = ''
2002 for key, value in make_global_settings_dict: 2007 for key, value in make_global_settings_dict:
2003 if value[0] != '$': 2008 if value[0] != '$':
2004 value = '$(abspath %s)' % value 2009 value = '$(abspath %s)' % value
2005 if key == 'LINK': 2010 if key == 'LINK':
2006 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % 2011 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' %
2007 (key, flock_command, value)) 2012 (key, flock_command, value))
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 root_makefile.write(" include " + include_file + "\n") 2128 root_makefile.write(" include " + include_file + "\n")
2124 root_makefile.write("endif\n") 2129 root_makefile.write("endif\n")
2125 root_makefile.write('\n') 2130 root_makefile.write('\n')
2126 2131
2127 if generator_flags.get('auto_regeneration', True): 2132 if generator_flags.get('auto_regeneration', True):
2128 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2133 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2129 2134
2130 root_makefile.write(SHARED_FOOTER) 2135 root_makefile.write(SHARED_FOOTER)
2131 2136
2132 root_makefile.close() 2137 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | test/compiler-override/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698