Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
|
Mark Mentovai
2010/11/08 19:58:21
CL description:
| |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This script is wrapper for Chromium that adds some support for how GYP | 7 # This script is wrapper for Chromium that adds some support for how GYP |
| 8 # is invoked by Chromium beyond what can be done in the gclient hooks. | 8 # is invoked by Chromium beyond what can be done in the gclient hooks. |
| 9 | 9 |
| 10 import glob | 10 import glob |
| 11 import os | 11 import os |
| 12 import shlex | 12 import shlex |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 script_dir = os.path.dirname(__file__) | 15 script_dir = os.path.dirname(__file__) |
| 16 chrome_src = os.path.normpath(os.path.join(script_dir, os.pardir)) | 16 chrome_src = os.path.normpath(os.path.join(script_dir, os.pardir)) |
| 17 | 17 |
| 18 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 18 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
| 19 import gyp | 19 import gyp |
| 20 | 20 |
| 21 def apply_gyp_environment(file_path=None): | |
| 22 """ | |
| 23 Reads in a *.gyp_env and applies the valid keys to os.environ. | |
|
Mark Mentovai
2010/11/08 19:58:21
*.gyp_env file.
| |
| 24 """ | |
| 25 if not file_path or not os.path.exists(file_path): | |
| 26 return | |
| 27 file_contents = open(file_path).read() | |
| 28 try: | |
| 29 file_data = eval(file_contents, {'__builtins__': None}, None) | |
| 30 except SyntaxError, e: | |
| 31 e.filename = os.path.abspath(file_path) | |
| 32 raise | |
| 33 supported_vars = ( 'CHROMIUM_GYP_FILE', | |
| 34 'CHROMIUM_GYP_SYNTAX_CHECK', | |
| 35 'GYP_DEFINES', | |
| 36 'GYP_GENERATOR_FLAGS', | |
| 37 'GYP_GENERATOR_OUTPUT', ) | |
| 38 for var in supported_vars: | |
| 39 val = file_data.get(var) | |
| 40 if val: | |
| 41 existing_value = os.environ.get(var) | |
| 42 if existing_value: | |
|
Mark Mentovai
2010/11/08 19:58:21
I would prefer not overwriting existing values at
| |
| 43 val = existing_value + ' ' + val | |
| 44 os.environ[var] = val | |
| 45 | |
| 21 def additional_include_files(args=[]): | 46 def additional_include_files(args=[]): |
| 22 """ | 47 """ |
| 23 Returns a list of additional (.gypi) files to include, without | 48 Returns a list of additional (.gypi) files to include, without |
| 24 duplicating ones that are already specified on the command line. | 49 duplicating ones that are already specified on the command line. |
| 25 """ | 50 """ |
| 26 # Determine the include files specified on the command line. | 51 # Determine the include files specified on the command line. |
| 27 # This doesn't cover all the different option formats you can use, | 52 # This doesn't cover all the different option formats you can use, |
| 28 # but it's mainly intended to avoid duplicating flags on the automatic | 53 # but it's mainly intended to avoid duplicating flags on the automatic |
| 29 # makefile regeneration which only uses this format. | 54 # makefile regeneration which only uses this format. |
| 30 specified_includes = set() | 55 specified_includes = set() |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 44 # Optionally add supplemental .gypi files if present. | 69 # Optionally add supplemental .gypi files if present. |
| 45 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) | 70 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) |
| 46 for supplement in supplements: | 71 for supplement in supplements: |
| 47 AddInclude(supplement) | 72 AddInclude(supplement) |
| 48 | 73 |
| 49 return result | 74 return result |
| 50 | 75 |
| 51 if __name__ == '__main__': | 76 if __name__ == '__main__': |
| 52 args = sys.argv[1:] | 77 args = sys.argv[1:] |
| 53 | 78 |
| 79 if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ: | |
| 80 # Update the environment based on .gyp_env | |
|
Mark Mentovai
2010/11/08 19:58:21
chromium.gyp_env.
| |
| 81 gyp_env_path = os.path.join(os.path.dirname(chrome_src), 'chromium.gyp_env') | |
| 82 apply_gyp_environment(gyp_env_path) | |
| 83 | |
| 54 # This could give false positives since it doesn't actually do real option | 84 # This could give false positives since it doesn't actually do real option |
| 55 # parsing. Oh well. | 85 # parsing. Oh well. |
| 56 gyp_file_specified = False | 86 gyp_file_specified = False |
| 57 for arg in args: | 87 for arg in args: |
| 58 if arg.endswith('.gyp'): | 88 if arg.endswith('.gyp'): |
| 59 gyp_file_specified = True | 89 gyp_file_specified = True |
| 60 break | 90 break |
| 61 | 91 |
| 62 # If we didn't get a file, check an env var, and then fall back to | 92 # If we didn't get a file, check an env var, and then fall back to |
| 63 # assuming 'all.gyp' from the same directory as the script. | 93 # assuming 'all.gyp' from the same directory as the script. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 88 # to enfore syntax checking. | 118 # to enfore syntax checking. |
| 89 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 119 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
| 90 if syntax_check and int(syntax_check): | 120 if syntax_check and int(syntax_check): |
| 91 args.append('--check') | 121 args.append('--check') |
| 92 | 122 |
| 93 print 'Updating projects from gyp files...' | 123 print 'Updating projects from gyp files...' |
| 94 sys.stdout.flush() | 124 sys.stdout.flush() |
| 95 | 125 |
| 96 # Off we go... | 126 # Off we go... |
| 97 sys.exit(gyp.main(args)) | 127 sys.exit(gyp.main(args)) |
| OLD | NEW |