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

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, 4 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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')) 63 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc'))
64 flavor = gyp.common.GetFlavor(params) 64 flavor = gyp.common.GetFlavor(params)
65 default_variables.setdefault('HOST_OS', gyp.common.GetHostFlavor(params))
66
65 if flavor == 'mac': 67 if flavor == 'mac':
66 default_variables.setdefault('OS', 'mac') 68 default_variables.setdefault('OS', 'mac')
67 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') 69 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
68 default_variables.setdefault('SHARED_LIB_DIR', 70 default_variables.setdefault('SHARED_LIB_DIR',
69 generator_default_variables['PRODUCT_DIR']) 71 generator_default_variables['PRODUCT_DIR'])
70 default_variables.setdefault('LIB_DIR', 72 default_variables.setdefault('LIB_DIR',
71 generator_default_variables['PRODUCT_DIR']) 73 generator_default_variables['PRODUCT_DIR'])
72 74
73 # Copy additional generator configuration data from Xcode, which is shared 75 # Copy additional generator configuration data from Xcode, which is shared
74 # by the Mac Make generator. 76 # by the Mac Make generator.
(...skipping 1837 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_flavor = gyp.common.GetHostFlavor(params)
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_flavor == '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 elif host_flavor == 'solaris':
1986 flock_command = './gyp-sun-tool flock',
1987 header_params.update({
1988 'flock': flock_command,
1989 'flock_index': 2,
1990 })
1991 elif host_flavor == 'freebsd':
1992 flock_command = 'lockf',
1993 header_params.update({
1994 'flock': flock_command,
1995 })
1996
1997 if flavor == 'mac':
1998 header_params.update({
1981 'link_commands': LINK_COMMANDS_MAC, 1999 'link_commands': LINK_COMMANDS_MAC,
1982 'extra_commands': SHARED_HEADER_MAC_COMMANDS, 2000 'extra_commands': SHARED_HEADER_MAC_COMMANDS,
1983 }) 2001 })
1984 elif flavor == 'android': 2002 elif flavor == 'android':
1985 header_params.update({ 2003 header_params.update({
1986 'link_commands': LINK_COMMANDS_ANDROID, 2004 'link_commands': LINK_COMMANDS_ANDROID,
1987 }) 2005 })
1988 elif flavor == 'solaris': 2006 elif flavor == 'solaris':
1989 header_params.update({ 2007 header_params.update({
1990 'flock': './gyp-sun-tool flock',
1991 'flock_index': 2,
1992 'extra_commands': SHARED_HEADER_SUN_COMMANDS, 2008 'extra_commands': SHARED_HEADER_SUN_COMMANDS,
1993 }) 2009 })
1994 elif flavor == 'freebsd': 2010
1995 header_params.update({
1996 'flock': 'lockf',
1997 })
1998 header_params.update(RunSystemTests(flavor)) 2011 header_params.update(RunSystemTests(flavor))
1999 2012
2000 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) 2013 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
2001 make_global_settings_dict = data[build_file].get('make_global_settings', {}) 2014 make_global_settings_dict = data[build_file].get('make_global_settings', {})
2002 make_global_settings = '' 2015 make_global_settings = ''
2003 for key, value in make_global_settings_dict: 2016 for key, value in make_global_settings_dict:
2004 if value[0] != '$': 2017 if value[0] != '$':
2005 value = '$(abspath %s)' % value 2018 value = '$(abspath %s)' % value
2006 if key == 'LINK': 2019 if key == 'LINK':
2007 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' % 2020 make_global_settings += ('%s ?= %s $(builddir)/linker.lock %s\n' %
2008 (key, flock_command, value)) 2021 (key, flock_command, value))
2009 elif key in ['CC', 'CXX']: 2022 elif key in ['CC', 'CXX', 'AR', 'LD', 'RANLIB']:
Torne 2012/08/14 11:04:01 This still doesn't make any sense. AR should proba
2010 make_global_settings += ( 2023 make_global_settings += (
2011 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) 2024 'ifneq (,$(filter $(origin %s), undefined default))\n' % key)
2012 # Let gyp-time envvars win over global settings. 2025 # Let gyp-time envvars win over global settings.
2013 if key in os.environ: 2026 if key in os.environ:
2014 value = os.environ[key] 2027 value = os.environ[key]
2015 make_global_settings += ' %s = %s\n' % (key, value) 2028 make_global_settings += ' %s = %s\n' % (key, value)
2016 make_global_settings += 'endif\n' 2029 make_global_settings += 'endif\n'
2017 else: 2030 else:
2018 make_global_settings += '%s ?= %s\n' % (key, value) 2031 make_global_settings += '%s ?= %s\n' % (key, value)
2019 header_params['make_global_settings'] = make_global_settings 2032 header_params['make_global_settings'] = make_global_settings
2020 2033
2021 ensure_directory_exists(makefile_path) 2034 ensure_directory_exists(makefile_path)
2022 root_makefile = open(makefile_path, 'w') 2035 root_makefile = open(makefile_path, 'w')
2023 root_makefile.write(SHARED_HEADER % header_params) 2036 root_makefile.write(SHARED_HEADER % header_params)
2024 # Currently any versions have the same effect, but in future the behavior 2037 # Currently any versions have the same effect, but in future the behavior
2025 # could be different. 2038 # could be different.
2026 if android_ndk_version: 2039 if android_ndk_version:
2027 root_makefile.write( 2040 root_makefile.write(
2028 '# Define LOCAL_PATH for build of Android applications.\n' 2041 '# Define LOCAL_PATH for build of Android applications.\n'
2029 'LOCAL_PATH := $(call my-dir)\n' 2042 'LOCAL_PATH := $(call my-dir)\n'
2030 '\n') 2043 '\n')
2031 for toolset in toolsets: 2044 for toolset in toolsets:
2032 root_makefile.write('TOOLSET := %s\n' % toolset) 2045 root_makefile.write('TOOLSET := %s\n' % toolset)
2033 WriteRootHeaderSuffixRules(root_makefile) 2046 WriteRootHeaderSuffixRules(root_makefile)
2034 2047
2035 # Put build-time support tools next to the root Makefile. 2048 # Put build-time support tools next to the root Makefile.
2036 dest_path = os.path.dirname(makefile_path) 2049 dest_path = os.path.dirname(makefile_path)
2037 gyp.common.CopyTool(flavor, dest_path) 2050 gyp.common.CopyTool(host_flavor, dest_path)
2038 2051
2039 # Find the list of targets that derive from the gyp file(s) being built. 2052 # Find the list of targets that derive from the gyp file(s) being built.
2040 needed_targets = set() 2053 needed_targets = set()
2041 for build_file in params['build_files']: 2054 for build_file in params['build_files']:
2042 for target in gyp.common.AllTargets(target_list, target_dicts, build_file): 2055 for target in gyp.common.AllTargets(target_list, target_dicts, build_file):
2043 needed_targets.add(target) 2056 needed_targets.add(target)
2044 2057
2045 build_files = set() 2058 build_files = set()
2046 include_list = set() 2059 include_list = set()
2047 for qualified_target in target_list: 2060 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") 2137 root_makefile.write(" include " + include_file + "\n")
2125 root_makefile.write("endif\n") 2138 root_makefile.write("endif\n")
2126 root_makefile.write('\n') 2139 root_makefile.write('\n')
2127 2140
2128 if generator_flags.get('auto_regeneration', True): 2141 if generator_flags.get('auto_regeneration', True):
2129 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2142 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2130 2143
2131 root_makefile.write(SHARED_FOOTER) 2144 root_makefile.write(SHARED_FOOTER)
2132 2145
2133 root_makefile.close() 2146 root_makefile.close()
OLDNEW
« pylib/gyp/common.py ('K') | « pylib/gyp/common.py ('k') | pylib/gyp/generator/ninja.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698