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

Side by Side Diff: build/gyp_chromium

Issue 185623004: Refactor gyp_chromium to ease reuse. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Another rebase Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 340
341 def GetDesiredVsToolchainHashes(): 341 def GetDesiredVsToolchainHashes():
342 """Load a list of SHA1s corresponding to the toolchains that we want installed 342 """Load a list of SHA1s corresponding to the toolchains that we want installed
343 to build with.""" 343 to build with."""
344 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash') 344 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash')
345 with open(sha1path, 'rb') as f: 345 with open(sha1path, 'rb') as f:
346 return f.read().strip().splitlines() 346 return f.read().strip().splitlines()
347 347
348 348
349 def DownloadVsToolChain():
350 """Download the Visual Studio toolchain on Windows.
351
352 If on Windows, request that depot_tools install/update the automatic
353 toolchain, and then use it (unless opted-out) and return a tuple containing
354 the x64 and x86 paths. Otherwise return None.
355 """
356 vs2013_runtime_dll_dirs = None
357 depot_tools_win_toolchain = \
358 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
359 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
360 import find_depot_tools
361 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
362 temp_handle, data_file = tempfile.mkstemp(suffix='.json')
363 os.close(temp_handle)
364 get_toolchain_args = [
365 sys.executable,
366 os.path.join(depot_tools_path,
367 'win_toolchain',
368 'get_toolchain_if_necessary.py'),
369 '--output-json', data_file,
370 ] + GetDesiredVsToolchainHashes()
371 subprocess.check_call(get_toolchain_args)
372
373 with open(data_file, 'r') as tempf:
374 toolchain_data = json.load(tempf)
375 os.unlink(data_file)
376
377 toolchain = toolchain_data['path']
378 version = toolchain_data['version']
379 version_is_pro = version[-1] != 'e'
380 win8sdk = toolchain_data['win8sdk']
381 wdk = toolchain_data['wdk']
382 # TODO(scottmg): The order unfortunately matters in these. They should be
383 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
384 # below). http://crbug.com/345992
385 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
386
387 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
388 os.environ['GYP_MSVS_VERSION'] = version
389 # We need to make sure windows_sdk_path is set to the automated
390 # toolchain values in GYP_DEFINES, but don't want to override any
391 # otheroptions.express
392 # values there.
393 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
394 gyp_defines_dict['windows_sdk_path'] = win8sdk
395 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
396 for k, v in gyp_defines_dict.iteritems())
397 os.environ['WINDOWSSDKDIR'] = win8sdk
398 os.environ['WDK_DIR'] = wdk
399 # Include the VS runtime in the PATH in case it's not machine-installed.
400 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
401 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
402 print('Using automatic toolchain in %s (%s edition).' % (
403 toolchain, 'Pro' if version_is_pro else 'Express'))
404 return vs2013_runtime_dll_dirs
405
406
349 def CopyVsRuntimeDlls(output_dir, runtime_dirs): 407 def CopyVsRuntimeDlls(output_dir, runtime_dirs):
350 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output 408 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
351 directory so that even if not system-installed, built binaries are likely to 409 directory so that even if not system-installed, built binaries are likely to
352 be able to run. 410 be able to run.
353 411
354 This needs to be run after gyp has been run so that the expected target 412 This needs to be run after gyp has been run so that the expected target
355 output directories are already created. 413 output directories are already created.
356 """ 414 """
357 assert sys.platform.startswith(('win32', 'cygwin')) 415 assert sys.platform.startswith(('win32', 'cygwin'))
358 416
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 # . set the env var only if it hasn't been set yet 519 # . set the env var only if it hasn't been set yet
462 # . chromium.gyp_env has been applied to os.environ at this point already 520 # . chromium.gyp_env has been applied to os.environ at this point already
463 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): 521 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'):
464 os.environ['GYP_GENERATORS'] = 'ninja' 522 os.environ['GYP_GENERATORS'] = 'ninja'
465 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'): 523 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'):
466 os.environ['GYP_GENERATORS'] = 'ninja' 524 os.environ['GYP_GENERATORS'] = 'ninja'
467 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ 525 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \
468 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): 526 not 'OS=ios' in os.environ.get('GYP_DEFINES', []):
469 os.environ['GYP_GENERATORS'] = 'ninja' 527 os.environ['GYP_GENERATORS'] = 'ninja'
470 528
471 # If on Windows, request that depot_tools install/update the automatic 529 vs2013_runtime_dll_dirs = DownloadVsToolChain()
472 # toolchain, and then use it (unless opted-out).
473 vs2013_runtime_dll_dirs = None
474 depot_tools_win_toolchain = \
475 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
476 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
477 import find_depot_tools
478 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
479 temp_handle, data_file = tempfile.mkstemp(suffix='.json')
480 os.close(temp_handle)
481 get_toolchain_args = [
482 sys.executable,
483 os.path.join(depot_tools_path,
484 'win_toolchain',
485 'get_toolchain_if_necessary.py'),
486 '--output-json', data_file,
487 ] + GetDesiredVsToolchainHashes()
488 subprocess.check_call(get_toolchain_args)
489
490 with open(data_file, 'r') as tempf:
491 toolchain_data = json.load(tempf)
492 os.unlink(data_file)
493
494 toolchain = toolchain_data['path']
495 version = toolchain_data['version']
496 version_is_pro = version[-1] != 'e'
497 win8sdk = toolchain_data['win8sdk']
498 wdk = toolchain_data['wdk']
499 # TODO(scottmg): The order unfortunately matters in these. They should be
500 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
501 # below). http://crbug.com/345992
502 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
503
504 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
505 os.environ['GYP_MSVS_VERSION'] = version
506 # We need to make sure windows_sdk_path is set to the automated
507 # toolchain values in GYP_DEFINES, but don't want to override any
508 # otheroptions.express
509 # values there.
510 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
511 gyp_defines_dict['windows_sdk_path'] = win8sdk
512 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
513 for k, v in gyp_defines_dict.iteritems())
514 os.environ['WINDOWSSDKDIR'] = win8sdk
515 os.environ['WDK_DIR'] = wdk
516 # Include the VS runtime in the PATH in case it's not machine-installed.
517 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
518 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
519 print('Using automatic toolchain in %s (%s edition).' % (
520 toolchain, 'Pro' if version_is_pro else 'Express'))
521 530
522 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check 531 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
523 # to enfore syntax checking. 532 # to enfore syntax checking.
524 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') 533 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
525 if syntax_check and int(syntax_check): 534 if syntax_check and int(syntax_check):
526 args.append('--check') 535 args.append('--check')
527 536
528 supplemental_includes = GetSupplementalFiles() 537 supplemental_includes = GetSupplementalFiles()
529 gn_vars_dict = GetGypVarsForGN(supplemental_includes) 538 gn_vars_dict = GetGypVarsForGN(supplemental_includes)
530 539
(...skipping 24 matching lines...) Expand all
555 print 'Running build/landmines.py...' 564 print 'Running build/landmines.py...'
556 subprocess.check_call( 565 subprocess.check_call(
557 [sys.executable, os.path.join(script_dir, 'landmines.py')]) 566 [sys.executable, os.path.join(script_dir, 'landmines.py')])
558 567
559 if vs2013_runtime_dll_dirs: 568 if vs2013_runtime_dll_dirs:
560 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 569 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
561 CopyVsRuntimeDlls(os.path.join(chrome_src, GetOutputDirectory()), 570 CopyVsRuntimeDlls(os.path.join(chrome_src, GetOutputDirectory()),
562 (x86_runtime, x64_runtime)) 571 (x86_runtime, x64_runtime))
563 572
564 sys.exit(gyp_rc) 573 sys.exit(gyp_rc)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698