OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 = GetEnv('AR.target', 'AR_target', 'ar') |
1895 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) | 1894 cc_target = GetEnv('CC.target', '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' |
1906 # It feels redundant to compute this again given that most builds aren't | 1905 # It feels redundant to compute this again given that most builds aren't |
1907 # cross-compiles, but due to quirks of history CC.host defaults to 'gcc' | 1906 # cross-compiles, but due to quirks of history CC.host defaults to 'gcc' |
1908 # while CC.target defaults to 'cc', so the commands really are different | 1907 # while CC.target defaults to 'cc', so the commands really are different |
1909 # even though they're nearly guaranteed to run the same code underneath. | 1908 # even though they're nearly guaranteed to run the same code underneath. |
1910 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host, | 1909 if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host, |
1911 cc_command=cc_host): | 1910 cc_command=cc_host): |
1912 arflags_host = 'crsT' | 1911 arflags_host = 'crsT' |
1913 | 1912 |
1914 return { 'ARFLAGS.target': arflags_target, | 1913 return { 'ARFLAGS.target': arflags_target, |
1915 'ARFLAGS.host': arflags_host } | 1914 'ARFLAGS.host': arflags_host } |
1916 | 1915 |
1917 | 1916 |
| 1917 def GetEnv(primary, secondary, default): |
| 1918 """Look up a key in the environment, falling back to a secondary key |
| 1919 and finally falling back to a default value.""" |
| 1920 return os.environ.get(primary, os.environ.get(secondary, default)) |
| 1921 |
1918 def GenerateOutput(target_list, target_dicts, data, params): | 1922 def GenerateOutput(target_list, target_dicts, data, params): |
1919 options = params['options'] | 1923 options = params['options'] |
1920 flavor = gyp.common.GetFlavor(params) | 1924 flavor = gyp.common.GetFlavor(params) |
1921 generator_flags = params.get('generator_flags', {}) | 1925 generator_flags = params.get('generator_flags', {}) |
1922 builddir_name = generator_flags.get('output_dir', 'out') | 1926 builddir_name = generator_flags.get('output_dir', 'out') |
1923 android_ndk_version = generator_flags.get('android_ndk_version', None) | 1927 android_ndk_version = generator_flags.get('android_ndk_version', None) |
1924 default_target = generator_flags.get('default_target', 'all') | 1928 default_target = generator_flags.get('default_target', 'all') |
1925 | 1929 |
1926 def CalculateMakefilePath(build_file, base_name): | 1930 def CalculateMakefilePath(build_file, base_name): |
1927 """Determine where to write a Makefile for a given gyp file.""" | 1931 """Determine where to write a Makefile for a given gyp file.""" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 elif flavor == 'solaris': | 1991 elif flavor == 'solaris': |
1988 header_params.update({ | 1992 header_params.update({ |
1989 'flock': './gyp-sun-tool flock', | 1993 'flock': './gyp-sun-tool flock', |
1990 'flock_index': 2, | 1994 'flock_index': 2, |
1991 'extra_commands': SHARED_HEADER_SUN_COMMANDS, | 1995 'extra_commands': SHARED_HEADER_SUN_COMMANDS, |
1992 }) | 1996 }) |
1993 elif flavor == 'freebsd': | 1997 elif flavor == 'freebsd': |
1994 header_params.update({ | 1998 header_params.update({ |
1995 'flock': 'lockf', | 1999 'flock': 'lockf', |
1996 }) | 2000 }) |
| 2001 |
1997 header_params.update(RunSystemTests(flavor)) | 2002 header_params.update(RunSystemTests(flavor)) |
| 2003 header_params.update({ |
| 2004 'CC.target': GetEnv('CC.target', 'CC_target', '$(CC)'), |
| 2005 'AR.target': GetEnv('AR.target', 'AR_target', '$(AR)'), |
| 2006 'CXX.target': GetEnv('CXX.target', 'CXX_target', '$(CXX)'), |
| 2007 'LINK.target': GetEnv('LINK.target', 'LD_target', '$(LINK)'), |
| 2008 }) |
1998 | 2009 |
1999 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) | 2010 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
2000 make_global_settings_dict = data[build_file].get('make_global_settings', {}) | 2011 make_global_settings_dict = data[build_file].get('make_global_settings', {}) |
2001 make_global_settings = '' | 2012 make_global_settings = '' |
2002 for key, value in make_global_settings_dict: | 2013 for key, value in make_global_settings_dict: |
2003 if value[0] != '$': | 2014 if value[0] != '$': |
2004 value = '$(abspath %s)' % value | 2015 value = '$(abspath %s)' % value |
2005 if key == 'LINK': | 2016 if key == 'LINK': |
2006 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % | 2017 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % |
2007 (key, flock_command, value)) | 2018 (key, flock_command, value)) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 root_makefile.write(" include " + include_file + "\n") | 2134 root_makefile.write(" include " + include_file + "\n") |
2124 root_makefile.write("endif\n") | 2135 root_makefile.write("endif\n") |
2125 root_makefile.write('\n') | 2136 root_makefile.write('\n') |
2126 | 2137 |
2127 if generator_flags.get('auto_regeneration', True): | 2138 if generator_flags.get('auto_regeneration', True): |
2128 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) | 2139 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) |
2129 | 2140 |
2130 root_makefile.write(SHARED_FOOTER) | 2141 root_makefile.write(SHARED_FOOTER) |
2131 | 2142 |
2132 root_makefile.close() | 2143 root_makefile.close() |
OLD | NEW |