Index: build/gyp_chromium |
diff --git a/build/gyp_chromium b/build/gyp_chromium |
index 5bf5386081d197618313330df3ffa7018a7a3047..964639f5c0ff69708fba8c1641814863d5b86bcd 100755 |
--- a/build/gyp_chromium |
+++ b/build/gyp_chromium |
@@ -54,10 +54,47 @@ else: |
psyco = None |
-def additional_include_files(args=[]): |
+def GetSupplementalFiles(): |
+ """Returns a list of the supplemental files that are included in all GYP |
bradn
2013/11/19 17:45:58
FWIW These are usually meant to fix on one line.
|
+ sources.""" |
+ return glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) |
+ |
+ |
+def GetVarsStringForGN(supplemental_files): |
+ vars_dict = {} |
+ |
+ for supplement in supplemental_files: |
+ with open(supplement, 'r') as f: |
+ try: |
+ file_data = eval(f.read(), {'__builtins__': None}, None) |
+ except SyntaxError, e: |
+ e.filename = os.path.abspath(supplement) |
+ raise |
+ variables = file_data.get('variables') |
+ for v in variables: |
+ vars_dict[v] = '"' + variables[v] + '"' |
+ |
+ env_string = os.environ.get('GYP_DEFINES', []) |
+ items = shlex.split(env_string) |
+ for item in items: |
+ tokens = item.split('=', 1) |
+ if len(tokens) == 2: |
+ vars_dict[tokens[0]] = '"' + tokens[1] + '"' |
+ else: |
+ # No value supplied, treat it as a boolean and set it. |
+ vars_dict[tokens[0]] = 'true' |
+ |
+ vars_string = '' |
+ for v in vars_dict: |
+ vars_string = vars_string + v + '=' + vars_dict[v] + ' ' |
+ return vars_string.strip() # Remove trailing space. |
+ |
+ |
+def additional_include_files(supplemental_files, args=[]): |
""" |
- Returns a list of additional (.gypi) files to include, without |
- duplicating ones that are already specified on the command line. |
+ Returns a list of additional (.gypi) files to include, without duplicating |
+ ones that are already specified on the command line. The list of supplemental |
+ include files is passed in as an argument. |
""" |
# Determine the include files specified on the command line. |
# This doesn't cover all the different option formats you can use, |
@@ -77,16 +114,16 @@ def additional_include_files(args=[]): |
AddInclude(os.path.join(script_dir, 'common.gypi')) |
# Optionally add supplemental .gypi files if present. |
- supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) |
- for supplement in supplements: |
+ for supplement in supplemental_files: |
AddInclude(supplement) |
return result |
-def RunGN(): |
+def RunGN(supplemental_includes): |
"""Runs GN, returning True if it succeeded, printing an error and returning |
false if not.""" |
+ |
# The binaries in platform-specific subdirectories in src/tools/gn/bin. |
gnpath = SRC_DIR + '/tools/gn/bin/' |
if sys.platform == 'win32': |
@@ -100,13 +137,15 @@ def RunGN(): |
return False |
print 'Generating gyp files from GN...' |
- print 'platform = ', sys.platform |
- print 'binary = ', gnpath |
+ gyp_vars = GetVarsStringForGN(supplemental_includes) |
# Need to pass both the source root (the bots don't run this command from |
# within the source tree) as well as set the is_gyp value so the BUILD files |
# to know they're being run under GYP. |
- args = [gnpath, 'gyp', '-q', '--root=' + chrome_src, '--args=is_gyp=true'] |
+ args = [gnpath, 'gyp', '-q', |
+ '--root=' + chrome_src, |
+ '--args=is_gyp=true', |
+ '--gyp_vars=' + gyp_vars + ''] |
return subprocess.call(args) == 0 |
@@ -118,9 +157,6 @@ if __name__ == '__main__': |
psyco.profile() |
print "Enabled Psyco JIT." |
- if not RunGN(): |
- sys.exit(1) |
- |
# Fall back on hermetic python if we happen to get run under cygwin. |
# TODO(bradnelson): take this out once this issue is fixed: |
# http://code.google.com/p/gyp/issues/detail?id=177 |
@@ -155,7 +191,13 @@ if __name__ == '__main__': |
else: |
args.append(os.path.join(script_dir, 'all.gyp')) |
- args.extend(['-I' + i for i in additional_include_files(args)]) |
+ supplemental_includes = GetSupplementalFiles() |
+ |
+ if not RunGN(supplemental_includes): |
+ sys.exit(1) |
+ |
+ args.extend( |
+ ['-I' + i for i in additional_include_files(supplemental_includes, args)]) |
# There shouldn't be a circular dependency relationship between .gyp files, |
# but in Chromium's .gyp files, on non-Mac platforms, circular relationships |