| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 gyp_helper | |
| 12 import os | 11 import os |
| 13 import shlex | 12 import shlex |
| 14 import subprocess | 13 import subprocess |
| 15 import sys | 14 import sys |
| 16 | 15 |
| 17 script_dir = os.path.dirname(os.path.realpath(__file__)) | 16 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 17 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 19 | 18 |
| 20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 19 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
| 21 import gyp | 20 import gyp |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 # may not be worth it). | 37 # may not be worth it). |
| 39 if sys.platform == 'win32': | 38 if sys.platform == 'win32': |
| 40 try: | 39 try: |
| 41 sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32')) | 40 sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32')) |
| 42 import psyco | 41 import psyco |
| 43 except: | 42 except: |
| 44 psyco = None | 43 psyco = None |
| 45 else: | 44 else: |
| 46 psyco = None | 45 psyco = None |
| 47 | 46 |
| 47 def apply_gyp_environment(file_path=None): |
| 48 """ |
| 49 Reads in a *.gyp_env file and applies the valid keys to os.environ. |
| 50 """ |
| 51 if not file_path or not os.path.exists(file_path): |
| 52 return |
| 53 file_contents = open(file_path).read() |
| 54 try: |
| 55 file_data = eval(file_contents, {'__builtins__': None}, None) |
| 56 except SyntaxError, e: |
| 57 e.filename = os.path.abspath(file_path) |
| 58 raise |
| 59 supported_vars = ( 'CC', |
| 60 'CHROMIUM_GYP_FILE', |
| 61 'CHROMIUM_GYP_SYNTAX_CHECK', |
| 62 'CXX', |
| 63 'GYP_DEFINES', |
| 64 'GYP_GENERATOR_FLAGS', |
| 65 'GYP_GENERATOR_OUTPUT', |
| 66 'GYP_GENERATORS', ) |
| 67 for var in supported_vars: |
| 68 val = file_data.get(var) |
| 69 if val: |
| 70 if var in os.environ: |
| 71 print 'INFO: Environment value for "%s" overrides value in %s.' % ( |
| 72 var, os.path.abspath(file_path) |
| 73 ) |
| 74 else: |
| 75 os.environ[var] = val |
| 76 |
| 48 def additional_include_files(args=[]): | 77 def additional_include_files(args=[]): |
| 49 """ | 78 """ |
| 50 Returns a list of additional (.gypi) files to include, without | 79 Returns a list of additional (.gypi) files to include, without |
| 51 duplicating ones that are already specified on the command line. | 80 duplicating ones that are already specified on the command line. |
| 52 """ | 81 """ |
| 53 # Determine the include files specified on the command line. | 82 # Determine the include files specified on the command line. |
| 54 # This doesn't cover all the different option formats you can use, | 83 # This doesn't cover all the different option formats you can use, |
| 55 # but it's mainly intended to avoid duplicating flags on the automatic | 84 # but it's mainly intended to avoid duplicating flags on the automatic |
| 56 # makefile regeneration which only uses this format. | 85 # makefile regeneration which only uses this format. |
| 57 specified_includes = set() | 86 specified_includes = set() |
| (...skipping 30 matching lines...) Expand all Loading... |
| 88 if sys.platform == 'cygwin': | 117 if sys.platform == 'cygwin': |
| 89 python_dir = os.path.join(chrome_src, 'third_party', 'python_26') | 118 python_dir = os.path.join(chrome_src, 'third_party', 'python_26') |
| 90 env = os.environ.copy() | 119 env = os.environ.copy() |
| 91 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') | 120 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') |
| 92 p = subprocess.Popen( | 121 p = subprocess.Popen( |
| 93 [os.path.join(python_dir, 'python.exe')] + sys.argv, | 122 [os.path.join(python_dir, 'python.exe')] + sys.argv, |
| 94 env=env, shell=False) | 123 env=env, shell=False) |
| 95 p.communicate() | 124 p.communicate() |
| 96 sys.exit(p.returncode) | 125 sys.exit(p.returncode) |
| 97 | 126 |
| 98 gyp_helper.apply_chromium_gyp_env() | 127 if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ: |
| 128 # Update the environment based on chromium.gyp_env |
| 129 gyp_env_path = os.path.join(os.path.dirname(chrome_src), 'chromium.gyp_env') |
| 130 apply_gyp_environment(gyp_env_path) |
| 99 | 131 |
| 100 # This could give false positives since it doesn't actually do real option | 132 # This could give false positives since it doesn't actually do real option |
| 101 # parsing. Oh well. | 133 # parsing. Oh well. |
| 102 gyp_file_specified = False | 134 gyp_file_specified = False |
| 103 for arg in args: | 135 for arg in args: |
| 104 if arg.endswith('.gyp'): | 136 if arg.endswith('.gyp'): |
| 105 gyp_file_specified = True | 137 gyp_file_specified = True |
| 106 break | 138 break |
| 107 | 139 |
| 108 # If we didn't get a file, check an env var, and then fall back to | 140 # If we didn't get a file, check an env var, and then fall back to |
| (...skipping 25 matching lines...) Expand all Loading... |
| 134 # to enfore syntax checking. | 166 # to enfore syntax checking. |
| 135 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 167 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
| 136 if syntax_check and int(syntax_check): | 168 if syntax_check and int(syntax_check): |
| 137 args.append('--check') | 169 args.append('--check') |
| 138 | 170 |
| 139 print 'Updating projects from gyp files...' | 171 print 'Updating projects from gyp files...' |
| 140 sys.stdout.flush() | 172 sys.stdout.flush() |
| 141 | 173 |
| 142 # Off we go... | 174 # Off we go... |
| 143 sys.exit(gyp.main(args)) | 175 sys.exit(gyp.main(args)) |
| OLD | NEW |