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

Side by Side Diff: build/gyp_chromium

Issue 175573004: Move control of updating toolchain into src/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mkstemp 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 # Need to pass both the source root (the bots don't run this command from 325 # Need to pass both the source root (the bots don't run this command from
324 # within the source tree) as well as set the is_gyp value so the BUILD files 326 # within the source tree) as well as set the is_gyp value so the BUILD files
325 # to know they're being run under GYP. 327 # to know they're being run under GYP.
326 args = [gnpath, 'gyp', '-q', 328 args = [gnpath, 'gyp', '-q',
327 '--root=' + chrome_src, 329 '--root=' + chrome_src,
328 '--args=' + GetArgsStringForGN(vars_dict), 330 '--args=' + GetArgsStringForGN(vars_dict),
329 '--output=//' + GetOutputDirectory() + '/gn_build/'] 331 '--output=//' + GetOutputDirectory() + '/gn_build/']
330 return subprocess.call(args) == 0 332 return subprocess.call(args) == 0
331 333
332 334
335 def GetDesiredVsToolchainHashes():
336 """Load a list of SHA1s corresponding to the toolchains that we want installed
337 to build with."""
338 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash')
339 with open(sha1path, 'rb') as f:
340 return f.read().strip().splitlines()
341
342
333 def CopyVsRuntimeDlls(output_dir, runtime_dirs): 343 def CopyVsRuntimeDlls(output_dir, runtime_dirs):
334 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output 344 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
335 directory so that even if not system-installed, built binaries are likely to 345 directory so that even if not system-installed, built binaries are likely to
336 be able to run. 346 be able to run.
337 347
338 This needs to be run after gyp has been run so that the expected target 348 This needs to be run after gyp has been run so that the expected target
339 output directories are already created. 349 output directories are already created.
340 """ 350 """
341 assert sys.platform.startswith(('win32', 'cygwin')) 351 assert sys.platform.startswith(('win32', 'cygwin'))
342 352
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 # . set the env var only if it hasn't been set yet 441 # . set the env var only if it hasn't been set yet
432 # . chromium.gyp_env has been applied to os.environ at this point already 442 # . chromium.gyp_env has been applied to os.environ at this point already
433 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): 443 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'):
434 os.environ['GYP_GENERATORS'] = 'ninja' 444 os.environ['GYP_GENERATORS'] = 'ninja'
435 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'): 445 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'):
436 os.environ['GYP_GENERATORS'] = 'ninja' 446 os.environ['GYP_GENERATORS'] = 'ninja'
437 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ 447 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \
438 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): 448 not 'OS=ios' in os.environ.get('GYP_DEFINES', []):
439 os.environ['GYP_GENERATORS'] = 'ninja' 449 os.environ['GYP_GENERATORS'] = 'ninja'
440 450
441 # If on windows, and the automatic toolchain has been installed by 451 # If on Windows, request that depot_tools install/update the automatic
442 # depot_tools, then use it. 452 # toolchain, and then use it (unless opted-out).
443 vs2013_runtime_dll_dirs = None 453 vs2013_runtime_dll_dirs = None
444 # If MSVS_VERSION is explicitly specified to be something other than 2013, 454 depot_tools_win_toolchain = \
445 # don't use the automatic toolchain, as it currently only supports VS2013. 455 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
446 msvs_version = os.environ.get('GYP_MSVS_VERSION', '2013') 456 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
447 if sys.platform in ('win32', 'cygwin') and msvs_version.startswith('2013'):
448 import find_depot_tools 457 import find_depot_tools
449 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 458 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
450 toolchain = os.path.normpath(os.path.join( 459 temp_handle, data_file = tempfile.mkstemp(suffix='.json')
451 depot_tools_path, 'win_toolchain', 'vs2013_files')) 460 os.close(temp_handle)
452 version_file = os.path.join(toolchain, '.version') 461 get_toolchain_args = [
453 if os.path.isdir(toolchain) and os.path.isfile(version_file): 462 sys.executable,
454 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain 463 os.path.join(depot_tools_path,
455 with open(version_file, 'r') as f: 464 'win_toolchain',
456 version_is_pro = f.read().strip() == 'pro' 465 'get_toolchain_if_necessary.py'),
457 vs2013_runtime_dll_dirs = (os.path.join(toolchain, 'sys32'), 466 '--output-json', data_file,
458 os.path.join(toolchain, 'sys64')) 467 ] + GetDesiredVsToolchainHashes()
459 os.environ['GYP_MSVS_VERSION'] = '2013' if version_is_pro else '2013e' 468 subprocess.check_call(get_toolchain_args)
460 # We need to make sure windows_sdk_path is set to the automated 469
461 # toolchain values in GYP_DEFINES, but don't want to override any other 470 with open(data_file, 'r') as tempf:
462 # values there. 471 toolchain_data = json.load(tempf)
463 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) 472 os.unlink(data_file)
464 win8sdk = os.path.join(toolchain, 'win8sdk') 473
465 wdk = os.path.join(toolchain, 'wdk') 474 toolchain = toolchain_data['path']
466 gyp_defines_dict['windows_sdk_path'] = win8sdk 475 version = toolchain_data['version']
467 os.environ['WINDOWSSDKDIR'] = win8sdk 476 version_is_pro = version[-1] != 'e'
468 os.environ['WDK_DIR'] = wdk 477 win8sdk = toolchain_data['win8sdk']
469 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) 478 wdk = toolchain_data['wdk']
470 for k, v in gyp_defines_dict.iteritems()) 479 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
471 # Include the VS runtime in the PATH in case it's not machine-installed. 480
472 runtime_path = ';'.join(os.path.normpath(os.path.join(toolchain, s)) 481 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
473 for s in ('sys64', 'sys32')) 482 os.environ['GYP_MSVS_VERSION'] = version
474 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] 483 # We need to make sure windows_sdk_path is set to the automated
475 print('Using automatic toolchain in %s (%s edition).' % ( 484 # toolchain values in GYP_DEFINES, but don't want to override any
476 toolchain, 'Pro' if version_is_pro else 'Express')) 485 # otheroptions.express
486 # values there.
487 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
488 gyp_defines_dict['windows_sdk_path'] = win8sdk
489 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
490 for k, v in gyp_defines_dict.iteritems())
491 os.environ['WINDOWSSDKDIR'] = win8sdk
492 os.environ['WDK_DIR'] = wdk
493 # Include the VS runtime in the PATH in case it's not machine-installed.
494 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
495 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
496 print('Using automatic toolchain in %s (%s edition).' % (
497 toolchain, 'Pro' if version_is_pro else 'Express'))
477 498
478 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check 499 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
479 # to enfore syntax checking. 500 # to enfore syntax checking.
480 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') 501 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
481 if syntax_check and int(syntax_check): 502 if syntax_check and int(syntax_check):
482 args.append('--check') 503 args.append('--check')
483 504
484 supplemental_includes = GetSupplementalFiles() 505 supplemental_includes = GetSupplementalFiles()
485 gn_vars_dict = GetGypVarsForGN(supplemental_includes) 506 gn_vars_dict = GetGypVarsForGN(supplemental_includes)
486 507
(...skipping 23 matching lines...) Expand all
510 # from above are picked up. 531 # from above are picked up.
511 print 'Running build/landmines.py...' 532 print 'Running build/landmines.py...'
512 subprocess.check_call( 533 subprocess.check_call(
513 [sys.executable, os.path.join(script_dir, 'landmines.py')]) 534 [sys.executable, os.path.join(script_dir, 'landmines.py')])
514 535
515 if vs2013_runtime_dll_dirs: 536 if vs2013_runtime_dll_dirs:
516 CopyVsRuntimeDlls(os.path.join(chrome_src, GetOutputDirectory()), 537 CopyVsRuntimeDlls(os.path.join(chrome_src, GetOutputDirectory()),
517 vs2013_runtime_dll_dirs) 538 vs2013_runtime_dll_dirs)
518 539
519 sys.exit(gyp_rc) 540 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