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

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

Issue 10795044: Support Mac android cross compile. Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 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 | « pylib/gyp/common.py ('k') | 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 # 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 # Placates pylint. 56 # Placates pylint.
57 generator_additional_non_configuration_keys = [] 57 generator_additional_non_configuration_keys = []
58 generator_additional_path_sections = [] 58 generator_additional_path_sections = []
59 generator_extra_sources_for_rules = [] 59 generator_extra_sources_for_rules = []
60 60
61 61
62 def CalculateVariables(default_variables, params): 62 def CalculateVariables(default_variables, params):
63 """Calculate additional variables for use in the build (called by gyp).""" 63 """Calculate additional variables for use in the build (called by gyp)."""
64 flavor = gyp.common.GetFlavor(params) 64 flavor = gyp.common.GetFlavor(params)
65 default_variables.setdefault('HOST_OS', gyp.common.GetHostOS())
65 if flavor == 'mac': 66 if flavor == 'mac':
66 default_variables.setdefault('OS', 'mac') 67 default_variables.setdefault('OS', 'mac')
67 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') 68 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
68 default_variables.setdefault('SHARED_LIB_DIR', 69 default_variables.setdefault('SHARED_LIB_DIR',
69 generator_default_variables['PRODUCT_DIR']) 70 generator_default_variables['PRODUCT_DIR'])
70 default_variables.setdefault('LIB_DIR', 71 default_variables.setdefault('LIB_DIR',
71 generator_default_variables['PRODUCT_DIR']) 72 generator_default_variables['PRODUCT_DIR'])
72 73
73 # Copy additional generator configuration data from Xcode, which is shared 74 # Copy additional generator configuration data from Xcode, which is shared
74 # by the Mac Make generator. 75 # by the Mac Make generator.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 # the local, absolute paths used on the link command-line. 155 # the local, absolute paths used on the link command-line.
155 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 156 quiet_cmd_solink = SOLINK($(TOOLSET)) $@
156 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl ,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(L IBS) 157 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl ,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(L IBS)
157 158
158 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 159 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
159 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl ,--end-group $(LIBS) 160 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl ,--end-group $(LIBS)
160 """ 161 """
161 162
162 LINK_COMMANDS_MAC = """\ 163 LINK_COMMANDS_MAC = """\
163 quiet_cmd_alink = LIBTOOL-STATIC $@ 164 quiet_cmd_alink = LIBTOOL-STATIC $@
164 cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS ) -static -o $@ $(filter %.o,$^) 165 cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS ) -v -static -o $@ $(filter %.o,$^)
166
167 quiet_cmd_alink_thin = LIBTOOL-STATIC-THIN-FAKE $@
168 cmd_alink_thin = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOL FLAGS) -v -static -o $@ $(filter %.o,$^)
165 169
166 quiet_cmd_link = LINK($(TOOLSET)) $@ 170 quiet_cmd_link = LINK($(TOOLSET)) $@
167 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_ INPUTS) $(LIBS) 171 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_ INPUTS) $(LIBS)
168 172
169 # TODO(thakis): Find out and document the difference between shared_library and 173 # TODO(thakis): Find out and document the difference between shared_library and
170 # loadable_module on mac. 174 # loadable_module on mac.
171 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 175 quiet_cmd_solink = SOLINK($(TOOLSET)) $@
172 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 176 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
173 177
174 # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass 178 # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass
175 # -bundle -single_module here (for osmesa.so). 179 # -bundle -single_module here (for osmesa.so).
176 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 180 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
177 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) 181 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
178 """ 182 """
179 183
180 LINK_COMMANDS_ANDROID = """\ 184 LINK_COMMANDS_ANDROID = """\
181 quiet_cmd_alink = AR($(TOOLSET)) $@ 185 quiet_cmd_alink_target = AR($(TOOLSET)) $@
182 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) 186 cmd_alink_target = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
183 187
184 quiet_cmd_alink_thin = AR($(TOOLSET)) $@ 188 quiet_cmd_alink_thin_target = AR($(TOOLSET)) $@
185 cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) 189 cmd_alink_thin_target = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
186 190
187 # Due to circular dependencies between libraries :(, we wrap the 191 # Due to circular dependencies between libraries :(, we wrap the
188 # special "figure out circular dependencies" flags around the entire 192 # special "figure out circular dependencies" flags around the entire
189 # input list during linking. 193 # input list during linking.
190 quiet_cmd_link = LINK($(TOOLSET)) $@ 194 quiet_cmd_link_target = LINK($(TOOLSET)) $@
191 quiet_cmd_link_host = LINK($(TOOLSET)) $@ 195 cmd_link_target = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
192 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
193 cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $( LD_INPUTS) $(LIBS)
194 196
195 # Other shared-object link notes: 197 # Other shared-object link notes:
196 # - Set SONAME to the library filename so our binaries don't reference 198 # - Set SONAME to the library filename so our binaries don't reference
197 # the local, absolute paths used on the link command-line. 199 # the local, absolute paths used on the link command-line.
198 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 200 quiet_cmd_solink_target = SOLINK($(TOOLSET)) $@
199 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl ,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(L IBS) 201 cmd_solink_target = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-arch ive $(LIBS)
200 202
201 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 203 quiet_cmd_solink_module_target = SOLINK_MODULE($(TOOLSET)) $@
202 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl ,--end-group $(LIBS) 204 cmd_solink_module_target = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$ (TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
203 quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@ 205 quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@
204 cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(T OOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) 206 cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(T OOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
205 """ 207 """
206 208
207 209
208 # Header of toplevel Makefile. 210 # Header of toplevel Makefile.
209 # This should go into the build tree, but it's easier to keep it here for now. 211 # This should go into the build tree, but it's easier to keep it here for now.
210 SHARED_HEADER = ("""\ 212 SHARED_HEADER = ("""\
211 # We borrow heavily from the kernel build setup, though we are simpler since 213 # We borrow heavily from the kernel build setup, though we are simpler since
212 # we don't have Kconfig tweaking settings on us. 214 # we don't have Kconfig tweaking settings on us.
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 if postbuilds: 1510 if postbuilds:
1509 assert not self.is_mac_bundle, ('Postbuilds for bundles should be done ' 1511 assert not self.is_mac_bundle, ('Postbuilds for bundles should be done '
1510 'on the bundle, not the binary (target \'%s\')' % self.target) 1512 'on the bundle, not the binary (target \'%s\')' % self.target)
1511 assert 'product_dir' not in spec, ('Postbuilds do not work with ' 1513 assert 'product_dir' not in spec, ('Postbuilds do not work with '
1512 'custom product_dir') 1514 'custom product_dir')
1513 1515
1514 if self.type == 'executable': 1516 if self.type == 'executable':
1515 self.WriteLn('%s: LD_INPUTS := %s' % ( 1517 self.WriteLn('%s: LD_INPUTS := %s' % (
1516 QuoteSpaces(self.output_binary), 1518 QuoteSpaces(self.output_binary),
1517 ' '.join(map(QuoteSpaces, link_deps)))) 1519 ' '.join(map(QuoteSpaces, link_deps))))
1518 if self.toolset == 'host' and self.flavor == 'android': 1520 if self.toolset == 'target' and self.flavor == 'android':
1519 self.WriteDoCmd([self.output_binary], link_deps, 'link_host', 1521 self.WriteDoCmd([self.output_binary], link_deps, 'link_target',
1520 part_of_all, postbuilds=postbuilds) 1522 part_of_all, postbuilds=postbuilds)
1521 else: 1523 else:
1522 self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all, 1524 self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all,
1523 postbuilds=postbuilds) 1525 postbuilds=postbuilds)
1524 1526
1525 elif self.type == 'static_library': 1527 elif self.type == 'static_library':
1526 for link_dep in link_deps: 1528 for link_dep in link_deps:
1527 assert ' ' not in link_dep, ( 1529 assert ' ' not in link_dep, (
1528 "Spaces in alink input filenames not supported (%s)" % link_dep) 1530 "Spaces in alink input filenames not supported (%s)" % link_dep)
1529 if (self.flavor not in ('mac', 'win') and not 1531 if (self.flavor not in ('mac', 'win') and not
1530 self.is_standalone_static_library): 1532 self.is_standalone_static_library):
1531 self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin', 1533 if self.toolset == 'target' and self.flavor == 'android':
1532 part_of_all, postbuilds=postbuilds) 1534 self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin_target',
1535 part_of_all, postbuilds=postbuilds)
1536 else:
1537 self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin',
1538 part_of_all, postbuilds=postbuilds)
1533 else: 1539 else:
1534 self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, 1540 if self.toolset == 'target' and self.flavor == 'android':
1535 postbuilds=postbuilds) 1541 self.WriteDoCmd([self.output_binary], link_deps, 'alink_target',
1542 part_of_all, postbuilds=postbuilds)
1543 else:
1544 self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all,
1545 postbuilds=postbuilds)
1536 elif self.type == 'shared_library': 1546 elif self.type == 'shared_library':
1537 self.WriteLn('%s: LD_INPUTS := %s' % ( 1547 self.WriteLn('%s: LD_INPUTS := %s' % (
1538 QuoteSpaces(self.output_binary), 1548 QuoteSpaces(self.output_binary),
1539 ' '.join(map(QuoteSpaces, link_deps)))) 1549 ' '.join(map(QuoteSpaces, link_deps))))
1540 self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, 1550 if self.toolset == 'target' and self.flavor == 'android':
1541 postbuilds=postbuilds) 1551 self.WriteDoCmd([self.output_binary], link_deps, 'solink_target',
1552 part_of_all, postbuilds=postbuilds)
1553 else:
1554 self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all,
1555 postbuilds=postbuilds)
1542 elif self.type == 'loadable_module': 1556 elif self.type == 'loadable_module':
1543 for link_dep in link_deps: 1557 for link_dep in link_deps:
1544 assert ' ' not in link_dep, ( 1558 assert ' ' not in link_dep, (
1545 "Spaces in module input filenames not supported (%s)" % link_dep) 1559 "Spaces in module input filenames not supported (%s)" % link_dep)
1546 if self.toolset == 'host' and self.flavor == 'android': 1560 if self.toolset == 'target' and self.flavor == 'android':
1547 self.WriteDoCmd([self.output_binary], link_deps, 'solink_module_host', 1561 self.WriteDoCmd([self.output_binary], link_deps, 'solink_module_target',
1548 part_of_all, postbuilds=postbuilds) 1562 part_of_all, postbuilds=postbuilds)
1549 else: 1563 else:
1550 self.WriteDoCmd( 1564 self.WriteDoCmd(
1551 [self.output_binary], link_deps, 'solink_module', part_of_all, 1565 [self.output_binary], link_deps, 'solink_module', part_of_all,
1552 postbuilds=postbuilds) 1566 postbuilds=postbuilds)
1553 elif self.type == 'none': 1567 elif self.type == 'none':
1554 # Write a stamp line. 1568 # Write a stamp line.
1555 self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all, 1569 self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all,
1556 postbuilds=postbuilds) 1570 postbuilds=postbuilds)
1557 else: 1571 else:
1558 print "WARNING: no output for", self.type, target 1572 print "WARNING: no output for", self.type, target
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 if options.toplevel_dir and options.toplevel_dir != '.': 1920 if options.toplevel_dir and options.toplevel_dir != '.':
1907 arguments += '-C', options.toplevel_dir 1921 arguments += '-C', options.toplevel_dir
1908 arguments.append('BUILDTYPE=' + config) 1922 arguments.append('BUILDTYPE=' + config)
1909 print 'Building [%s]: %s' % (config, arguments) 1923 print 'Building [%s]: %s' % (config, arguments)
1910 subprocess.check_call(arguments) 1924 subprocess.check_call(arguments)
1911 1925
1912 1926
1913 def GenerateOutput(target_list, target_dicts, data, params): 1927 def GenerateOutput(target_list, target_dicts, data, params):
1914 options = params['options'] 1928 options = params['options']
1915 flavor = gyp.common.GetFlavor(params) 1929 flavor = gyp.common.GetFlavor(params)
1930 host_os = gyp.common.GetHostOS()
1916 generator_flags = params.get('generator_flags', {}) 1931 generator_flags = params.get('generator_flags', {})
1917 builddir_name = generator_flags.get('output_dir', 'out') 1932 builddir_name = generator_flags.get('output_dir', 'out')
1918 android_ndk_version = generator_flags.get('android_ndk_version', None) 1933 android_ndk_version = generator_flags.get('android_ndk_version', None)
1919 default_target = generator_flags.get('default_target', 'all') 1934 default_target = generator_flags.get('default_target', 'all')
1920 1935
1921 def CalculateMakefilePath(build_file, base_name): 1936 def CalculateMakefilePath(build_file, base_name):
1922 """Determine where to write a Makefile for a given gyp file.""" 1937 """Determine where to write a Makefile for a given gyp file."""
1923 # Paths in gyp files are relative to the .gyp file, but we want 1938 # Paths in gyp files are relative to the .gyp file, but we want
1924 # paths relative to the source root for the master makefile. Grab 1939 # paths relative to the source root for the master makefile. Grab
1925 # the path of the .gyp file as the base to relativize against. 1940 # the path of the .gyp file as the base to relativize against.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 header_params = { 1975 header_params = {
1961 'default_target': default_target, 1976 'default_target': default_target,
1962 'builddir': builddir_name, 1977 'builddir': builddir_name,
1963 'default_configuration': default_configuration, 1978 'default_configuration': default_configuration,
1964 'flock': flock_command, 1979 'flock': flock_command,
1965 'flock_index': 1, 1980 'flock_index': 1,
1966 'link_commands': LINK_COMMANDS_LINUX, 1981 'link_commands': LINK_COMMANDS_LINUX,
1967 'extra_commands': '', 1982 'extra_commands': '',
1968 'srcdir': srcdir, 1983 'srcdir': srcdir,
1969 } 1984 }
1970 if flavor == 'mac': 1985 if host_os == 'mac':
1971 flock_command = './gyp-mac-tool flock' 1986 flock_command = './gyp-mac-tool flock'
1972 header_params.update({ 1987 header_params.update({
1973 'flock': flock_command, 1988 'flock': flock_command,
1974 'flock_index': 2, 1989 'flock_index': 2,
1975 'link_commands': LINK_COMMANDS_MAC, 1990 'link_commands': LINK_COMMANDS_MAC,
1991 })
1992 elif host_os == 'solaris':
1993 flock_command = './gyp-sun-tool flock',
1994 header_params.update({
1995 'flock': flock_command,
1996 'flock_index': 2,
1997 })
1998 elif host_os == 'freebsd':
1999 flock_command = 'lockf',
2000 header_params.update({
2001 'flock': flock_command,
2002 })
2003
2004 if flavor == 'mac':
2005 header_params.update({
1976 'extra_commands': SHARED_HEADER_MAC_COMMANDS, 2006 'extra_commands': SHARED_HEADER_MAC_COMMANDS,
1977 }) 2007 })
2008 elif flavor == 'solaris':
2009 header_params.update({
2010 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
2011 })
1978 elif flavor == 'android': 2012 elif flavor == 'android':
1979 header_params.update({ 2013 header_params.update({
1980 'link_commands': LINK_COMMANDS_ANDROID, 2014 'extra_commands': LINK_COMMANDS_ANDROID,
1981 })
1982 elif flavor == 'solaris':
1983 header_params.update({
1984 'flock': './gyp-sun-tool flock',
1985 'flock_index': 2,
1986 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
1987 })
1988 elif flavor == 'freebsd':
1989 header_params.update({
1990 'flock': 'lockf',
1991 }) 2015 })
1992 2016
1993 header_params.update({ 2017 header_params.update({
1994 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), 2018 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'),
1995 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'), 2019 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'),
1996 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'), 2020 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'),
1997 'LINK.target': GetEnvironFallback(('LD_target', 'LD'), '$(LINK)'), 2021 'LINK.target': GetEnvironFallback(('LD_target', 'LD'), '$(LINK)'),
1998 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'), 2022 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'),
1999 'AR.host': GetEnvironFallback(('AR_host',), 'ar'), 2023 'AR.host': GetEnvironFallback(('AR_host',), 'ar'),
2000 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'), 2024 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'),
2001 'LINK.host': GetEnvironFallback(('LD_host',), 'g++'), 2025 'LINK.host': GetEnvironFallback(('LD_host',), 'g++'),
2002 }) 2026 })
2003 2027
2004 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) 2028 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
2005 make_global_settings_array = data[build_file].get('make_global_settings', []) 2029 make_global_settings_array = data[build_file].get('make_global_settings', [])
2006 make_global_settings = '' 2030 make_global_settings = ''
2007 for key, value in make_global_settings_array: 2031 for key, value in make_global_settings_array:
2008 if value[0] != '$': 2032 if value[0] != '$':
2009 value = '$(abspath %s)' % value 2033 value = '$(abspath %s)' % value
2010 if key == 'LINK': 2034 if key == 'LINK':
2011 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % 2035 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' %
2012 (key, flock_command, value)) 2036 (key, flock_command, value))
2013 elif key in ('CC', 'CC.host', 'CXX', 'CXX.host'): 2037 elif key in ('CC', 'CC.host', 'CXX', 'CXX.host', 'AR', 'AR.host'):
2014 make_global_settings += ( 2038 make_global_settings += (
2015 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) 2039 'ifneq (,$(filter $(origin %s), undefined default))\n' % key)
2016 # Let gyp-time envvars win over global settings. 2040 # Let gyp-time envvars win over global settings.
2017 if key in os.environ: 2041 if key in os.environ:
2018 value = os.environ[key] 2042 value = os.environ[key]
2019 make_global_settings += ' %s = %s\n' % (key, value) 2043 make_global_settings += ' %s = %s\n' % (key, value)
2020 make_global_settings += 'endif\n' 2044 make_global_settings += 'endif\n'
2021 else: 2045 else:
2022 make_global_settings += '%s ?= %s\n' % (key, value) 2046 make_global_settings += '%s ?= %s\n' % (key, value)
2023 header_params['make_global_settings'] = make_global_settings 2047 header_params['make_global_settings'] = make_global_settings
2024 2048
2025 ensure_directory_exists(makefile_path) 2049 ensure_directory_exists(makefile_path)
2026 root_makefile = open(makefile_path, 'w') 2050 root_makefile = open(makefile_path, 'w')
2027 root_makefile.write(SHARED_HEADER % header_params) 2051 root_makefile.write(SHARED_HEADER % header_params)
2028 # Currently any versions have the same effect, but in future the behavior 2052 # Currently any versions have the same effect, but in future the behavior
2029 # could be different. 2053 # could be different.
2030 if android_ndk_version: 2054 if android_ndk_version:
2031 root_makefile.write( 2055 root_makefile.write(
2032 '# Define LOCAL_PATH for build of Android applications.\n' 2056 '# Define LOCAL_PATH for build of Android applications.\n'
2033 'LOCAL_PATH := $(call my-dir)\n' 2057 'LOCAL_PATH := $(call my-dir)\n'
2034 '\n') 2058 '\n')
2035 for toolset in toolsets: 2059 for toolset in toolsets:
2036 root_makefile.write('TOOLSET := %s\n' % toolset) 2060 root_makefile.write('TOOLSET := %s\n' % toolset)
2037 WriteRootHeaderSuffixRules(root_makefile) 2061 WriteRootHeaderSuffixRules(root_makefile)
2038 2062
2039 # Put build-time support tools next to the root Makefile. 2063 # Put build-time support tools next to the root Makefile.
2040 dest_path = os.path.dirname(makefile_path) 2064 dest_path = os.path.dirname(makefile_path)
2041 gyp.common.CopyTool(flavor, dest_path) 2065 gyp.common.CopyTool(host_os, dest_path)
2042 2066
2043 # Find the list of targets that derive from the gyp file(s) being built. 2067 # Find the list of targets that derive from the gyp file(s) being built.
2044 needed_targets = set() 2068 needed_targets = set()
2045 for build_file in params['build_files']: 2069 for build_file in params['build_files']:
2046 for target in gyp.common.AllTargets(target_list, target_dicts, build_file): 2070 for target in gyp.common.AllTargets(target_list, target_dicts, build_file):
2047 needed_targets.add(target) 2071 needed_targets.add(target)
2048 2072
2049 build_files = set() 2073 build_files = set()
2050 include_list = set() 2074 include_list = set()
2051 for qualified_target in target_list: 2075 for qualified_target in target_list:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 root_makefile.write("endif\n") 2153 root_makefile.write("endif\n")
2130 root_makefile.write('\n') 2154 root_makefile.write('\n')
2131 2155
2132 if (not generator_flags.get('standalone') 2156 if (not generator_flags.get('standalone')
2133 and generator_flags.get('auto_regeneration', True)): 2157 and generator_flags.get('auto_regeneration', True)):
2134 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2158 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2135 2159
2136 root_makefile.write(SHARED_FOOTER) 2160 root_makefile.write(SHARED_FOOTER)
2137 2161
2138 root_makefile.close() 2162 root_makefile.close()
OLDNEW
« no previous file with comments | « pylib/gyp/common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698