| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 metavar=HOST_CPUS, | 70 metavar=HOST_CPUS, |
| 71 default=str(HOST_CPUS)) | 71 default=str(HOST_CPUS)) |
| 72 (vs_directory, vs_executable) = utils.GuessVisualStudioPath() | 72 (vs_directory, vs_executable) = utils.GuessVisualStudioPath() |
| 73 result.add_option("--devenv", | 73 result.add_option("--devenv", |
| 74 help='Path containing devenv.com on Windows', | 74 help='Path containing devenv.com on Windows', |
| 75 default=vs_directory) | 75 default=vs_directory) |
| 76 result.add_option("--executable", | 76 result.add_option("--executable", |
| 77 help='Name of the devenv.com/msbuild executable on Windows (varies for ' | 77 help='Name of the devenv.com/msbuild executable on Windows (varies for ' |
| 78 'different versions of Visual Studio)', | 78 'different versions of Visual Studio)', |
| 79 default=vs_executable) | 79 default=vs_executable) |
| 80 result.add_option("--gn", |
| 81 help='Build with GN/Ninja', |
| 82 default=False, |
| 83 action='store_true') |
| 80 return result | 84 return result |
| 81 | 85 |
| 82 | 86 |
| 83 def ProcessOsOption(os_name): | 87 def ProcessOsOption(os_name): |
| 84 if os_name == 'host': | 88 if os_name == 'host': |
| 85 return HOST_OS | 89 return HOST_OS |
| 86 return os_name | 90 return os_name |
| 87 | 91 |
| 88 | 92 |
| 89 def ProcessOptions(options, args): | 93 def ProcessOptions(options, args): |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 "$n.showballoontip(%d, '%s', '%s', " | 386 "$n.showballoontip(%d, '%s', '%s', " |
| 383 "[system.windows.forms.tooltipicon]::%s);\"") % ( | 387 "[system.windows.forms.tooltipicon]::%s);\"") % ( |
| 384 5000, # Notification stays on for this many milliseconds | 388 5000, # Notification stays on for this many milliseconds |
| 385 message, title, icon) | 389 message, title, icon) |
| 386 | 390 |
| 387 if command: | 391 if command: |
| 388 # Ignore return code, if this command fails, it doesn't matter. | 392 # Ignore return code, if this command fails, it doesn't matter. |
| 389 os.system(command) | 393 os.system(command) |
| 390 | 394 |
| 391 | 395 |
| 396 def BuildNinjaCommand(options, target, target_os, mode, arch): |
| 397 out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os) |
| 398 command = ['ninja', '-C', out_dir] |
| 399 if options.verbose: |
| 400 command += ['-v'] |
| 401 command += [target] |
| 402 return command |
| 403 |
| 404 |
| 392 filter_xcodebuild_output = False | 405 filter_xcodebuild_output = False |
| 393 def BuildOneConfig(options, target, target_os, mode, arch, override_tools): | 406 def BuildOneConfig(options, target, target_os, mode, arch, override_tools): |
| 394 global filter_xcodebuild_output | 407 global filter_xcodebuild_output |
| 395 start_time = time.time() | 408 start_time = time.time() |
| 396 os.environ['DART_BUILD_MODE'] = mode | 409 args = [] |
| 397 build_config = utils.GetBuildConf(mode, arch, target_os) | 410 build_config = utils.GetBuildConf(mode, arch, target_os) |
| 398 if HOST_OS == 'macos': | 411 if options.gn: |
| 399 filter_xcodebuild_output = True | 412 args = BuildNinjaCommand(options, target, target_os, mode, arch) |
| 400 project_file = 'dart.xcodeproj' | 413 else: |
| 401 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 414 os.environ['DART_BUILD_MODE'] = mode |
| 402 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() | 415 if HOST_OS == 'macos': |
| 403 args = ['xcodebuild', | 416 filter_xcodebuild_output = True |
| 404 '-project', | 417 project_file = 'dart.xcodeproj' |
| 405 project_file, | 418 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| 406 '-target', | 419 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() |
| 407 target, | 420 args = ['xcodebuild', |
| 408 '-configuration', | 421 '-project', |
| 409 build_config, | 422 project_file, |
| 410 'SYMROOT=%s' % os.path.abspath('xcodebuild') | 423 '-target', |
| 411 ] | 424 target, |
| 412 elif HOST_OS == 'win32': | 425 '-configuration', |
| 413 project_file = 'dart.sln' | 426 build_config, |
| 414 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 427 'SYMROOT=%s' % os.path.abspath('xcodebuild') |
| 415 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() | 428 ] |
| 416 # Select a platform suffix to pass to devenv. | 429 elif HOST_OS == 'win32': |
| 417 if arch == 'ia32': | 430 project_file = 'dart.sln' |
| 418 platform_suffix = 'Win32' | 431 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| 419 elif arch == 'x64': | 432 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() |
| 420 platform_suffix = 'x64' | 433 # Select a platform suffix to pass to devenv. |
| 434 if arch == 'ia32': |
| 435 platform_suffix = 'Win32' |
| 436 elif arch == 'x64': |
| 437 platform_suffix = 'x64' |
| 438 else: |
| 439 print 'Unsupported arch for MSVC build: %s' % arch |
| 440 return 1 |
| 441 config_name = '%s|%s' % (build_config, platform_suffix) |
| 442 if target == 'all': |
| 443 args = [options.devenv + os.sep + options.executable, |
| 444 '/build', |
| 445 config_name, |
| 446 project_file |
| 447 ] |
| 448 else: |
| 449 args = [options.devenv + os.sep + options.executable, |
| 450 '/build', |
| 451 config_name, |
| 452 '/project', |
| 453 target, |
| 454 project_file |
| 455 ] |
| 421 else: | 456 else: |
| 422 print 'Unsupported arch for MSVC build: %s' % arch | 457 make = 'make' |
| 423 return 1 | 458 if HOST_OS == 'freebsd': |
| 424 config_name = '%s|%s' % (build_config, platform_suffix) | 459 make = 'gmake' |
| 425 if target == 'all': | 460 # work around lack of flock |
| 426 args = [options.devenv + os.sep + options.executable, | 461 os.environ['LINK'] = '$(CXX)' |
| 427 '/build', | 462 args = [make, |
| 428 config_name, | 463 '-j', |
| 429 project_file | 464 options.j, |
| 430 ] | 465 'BUILDTYPE=' + build_config, |
| 431 else: | 466 ] |
| 432 args = [options.devenv + os.sep + options.executable, | 467 if target_os != HOST_OS: |
| 433 '/build', | 468 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS)] |
| 434 config_name, | 469 if options.verbose: |
| 435 '/project', | 470 args += ['V=1'] |
| 436 target, | |
| 437 project_file | |
| 438 ] | |
| 439 else: | |
| 440 make = 'make' | |
| 441 if HOST_OS == 'freebsd': | |
| 442 make = 'gmake' | |
| 443 # work around lack of flock | |
| 444 os.environ['LINK'] = '$(CXX)' | |
| 445 args = [make, | |
| 446 '-j', | |
| 447 options.j, | |
| 448 'BUILDTYPE=' + build_config, | |
| 449 ] | |
| 450 if target_os != HOST_OS: | |
| 451 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS)] | |
| 452 if options.verbose: | |
| 453 args += ['V=1'] | |
| 454 | 471 |
| 455 args += [target] | 472 args += [target] |
| 456 | 473 |
| 457 toolsOverride = None | 474 toolsOverride = None |
| 458 if override_tools: | 475 if override_tools: |
| 459 toolsOverride = SetTools(arch, target_os, options) | 476 toolsOverride = SetTools(arch, target_os, options) |
| 460 if toolsOverride: | 477 if toolsOverride: |
| 461 for k, v in toolsOverride.iteritems(): | 478 for k, v in toolsOverride.iteritems(): |
| 462 args.append( k + "=" + v) | 479 args.append( k + "=" + v) |
| 463 if options.verbose: | 480 if options.verbose: |
| 464 print k + " = " + v | 481 print k + " = " + v |
| 465 if not os.path.isfile(toolsOverride['CC.target']): | 482 if not os.path.isfile(toolsOverride['CC.target']): |
| (...skipping 28 matching lines...) Expand all Loading... |
| 494 def BuildCrossSdk(options, target_os, mode, arch): | 511 def BuildCrossSdk(options, target_os, mode, arch): |
| 495 # First build 'create_sdk' for the host. Do not override the host toolchain. | 512 # First build 'create_sdk' for the host. Do not override the host toolchain. |
| 496 if BuildOneConfig(options, 'create_sdk', HOST_OS, | 513 if BuildOneConfig(options, 'create_sdk', HOST_OS, |
| 497 mode, HOST_ARCH, False) != 0: | 514 mode, HOST_ARCH, False) != 0: |
| 498 return 1 | 515 return 1 |
| 499 | 516 |
| 500 # Then, build the runtime for the target arch. | 517 # Then, build the runtime for the target arch. |
| 501 if BuildOneConfig(options, 'runtime', target_os, mode, arch, True) != 0: | 518 if BuildOneConfig(options, 'runtime', target_os, mode, arch, True) != 0: |
| 502 return 1 | 519 return 1 |
| 503 | 520 |
| 504 # TODO(zra): verify that no platform specific details leak into the snapshots | |
| 505 # created for pub, dart2js, etc. | |
| 506 | |
| 507 # Copy dart-sdk from the host build products dir to the target build | 521 # Copy dart-sdk from the host build products dir to the target build |
| 508 # products dir, and copy the dart binary for target to the sdk bin/ dir. | 522 # products dir, and copy the dart binary for target to the sdk bin/ dir. |
| 509 src = os.path.join( | 523 src = os.path.join( |
| 510 utils.GetBuildRoot(HOST_OS, mode, HOST_ARCH, HOST_OS), 'dart-sdk') | 524 utils.GetBuildRoot(HOST_OS, mode, HOST_ARCH, HOST_OS), 'dart-sdk') |
| 511 dst = os.path.join( | 525 dst = os.path.join( |
| 512 utils.GetBuildRoot(HOST_OS, mode, arch, target_os), 'dart-sdk') | 526 utils.GetBuildRoot(HOST_OS, mode, arch, target_os), 'dart-sdk') |
| 513 shutil.rmtree(dst, ignore_errors=True) | 527 shutil.rmtree(dst, ignore_errors=True) |
| 514 shutil.copytree(src, dst) | 528 shutil.copytree(src, dst) |
| 515 | 529 |
| 516 dart = os.path.join( | 530 dart = os.path.join( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 else: | 572 else: |
| 559 if BuildOneConfig(options, target, target_os, | 573 if BuildOneConfig(options, target, target_os, |
| 560 mode, arch, cross_build) != 0: | 574 mode, arch, cross_build) != 0: |
| 561 return 1 | 575 return 1 |
| 562 | 576 |
| 563 return 0 | 577 return 0 |
| 564 | 578 |
| 565 | 579 |
| 566 if __name__ == '__main__': | 580 if __name__ == '__main__': |
| 567 sys.exit(Main()) | 581 sys.exit(Main()) |
| OLD | NEW |