| 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_helper |
| 12 import os | 12 import os |
| 13 import pipes | 13 import pipes |
| 14 import shlex | 14 import shlex |
| 15 import shutil |
| 15 import subprocess | 16 import subprocess |
| 16 import string | 17 import string |
| 17 import sys | 18 import sys |
| 18 | 19 |
| 19 script_dir = os.path.dirname(os.path.realpath(__file__)) | 20 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 20 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)) |
| 21 | 22 |
| 22 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 23 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
| 23 import gyp | 24 import gyp |
| 24 | 25 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 # Need to pass both the source root (the bots don't run this command from | 320 # Need to pass both the source root (the bots don't run this command from |
| 320 # within the source tree) as well as set the is_gyp value so the BUILD files | 321 # within the source tree) as well as set the is_gyp value so the BUILD files |
| 321 # to know they're being run under GYP. | 322 # to know they're being run under GYP. |
| 322 args = [gnpath, 'gyp', '-q', | 323 args = [gnpath, 'gyp', '-q', |
| 323 '--root=' + chrome_src, | 324 '--root=' + chrome_src, |
| 324 '--args=' + GetArgsStringForGN(supplemental_includes), | 325 '--args=' + GetArgsStringForGN(supplemental_includes), |
| 325 '--output=//' + GetOutputDirectory() + '/gn_build/'] | 326 '--output=//' + GetOutputDirectory() + '/gn_build/'] |
| 326 return subprocess.call(args) == 0 | 327 return subprocess.call(args) == 0 |
| 327 | 328 |
| 328 | 329 |
| 330 def CopyVsRuntimeDlls(output_dir, runtime_dirs): |
| 331 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output |
| 332 directory so that even if not system-installed, built binaries are likely to |
| 333 be able to run. |
| 334 |
| 335 This needs to be run after gyp has been run so that the expected target |
| 336 output directories are already created. |
| 337 """ |
| 338 assert sys.platform.startswith(('win32', 'cygwin')) |
| 339 |
| 340 def copy_runtime(target_dir, source_dir, dll_pattern): |
| 341 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
| 342 exist, but the target directory does exist.""" |
| 343 for which in ('p', 'r'): |
| 344 dll = dll_pattern % which |
| 345 target = os.path.join(target_dir, dll) |
| 346 source = os.path.join(source_dir, dll) |
| 347 # If gyp generated to that output dir, and the runtime isn't already |
| 348 # there, then copy it over. |
| 349 if os.path.isdir(target_dir) and not os.path.isfile(target): |
| 350 shutil.copyfile(source, target) |
| 351 |
| 352 x86, x64 = runtime_dirs |
| 353 out_debug = os.path.join(output_dir, 'Debug') |
| 354 out_release = os.path.join(output_dir, 'Release') |
| 355 out_debug_x64 = os.path.join(output_dir, 'Debug_x64') |
| 356 out_release_x64 = os.path.join(output_dir, 'Release_x64') |
| 357 copy_runtime(out_debug, x86, 'msvc%s120d.dll') |
| 358 copy_runtime(out_release, x86, 'msvc%s120.dll') |
| 359 copy_runtime(out_debug_x64, x64, 'msvc%s120d.dll') |
| 360 copy_runtime(out_release_x64, x64, 'msvc%s120.dll') |
| 361 |
| 362 |
| 329 if __name__ == '__main__': | 363 if __name__ == '__main__': |
| 330 args = sys.argv[1:] | 364 args = sys.argv[1:] |
| 331 | 365 |
| 332 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): | 366 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): |
| 333 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' | 367 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' |
| 334 sys.exit(0) | 368 sys.exit(0) |
| 335 | 369 |
| 336 # Use the Psyco JIT if available. | 370 # Use the Psyco JIT if available. |
| 337 if psyco: | 371 if psyco: |
| 338 psyco.profile() | 372 psyco.profile() |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): | 429 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): |
| 396 os.environ['GYP_GENERATORS'] = 'ninja' | 430 os.environ['GYP_GENERATORS'] = 'ninja' |
| 397 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'): | 431 if sys.platform.startswith('win') and not os.environ.get('GYP_GENERATORS'): |
| 398 os.environ['GYP_GENERATORS'] = 'ninja' | 432 os.environ['GYP_GENERATORS'] = 'ninja' |
| 399 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ | 433 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ |
| 400 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): | 434 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): |
| 401 os.environ['GYP_GENERATORS'] = 'ninja' | 435 os.environ['GYP_GENERATORS'] = 'ninja' |
| 402 | 436 |
| 403 # If using ninja on windows, and the automatic toolchain has been installed | 437 # If using ninja on windows, and the automatic toolchain has been installed |
| 404 # by depot_tools, then use it. | 438 # by depot_tools, then use it. |
| 439 vs2013_runtime_dll_dirs = None |
| 405 if (sys.platform in ('win32', 'cygwin') and | 440 if (sys.platform in ('win32', 'cygwin') and |
| 406 os.environ.get('GYP_GENERATORS') == 'ninja'): | 441 os.environ.get('GYP_GENERATORS') == 'ninja'): |
| 407 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 442 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 408 toolchain = os.path.normpath(os.path.join( | 443 toolchain = os.path.normpath(os.path.join( |
| 409 depot_tools_path, 'win_toolchain', 'vs2013_files')) | 444 depot_tools_path, 'win_toolchain', 'vs2013_files')) |
| 410 version_file = os.path.join(toolchain, '.version') | 445 version_file = os.path.join(toolchain, '.version') |
| 411 if os.path.isdir(toolchain) and os.path.isfile(version_file): | 446 if os.path.isdir(toolchain) and os.path.isfile(version_file): |
| 412 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain | 447 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
| 413 with open(version_file, 'r') as f: | 448 with open(version_file, 'r') as f: |
| 414 version_is_pro = f.read().strip() == 'pro' | 449 version_is_pro = f.read().strip() == 'pro' |
| 450 vs2013_runtime_dll_dirs = (os.path.join(toolchain, 'sys32'), |
| 451 os.path.join(toolchain, 'sys64')) |
| 415 os.environ['GYP_MSVS_VERSION'] = '2013' if version_is_pro else '2013e' | 452 os.environ['GYP_MSVS_VERSION'] = '2013' if version_is_pro else '2013e' |
| 416 # We need to make sure windows_sdk_path is set to the automated | 453 # We need to make sure windows_sdk_path is set to the automated |
| 417 # toolchain values in GYP_DEFINES, but don't want to override any other | 454 # toolchain values in GYP_DEFINES, but don't want to override any other |
| 418 # values there. | 455 # values there. |
| 419 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) | 456 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) |
| 420 win8sdk = os.path.join(toolchain, 'win8sdk') | 457 win8sdk = os.path.join(toolchain, 'win8sdk') |
| 421 wdk = os.path.join(toolchain, 'wdk') | 458 wdk = os.path.join(toolchain, 'wdk') |
| 422 gyp_defines_dict['windows_sdk_path'] = win8sdk | 459 gyp_defines_dict['windows_sdk_path'] = win8sdk |
| 423 os.environ['WINDOWSSDKDIR'] = win8sdk | 460 os.environ['WINDOWSSDKDIR'] = win8sdk |
| 424 os.environ['WDK_DIR'] = wdk | 461 os.environ['WDK_DIR'] = wdk |
| (...skipping 17 matching lines...) Expand all Loading... |
| 442 sys.exit(1) | 479 sys.exit(1) |
| 443 args.extend( | 480 args.extend( |
| 444 ['-I' + i for i in additional_include_files(supplemental_includes, args)]) | 481 ['-I' + i for i in additional_include_files(supplemental_includes, args)]) |
| 445 | 482 |
| 446 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) | 483 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) |
| 447 | 484 |
| 448 print 'Updating projects from gyp files...' | 485 print 'Updating projects from gyp files...' |
| 449 sys.stdout.flush() | 486 sys.stdout.flush() |
| 450 | 487 |
| 451 # Off we go... | 488 # Off we go... |
| 452 sys.exit(gyp.main(args)) | 489 gyp_rc = gyp.main(args) |
| 490 |
| 491 if vs2013_runtime_dll_dirs: |
| 492 CopyVsRuntimeDlls(GetOutputDirectory(), vs2013_runtime_dll_dirs) |
| 493 |
| 494 sys.exit(gyp_rc) |
| OLD | NEW |