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

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 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 | Annotate | Revision Log
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 # Placates pylint. 57 # Placates pylint.
58 generator_additional_non_configuration_keys = [] 58 generator_additional_non_configuration_keys = []
59 generator_additional_path_sections = [] 59 generator_additional_path_sections = []
60 generator_extra_sources_for_rules = [] 60 generator_extra_sources_for_rules = []
61 61
62 62
63 def CalculateVariables(default_variables, params): 63 def CalculateVariables(default_variables, params):
64 """Calculate additional variables for use in the build (called by gyp).""" 64 """Calculate additional variables for use in the build (called by gyp)."""
65 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) 65 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc'))
66 flavor = gyp.common.GetFlavor(params) 66 flavor = gyp.common.GetFlavor(params)
67 default_variables.setdefault('HOST_OS', gyp.common.GetHostOSFlavor())
68
67 if flavor == 'mac': 69 if flavor == 'mac':
68 default_variables.setdefault('OS', 'mac') 70 default_variables.setdefault('OS', 'mac')
69 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') 71 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
70 default_variables.setdefault('SHARED_LIB_DIR', 72 default_variables.setdefault('SHARED_LIB_DIR',
71 generator_default_variables['PRODUCT_DIR']) 73 generator_default_variables['PRODUCT_DIR'])
72 default_variables.setdefault('LIB_DIR', 74 default_variables.setdefault('LIB_DIR',
73 generator_default_variables['PRODUCT_DIR']) 75 generator_default_variables['PRODUCT_DIR'])
74 76
75 # Copy additional generator configuration data from Xcode, which is shared 77 # Copy additional generator configuration data from Xcode, which is shared
76 # by the Mac Make generator. 78 # by the Mac Make generator.
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 cc_command=cc_host): 1914 cc_command=cc_host):
1913 arflags_host = 'crsT' 1915 arflags_host = 'crsT'
1914 1916
1915 return { 'ARFLAGS.target': arflags_target, 1917 return { 'ARFLAGS.target': arflags_target,
1916 'ARFLAGS.host': arflags_host } 1918 'ARFLAGS.host': arflags_host }
1917 1919
1918 1920
1919 def GenerateOutput(target_list, target_dicts, data, params): 1921 def GenerateOutput(target_list, target_dicts, data, params):
1920 options = params['options'] 1922 options = params['options']
1921 flavor = gyp.common.GetFlavor(params) 1923 flavor = gyp.common.GetFlavor(params)
1924 host_os = gyp.common.GetHostOSFlavor()
Torne 2012/08/01 11:20:32 rename to host_flavor as mentioned in other commen
1922 generator_flags = params.get('generator_flags', {}) 1925 generator_flags = params.get('generator_flags', {})
1923 builddir_name = generator_flags.get('output_dir', 'out') 1926 builddir_name = generator_flags.get('output_dir', 'out')
1924 android_ndk_version = generator_flags.get('android_ndk_version', None) 1927 android_ndk_version = generator_flags.get('android_ndk_version', None)
1925 default_target = generator_flags.get('default_target', 'all') 1928 default_target = generator_flags.get('default_target', 'all')
1926 1929
1927 def CalculateMakefilePath(build_file, base_name): 1930 def CalculateMakefilePath(build_file, base_name):
1928 """Determine where to write a Makefile for a given gyp file.""" 1931 """Determine where to write a Makefile for a given gyp file."""
1929 # Paths in gyp files are relative to the .gyp file, but we want 1932 # Paths in gyp files are relative to the .gyp file, but we want
1930 # paths relative to the source root for the master makefile. Grab 1933 # paths relative to the source root for the master makefile. Grab
1931 # the path of the .gyp file as the base to relativize against. 1934 # the path of the .gyp file as the base to relativize against.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 header_params = { 1969 header_params = {
1967 'default_target': default_target, 1970 'default_target': default_target,
1968 'builddir': builddir_name, 1971 'builddir': builddir_name,
1969 'default_configuration': default_configuration, 1972 'default_configuration': default_configuration,
1970 'flock': flock_command, 1973 'flock': flock_command,
1971 'flock_index': 1, 1974 'flock_index': 1,
1972 'link_commands': LINK_COMMANDS_LINUX, 1975 'link_commands': LINK_COMMANDS_LINUX,
1973 'extra_commands': '', 1976 'extra_commands': '',
1974 'srcdir': srcdir, 1977 'srcdir': srcdir,
1975 } 1978 }
1976 if flavor == 'mac': 1979 if host_os == 'mac':
1977 flock_command = './gyp-mac-tool flock' 1980 flock_command = './gyp-mac-tool flock'
1978 header_params.update({ 1981 header_params.update({
1979 'flock': flock_command, 1982 'flock': flock_command,
1980 'flock_index': 2, 1983 'flock_index': 2,
1984 })
1985
1986 if flavor == 'mac':
1987 flock_command = './gyp-mac-tool flock'
Torne 2012/08/01 11:20:32 This line should be removed, which flock to use sh
1988 header_params.update({
1981 'link_commands': LINK_COMMANDS_MAC, 1989 'link_commands': LINK_COMMANDS_MAC,
1982 'extra_commands': SHARED_HEADER_MAC_COMMANDS, 1990 'extra_commands': SHARED_HEADER_MAC_COMMANDS,
1983 }) 1991 })
1984 elif flavor == 'android': 1992 elif flavor == 'android':
1985 header_params.update({ 1993 header_params.update({
1986 'link_commands': LINK_COMMANDS_ANDROID, 1994 'link_commands': LINK_COMMANDS_ANDROID,
1987 }) 1995 })
1988 elif flavor == 'solaris': 1996 elif flavor == 'solaris':
1989 header_params.update({ 1997 header_params.update({
1990 'flock': './gyp-sun-tool flock', 1998 'flock': './gyp-sun-tool flock',
1991 'flock_index': 2, 1999 'flock_index': 2,
1992 'extra_commands': SHARED_HEADER_SUN_COMMANDS, 2000 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
1993 }) 2001 })
1994 elif flavor == 'freebsd': 2002 elif flavor == 'freebsd':
1995 header_params.update({ 2003 header_params.update({
1996 'flock': 'lockf', 2004 'flock': 'lockf',
1997 }) 2005 })
1998 header_params.update(RunSystemTests(flavor)) 2006 header_params.update(RunSystemTests(flavor))
1999 2007
2000 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) 2008 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
2001 make_global_settings_dict = data[build_file].get('make_global_settings', {}) 2009 make_global_settings_dict = data[build_file].get('make_global_settings', {})
2002 make_global_settings = '' 2010 make_global_settings = ''
2003 for key, value in make_global_settings_dict: 2011 for key, value in make_global_settings_dict:
2004 if value[0] != '$': 2012 if value[0] != '$':
2005 value = '$(abspath %s)' % value 2013 value = '$(abspath %s)' % value
2006 if key == 'LINK': 2014 if key == 'LINK':
2007 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % 2015 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' %
2008 (key, flock_command, value)) 2016 (key, header_params['flock'], value))
Torne 2012/08/01 11:20:32 not sure this change is needed, remove it unless t
luke.weber 2012/08/07 11:52:35 It's not the right way to fix it, but you'll notic
2009 elif key in ['CC', 'CXX']: 2017 elif key in ['CC', 'CXX', 'AR', 'LD', 'RANLIB']:
Torne 2012/08/01 11:20:32 why do we need to handle AR/LD/RANLIB here now? (n
luke.weber 2012/08/07 11:52:35 If I don't do this it won't actually set the toolc
2010 make_global_settings += ( 2018 make_global_settings += (
2011 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) 2019 'ifneq (,$(filter $(origin %s), undefined default))\n' % key)
2012 # Let gyp-time envvars win over global settings. 2020 # Let gyp-time envvars win over global settings.
2013 if key in os.environ: 2021 if key in os.environ:
2014 value = os.environ[key] 2022 value = os.environ[key]
2015 make_global_settings += ' %s = %s\n' % (key, value) 2023 make_global_settings += ' %s = %s\n' % (key, value)
2016 make_global_settings += 'endif\n' 2024 make_global_settings += 'endif\n'
2017 else: 2025 else:
2018 make_global_settings += '%s ?= %s\n' % (key, value) 2026 make_global_settings += '%s ?= %s\n' % (key, value)
2019 header_params['make_global_settings'] = make_global_settings 2027 header_params['make_global_settings'] = make_global_settings
2020 2028
2021 ensure_directory_exists(makefile_path) 2029 ensure_directory_exists(makefile_path)
2022 root_makefile = open(makefile_path, 'w') 2030 root_makefile = open(makefile_path, 'w')
2023 root_makefile.write(SHARED_HEADER % header_params) 2031 root_makefile.write(SHARED_HEADER % header_params)
2024 # Currently any versions have the same effect, but in future the behavior 2032 # Currently any versions have the same effect, but in future the behavior
2025 # could be different. 2033 # could be different.
2026 if android_ndk_version: 2034 if android_ndk_version:
2027 root_makefile.write( 2035 root_makefile.write(
2028 '# Define LOCAL_PATH for build of Android applications.\n' 2036 '# Define LOCAL_PATH for build of Android applications.\n'
2029 'LOCAL_PATH := $(call my-dir)\n' 2037 'LOCAL_PATH := $(call my-dir)\n'
2030 '\n') 2038 '\n')
2031 for toolset in toolsets: 2039 for toolset in toolsets:
2032 root_makefile.write('TOOLSET := %s\n' % toolset) 2040 root_makefile.write('TOOLSET := %s\n' % toolset)
2033 WriteRootHeaderSuffixRules(root_makefile) 2041 WriteRootHeaderSuffixRules(root_makefile)
2034 2042
2035 # Put build-time support tools next to the root Makefile. 2043 # Put build-time support tools next to the root Makefile.
2036 dest_path = os.path.dirname(makefile_path) 2044 dest_path = os.path.dirname(makefile_path)
2037 gyp.common.CopyTool(flavor, dest_path) 2045 gyp.common.CopyTool(flavor, dest_path)
2046 if host_os == 'mac' and flavor != 'mac':
2047 gyp.common.CopyTool(host_os, dest_path)
Torne 2012/08/01 11:20:32 Probably this should only happen for host, not bot
luke.weber 2012/08/07 11:52:35 Was being careful not to break anything, but I thi
2038 2048
2039 # Find the list of targets that derive from the gyp file(s) being built. 2049 # Find the list of targets that derive from the gyp file(s) being built.
2040 needed_targets = set() 2050 needed_targets = set()
2041 for build_file in params['build_files']: 2051 for build_file in params['build_files']:
2042 for target in gyp.common.AllTargets(target_list, target_dicts, build_file): 2052 for target in gyp.common.AllTargets(target_list, target_dicts, build_file):
2043 needed_targets.add(target) 2053 needed_targets.add(target)
2044 2054
2045 build_files = set() 2055 build_files = set()
2046 include_list = set() 2056 include_list = set()
2047 for qualified_target in target_list: 2057 for qualified_target in target_list:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 root_makefile.write(" include " + include_file + "\n") 2134 root_makefile.write(" include " + include_file + "\n")
2125 root_makefile.write("endif\n") 2135 root_makefile.write("endif\n")
2126 root_makefile.write('\n') 2136 root_makefile.write('\n')
2127 2137
2128 if generator_flags.get('auto_regeneration', True): 2138 if generator_flags.get('auto_regeneration', True):
2129 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2139 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2130 2140
2131 root_makefile.write(SHARED_FOOTER) 2141 root_makefile.write(SHARED_FOOTER)
2132 2142
2133 root_makefile.close() 2143 root_makefile.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698