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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pylib/gyp/generator/ninja.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/generator/make.py
diff --git a/pylib/gyp/generator/make.py b/pylib/gyp/generator/make.py
index f915d94bfec4d3348d5e90fdf5cb274c63fd3f4b..8623b1f1c952ddee25a2fde6178cf8f1f78cec27 100644
--- a/pylib/gyp/generator/make.py
+++ b/pylib/gyp/generator/make.py
@@ -60,7 +60,6 @@ generator_extra_sources_for_rules = []
def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
- cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc'))
flavor = gyp.common.GetFlavor(params)
if flavor == 'mac':
default_variables.setdefault('OS', 'mac')
@@ -255,11 +254,11 @@ all_deps :=
# This will allow make to invoke N linker processes as specified in -jN.
LINK ?= %(flock)s $(builddir)/linker.lock $(CXX)
-CC.target ?= $(CC)
+CC.target ?= %(CC.target)s
CFLAGS.target ?= $(CFLAGS)
-CXX.target ?= $(CXX)
+CXX.target ?= %(CXX.target)s
CXXFLAGS.target ?= $(CXXFLAGS)
-LINK.target ?= $(LINK)
+LINK.target ?= %(LINK.target)s
LDFLAGS.target ?= $(LDFLAGS)
AR.target ?= $(AR)
ARFLAGS.target ?= %(ARFLAGS.target)s
@@ -268,13 +267,13 @@ ARFLAGS.target ?= %(ARFLAGS.target)s
# in gyp's make.py where ARFLAGS.host etc. is computed.
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
# to replicate this environment fallback in make as well.
-CC.host ?= gcc
+CC.host ?= %(CC.host)s
CFLAGS.host ?=
-CXX.host ?= g++
+CXX.host ?= %(CXX.host)s
CXXFLAGS.host ?=
-LINK.host ?= g++
+LINK.host ?= %(LINK.host)s
LDFLAGS.host ?=
-AR.host ?= ar
+AR.host ?= %(AR.host)s
ARFLAGS.host := %(ARFLAGS.host)s
# Define a dir function that can handle spaces.
@@ -1892,8 +1891,8 @@ def RunSystemTests(flavor):
# Compute flags used for building static archives.
# N.B.: this fallback logic should match the logic in SHARED_HEADER.
# See comment there for more details.
- ar_target = os.environ.get('AR.target', os.environ.get('AR', 'ar'))
- cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc'))
+ ar_target = GetEnv(('AR_target', 'AR'), 'ar')
+ cc_target = GetEnv(('CC_target', 'CC'), 'cc')
arflags_target = 'crs'
# ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it
# does something useless (it limits filenames in the archive to 15 chars).
@@ -1901,12 +1900,12 @@ def RunSystemTests(flavor):
cc_command=cc_target):
arflags_target = 'crsT'
- ar_host = os.environ.get('AR.host', 'ar')
- cc_host = os.environ.get('CC.host', 'gcc')
+ ar_host = os.environ.get('AR_host', 'ar')
+ cc_host = os.environ.get('CC_host', 'gcc')
arflags_host = 'crs'
# It feels redundant to compute this again given that most builds aren't
- # cross-compiles, but due to quirks of history CC.host defaults to 'gcc'
- # while CC.target defaults to 'cc', so the commands really are different
+ # cross-compiles, but due to quirks of history CC_host defaults to 'gcc'
+ # while CC_target defaults to 'cc', so the commands really are different
# even though they're nearly guaranteed to run the same code underneath.
if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host,
cc_command=cc_host):
@@ -1916,6 +1915,15 @@ def RunSystemTests(flavor):
'ARFLAGS.host': arflags_host }
+def GetEnv(possible_keys, default):
+ """Look up a key in the environment, falling back to a secondary key
+ and finally falling back to a default value."""
+ for key in possible_keys:
+ if key in os.environ:
+ return os.environ[key]
+
+ return default
+
def GenerateOutput(target_list, target_dicts, data, params):
options = params['options']
flavor = gyp.common.GetFlavor(params)
@@ -1995,7 +2003,18 @@ def GenerateOutput(target_list, target_dicts, data, params):
header_params.update({
'flock': 'lockf',
})
+
header_params.update(RunSystemTests(flavor))
+ header_params.update({
+ 'CC.target': GetEnv(('CC_target', 'CC'), '$(CC)'),
+ 'AR.target': GetEnv(('AR_target', 'AR'), '$(AR)'),
+ 'CXX.target': GetEnv(('CXX_target', 'CXX'), '$(CXX)'),
+ 'LINK.target': GetEnv(('LD_target', 'LD'), '$(LINK)'),
Nico 2012/08/08 21:26:08 If I understood michaelbai right, the _target stuf
Sam Clegg 2012/08/10 00:43:58 I will remove this.
+ 'CC.host': GetEnv(('CC_host',), 'gcc'),
+ 'AR.host': GetEnv(('AR_host',), 'ar'),
+ 'CXX.host': GetEnv(('CXX_host',), 'g++'),
+ 'LINK.host': GetEnv(('LD_host',), 'g++'),
Nico 2012/08/08 21:26:08 This part is fine, but it's overridden by make_glo
+ })
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
make_global_settings_dict = data[build_file].get('make_global_settings', {})
« no previous file with comments | « no previous file | pylib/gyp/generator/ninja.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698