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 | 11 import gyp_environment |
12 import os | 12 import os |
13 import re | 13 import re |
14 import shlex | 14 import shlex |
15 import subprocess | 15 import subprocess |
16 import string | 16 import string |
17 import sys | 17 import sys |
18 import vs_toolchain | 18 import vs_toolchain |
19 | 19 |
20 script_dir = os.path.dirname(os.path.realpath(__file__)) | 20 script_dir = os.path.dirname(os.path.realpath(__file__)) |
21 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 21 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 args = sys.argv[1:] | 190 args = sys.argv[1:] |
191 | 191 |
192 use_analyzer = len(args) and args[0] == '--analyzer' | 192 use_analyzer = len(args) and args[0] == '--analyzer' |
193 if use_analyzer: | 193 if use_analyzer: |
194 args.pop(0) | 194 args.pop(0) |
195 os.environ['GYP_GENERATORS'] = 'analyzer' | 195 os.environ['GYP_GENERATORS'] = 'analyzer' |
196 args.append('-Gconfig_path=' + args.pop(0)) | 196 args.append('-Gconfig_path=' + args.pop(0)) |
197 args.append('-Ganalyzer_output_path=' + args.pop(0)) | 197 args.append('-Ganalyzer_output_path=' + args.pop(0)) |
198 | 198 |
199 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): | 199 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): |
200 # Check for landmines (reasons to clobber the build) in any case. | |
201 print 'Running build/landmines.py...' | |
202 subprocess.check_call( | |
203 [sys.executable, os.path.join(script_dir, 'landmines.py')]) | |
204 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' | 200 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' |
205 sys.exit(0) | 201 sys.exit(0) |
206 | 202 |
207 # Use the Psyco JIT if available. | 203 # Use the Psyco JIT if available. |
208 if psyco: | 204 if psyco: |
209 psyco.profile() | 205 psyco.profile() |
210 print "Enabled Psyco JIT." | 206 print "Enabled Psyco JIT." |
211 | 207 |
212 # Fall back on hermetic python if we happen to get run under cygwin. | 208 # Fall back on hermetic python if we happen to get run under cygwin. |
213 # TODO(bradnelson): take this out once this issue is fixed: | 209 # TODO(bradnelson): take this out once this issue is fixed: |
214 # http://code.google.com/p/gyp/issues/detail?id=177 | 210 # http://code.google.com/p/gyp/issues/detail?id=177 |
215 if sys.platform == 'cygwin': | 211 if sys.platform == 'cygwin': |
216 import find_depot_tools | 212 import find_depot_tools |
217 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 213 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
218 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, | 214 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, |
219 'python2*_bin')))[-1] | 215 'python2*_bin')))[-1] |
220 env = os.environ.copy() | 216 env = os.environ.copy() |
221 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') | 217 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') |
222 p = subprocess.Popen( | 218 p = subprocess.Popen( |
223 [os.path.join(python_dir, 'python.exe')] + sys.argv, | 219 [os.path.join(python_dir, 'python.exe')] + sys.argv, |
224 env=env, shell=False) | 220 env=env, shell=False) |
225 p.communicate() | 221 p.communicate() |
226 sys.exit(p.returncode) | 222 sys.exit(p.returncode) |
227 | 223 |
228 gyp_helper.apply_chromium_gyp_env() | |
229 | |
230 # This could give false positives since it doesn't actually do real option | 224 # This could give false positives since it doesn't actually do real option |
231 # parsing. Oh well. | 225 # parsing. Oh well. |
232 gyp_file_specified = False | 226 gyp_file_specified = False |
233 for arg in args: | 227 for arg in args: |
234 if arg.endswith('.gyp'): | 228 if arg.endswith('.gyp'): |
235 gyp_file_specified = True | 229 gyp_file_specified = True |
236 break | 230 break |
237 | 231 |
| 232 gyp_environment.SetEnvironment() |
| 233 |
238 # If we didn't get a file, check an env var, and then fall back to | 234 # If we didn't get a file, check an env var, and then fall back to |
239 # assuming 'all.gyp' from the same directory as the script. | 235 # assuming 'all.gyp' from the same directory as the script. |
240 if not gyp_file_specified: | 236 if not gyp_file_specified: |
241 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') | 237 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') |
242 if gyp_file: | 238 if gyp_file: |
243 # Note that CHROMIUM_GYP_FILE values can't have backslashes as | 239 # Note that CHROMIUM_GYP_FILE values can't have backslashes as |
244 # path separators even on Windows due to the use of shlex.split(). | 240 # path separators even on Windows due to the use of shlex.split(). |
245 args.extend(shlex.split(gyp_file)) | 241 args.extend(shlex.split(gyp_file)) |
246 else: | 242 else: |
247 args.append(os.path.join(script_dir, 'all.gyp')) | 243 args.append(os.path.join(script_dir, 'all.gyp')) |
248 | 244 |
249 # There shouldn't be a circular dependency relationship between .gyp files, | 245 # There shouldn't be a circular dependency relationship between .gyp files, |
250 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships | 246 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships |
251 # currently exist. The check for circular dependencies is currently | 247 # currently exist. The check for circular dependencies is currently |
252 # bypassed on other platforms, but is left enabled on the Mac, where a | 248 # bypassed on other platforms, but is left enabled on the Mac, where a |
253 # violation of the rule causes Xcode to misbehave badly. | 249 # violation of the rule causes Xcode to misbehave badly. |
254 # TODO(mark): Find and kill remaining circular dependencies, and remove this | 250 # TODO(mark): Find and kill remaining circular dependencies, and remove this |
255 # option. http://crbug.com/35878. | 251 # option. http://crbug.com/35878. |
256 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the | 252 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the |
257 # list. | 253 # list. |
258 if sys.platform not in ('darwin',): | 254 if sys.platform not in ('darwin',): |
259 args.append('--no-circular-check') | 255 args.append('--no-circular-check') |
260 | 256 |
261 # We explicitly don't support the make gyp generator (crbug.com/348686). Be | 257 # We explicitly don't support the make gyp generator (crbug.com/348686). Be |
262 # nice and fail here, rather than choking in gyp. | 258 # nice and fail here, rather than choking in gyp. |
263 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): | 259 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): |
264 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' | 260 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' |
265 sys.exit(1) | 261 sys.exit(1) |
266 | 262 |
267 # Default to ninja on linux and windows, but only if no generator has | |
268 # explicitly been set. | |
269 # Also default to ninja on mac, but only when not building chrome/ios. | |
270 # . -f / --format has precedence over the env var, no need to check for it | |
271 # . set the env var only if it hasn't been set yet | |
272 # . chromium.gyp_env has been applied to os.environ at this point already | |
273 if sys.platform.startswith(('linux', 'win', 'freebsd')) and \ | |
274 not os.environ.get('GYP_GENERATORS'): | |
275 os.environ['GYP_GENERATORS'] = 'ninja' | |
276 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ | |
277 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): | |
278 os.environ['GYP_GENERATORS'] = 'ninja' | |
279 | |
280 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | |
281 | |
282 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check | 263 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check |
283 # to enfore syntax checking. | 264 # to enfore syntax checking. |
284 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 265 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
285 if syntax_check and int(syntax_check): | 266 if syntax_check and int(syntax_check): |
286 args.append('--check') | 267 args.append('--check') |
287 | 268 |
288 supplemental_includes = GetSupplementalFiles() | 269 supplemental_includes = GetSupplementalFiles() |
289 gyp_vars_dict = GetGypVars(supplemental_includes) | 270 gyp_vars_dict = GetGypVars(supplemental_includes) |
290 | 271 |
291 # TODO(dmikurube): Remove these checks and messages after a while. | 272 # TODO(dmikurube): Remove these checks and messages after a while. |
(...skipping 23 matching lines...) Expand all Loading... |
315 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) | 296 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) |
316 | 297 |
317 if not use_analyzer: | 298 if not use_analyzer: |
318 print 'Updating projects from gyp files...' | 299 print 'Updating projects from gyp files...' |
319 sys.stdout.flush() | 300 sys.stdout.flush() |
320 | 301 |
321 # Off we go... | 302 # Off we go... |
322 gyp_rc = gyp.main(args) | 303 gyp_rc = gyp.main(args) |
323 | 304 |
324 if not use_analyzer: | 305 if not use_analyzer: |
325 # Check for landmines (reasons to clobber the build). This must be run here, | 306 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
326 # rather than a separate runhooks step so that any environment modifications | |
327 # from above are picked up. | |
328 print 'Running build/landmines.py...' | |
329 subprocess.check_call( | |
330 [sys.executable, os.path.join(script_dir, 'landmines.py')]) | |
331 | |
332 if vs2013_runtime_dll_dirs: | 307 if vs2013_runtime_dll_dirs: |
333 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 308 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
334 vs_toolchain.CopyVsRuntimeDlls( | 309 vs_toolchain.CopyVsRuntimeDlls( |
335 os.path.join(chrome_src, GetOutputDirectory()), | 310 os.path.join(chrome_src, GetOutputDirectory()), |
336 (x86_runtime, x64_runtime)) | 311 (x86_runtime, x64_runtime)) |
337 | 312 |
338 sys.exit(gyp_rc) | 313 sys.exit(gyp_rc) |
OLD | NEW |