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

Side by Side Diff: build/gyp_chromium

Issue 175053009: Merge 252733 "Move control of updating toolchain into src/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1849/src/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/toolchain_vs2013.hash » ('j') | 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
11 import gyp_helper 11 import gyp_helper
12 import json
12 import os 13 import os
13 import pipes 14 import pipes
14 import shlex 15 import shlex
15 import shutil 16 import shutil
16 import subprocess 17 import subprocess
17 import string 18 import string
18 import sys 19 import sys
20 import tempfile
19 21
20 script_dir = os.path.dirname(os.path.realpath(__file__)) 22 script_dir = os.path.dirname(os.path.realpath(__file__))
21 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) 23 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
22 24
23 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) 25 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
24 import gyp 26 import gyp
25 27
26 # Assume this file is in a one-level-deep subdirectory of the source root. 28 # Assume this file is in a one-level-deep subdirectory of the source root.
27 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 29 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
28 30
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 # Need to pass both the source root (the bots don't run this command from 327 # Need to pass both the source root (the bots don't run this command from
326 # within the source tree) as well as set the is_gyp value so the BUILD files 328 # within the source tree) as well as set the is_gyp value so the BUILD files
327 # to know they're being run under GYP. 329 # to know they're being run under GYP.
328 args = [gnpath, 'gyp', '-q', 330 args = [gnpath, 'gyp', '-q',
329 '--root=' + chrome_src, 331 '--root=' + chrome_src,
330 '--args=' + GetArgsStringForGN(supplemental_includes), 332 '--args=' + GetArgsStringForGN(supplemental_includes),
331 '--output=//' + GetOutputDirectory() + '/gn_build/'] 333 '--output=//' + GetOutputDirectory() + '/gn_build/']
332 return subprocess.call(args) == 0 334 return subprocess.call(args) == 0
333 335
334 336
337 def GetDesiredVsToolchainHashes():
338 """Load a list of SHA1s corresponding to the toolchains that we want installed
339 to build with."""
340 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash')
341 with open(sha1path, 'rb') as f:
342 return f.read().strip().splitlines()
343
344
335 def CopyVsRuntimeDlls(output_dir, runtime_dirs): 345 def CopyVsRuntimeDlls(output_dir, runtime_dirs):
336 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output 346 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
337 directory so that even if not system-installed, built binaries are likely to 347 directory so that even if not system-installed, built binaries are likely to
338 be able to run. 348 be able to run.
339 349
340 This needs to be run after gyp has been run so that the expected target 350 This needs to be run after gyp has been run so that the expected target
341 output directories are already created. 351 output directories are already created.
342 """ 352 """
343 assert sys.platform.startswith(('win32', 'cygwin')) 353 assert sys.platform.startswith(('win32', 'cygwin'))
344 354
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 # . set the env var only if it hasn't been set yet 442 # . set the env var only if it hasn't been set yet
433 # . chromium.gyp_env has been applied to os.environ at this point already 443 # . chromium.gyp_env has been applied to os.environ at this point already
434 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): 444 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'):
435 os.environ['GYP_GENERATORS'] = 'ninja' 445 os.environ['GYP_GENERATORS'] = 'ninja'
436 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'): 446 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'):
437 os.environ['GYP_GENERATORS'] = 'ninja' 447 os.environ['GYP_GENERATORS'] = 'ninja'
438 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ 448 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \
439 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): 449 not 'OS=ios' in os.environ.get('GYP_DEFINES', []):
440 os.environ['GYP_GENERATORS'] = 'ninja' 450 os.environ['GYP_GENERATORS'] = 'ninja'
441 451
442 # If on windows, and the automatic toolchain has been installed by 452 # If on Windows, request that depot_tools install/update the automatic
443 # depot_tools, then use it. 453 # toolchain, and then use it (unless opted-out).
444 vs2013_runtime_dll_dirs = None 454 vs2013_runtime_dll_dirs = None
445 if sys.platform in ('win32', 'cygwin'): 455 depot_tools_win_toolchain = \
456 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
457 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
458 import find_depot_tools
446 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 459 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
447 toolchain = os.path.normpath(os.path.join( 460 temp_handle, data_file = tempfile.mkstemp(suffix='.json')
448 depot_tools_path, 'win_toolchain', 'vs2013_files')) 461 os.close(temp_handle)
449 version_file = os.path.join(toolchain, '.version') 462 get_toolchain_args = [
450 if os.path.isdir(toolchain) and os.path.isfile(version_file): 463 sys.executable,
451 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain 464 os.path.join(depot_tools_path,
452 with open(version_file, 'r') as f: 465 'win_toolchain',
453 version_is_pro = f.read().strip() == 'pro' 466 'get_toolchain_if_necessary.py'),
454 vs2013_runtime_dll_dirs = (os.path.join(toolchain, 'sys32'), 467 '--output-json', data_file,
455 os.path.join(toolchain, 'sys64')) 468 ] + GetDesiredVsToolchainHashes()
456 os.environ['GYP_MSVS_VERSION'] = '2013' if version_is_pro else '2013e' 469 subprocess.check_call(get_toolchain_args)
457 # We need to make sure windows_sdk_path is set to the automated 470
458 # toolchain values in GYP_DEFINES, but don't want to override any other 471 with open(data_file, 'r') as tempf:
459 # values there. 472 toolchain_data = json.load(tempf)
460 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) 473 os.unlink(data_file)
461 win8sdk = os.path.join(toolchain, 'win8sdk') 474
462 wdk = os.path.join(toolchain, 'wdk') 475 toolchain = toolchain_data['path']
463 gyp_defines_dict['windows_sdk_path'] = win8sdk 476 version = toolchain_data['version']
464 os.environ['WINDOWSSDKDIR'] = win8sdk 477 version_is_pro = version[-1] != 'e'
465 os.environ['WDK_DIR'] = wdk 478 win8sdk = toolchain_data['win8sdk']
466 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) 479 wdk = toolchain_data['wdk']
467 for k, v in gyp_defines_dict.iteritems()) 480 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
468 # Include the VS runtime in the PATH in case it's not machine-installed. 481
469 runtime_path = ';'.join(os.path.normpath(os.path.join(toolchain, s)) 482 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
470 for s in ('sys64', 'sys32')) 483 os.environ['GYP_MSVS_VERSION'] = version
471 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] 484 # We need to make sure windows_sdk_path is set to the automated
472 print('Using automatic toolchain in %s (%s edition).' % ( 485 # toolchain values in GYP_DEFINES, but don't want to override any
473 toolchain, 'Pro' if version_is_pro else 'Express')) 486 # otheroptions.express
487 # values there.
488 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
489 gyp_defines_dict['windows_sdk_path'] = win8sdk
490 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
491 for k, v in gyp_defines_dict.iteritems())
492 os.environ['WINDOWSSDKDIR'] = win8sdk
493 os.environ['WDK_DIR'] = wdk
494 # Include the VS runtime in the PATH in case it's not machine-installed.
495 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
496 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
497 print('Using automatic toolchain in %s (%s edition).' % (
498 toolchain, 'Pro' if version_is_pro else 'Express'))
474 499
475 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check 500 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
476 # to enfore syntax checking. 501 # to enfore syntax checking.
477 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') 502 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
478 if syntax_check and int(syntax_check): 503 if syntax_check and int(syntax_check):
479 args.append('--check') 504 args.append('--check')
480 505
481 supplemental_includes = GetSupplementalFiles() 506 supplemental_includes = GetSupplementalFiles()
482 if not RunGN(supplemental_includes): 507 if not RunGN(supplemental_includes):
483 sys.exit(1) 508 sys.exit(1)
(...skipping 12 matching lines...) Expand all
496 # rather than a separate runhooks step so that any environment modifications 521 # rather than a separate runhooks step so that any environment modifications
497 # from above are picked up. 522 # from above are picked up.
498 print 'Running build/landmines.py...' 523 print 'Running build/landmines.py...'
499 subprocess.check_call( 524 subprocess.check_call(
500 [sys.executable, os.path.join(script_dir, 'landmines.py')]) 525 [sys.executable, os.path.join(script_dir, 'landmines.py')])
501 526
502 if vs2013_runtime_dll_dirs: 527 if vs2013_runtime_dll_dirs:
503 CopyVsRuntimeDlls(GetOutputDirectory(), vs2013_runtime_dll_dirs) 528 CopyVsRuntimeDlls(GetOutputDirectory(), vs2013_runtime_dll_dirs)
504 529
505 sys.exit(gyp_rc) 530 sys.exit(gyp_rc)
OLDNEW
« no previous file with comments | « no previous file | build/toolchain_vs2013.hash » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698