| 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 26 matching lines...) Expand all Loading... |
| 37 usage = """\ | 37 usage = """\ |
| 38 usage: %%prog [options] [targets] | 38 usage: %%prog [options] [targets] |
| 39 | 39 |
| 40 This script runs 'make' in the *current* directory. So, run it from | 40 This script runs 'make' in the *current* directory. So, run it from |
| 41 the Dart repo root, | 41 the Dart repo root, |
| 42 | 42 |
| 43 %s , | 43 %s , |
| 44 | 44 |
| 45 unless you really intend to use a non-default Makefile.""" % DART_ROOT | 45 unless you really intend to use a non-default Makefile.""" % DART_ROOT |
| 46 | 46 |
| 47 DART_USE_GYP = "DART_USE_GYP" | 47 DART_USE_GN = "DART_USE_GN" |
| 48 | 48 |
| 49 | 49 |
| 50 def use_gyp(): | 50 def use_gn(): |
| 51 return DART_USE_GYP in os.environ | 51 return DART_USE_GN in os.environ |
| 52 | 52 |
| 53 | 53 |
| 54 def BuildOptions(): | 54 def BuildOptions(): |
| 55 result = optparse.OptionParser(usage=usage) | 55 result = optparse.OptionParser(usage=usage) |
| 56 result.add_option("-m", "--mode", | 56 result.add_option("-m", "--mode", |
| 57 help='Build variants (comma-separated).', | 57 help='Build variants (comma-separated).', |
| 58 metavar='[all,debug,release,product]', | 58 metavar='[all,debug,release,product]', |
| 59 default='debug') | 59 default='debug') |
| 60 result.add_option("-v", "--verbose", | 60 result.add_option("-v", "--verbose", |
| 61 help='Verbose output.', | 61 help='Verbose output.', |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 metavar=HOST_CPUS, | 77 metavar=HOST_CPUS, |
| 78 default=str(HOST_CPUS)) | 78 default=str(HOST_CPUS)) |
| 79 (vs_directory, vs_executable) = utils.GuessVisualStudioPath() | 79 (vs_directory, vs_executable) = utils.GuessVisualStudioPath() |
| 80 result.add_option("--devenv", | 80 result.add_option("--devenv", |
| 81 help='Path containing devenv.com on Windows', | 81 help='Path containing devenv.com on Windows', |
| 82 default=vs_directory) | 82 default=vs_directory) |
| 83 result.add_option("--executable", | 83 result.add_option("--executable", |
| 84 help='Name of the devenv.com/msbuild executable on Windows (varies for ' | 84 help='Name of the devenv.com/msbuild executable on Windows (varies for ' |
| 85 'different versions of Visual Studio)', | 85 'different versions of Visual Studio)', |
| 86 default=vs_executable) | 86 default=vs_executable) |
| 87 result.add_option("--gyp", | 87 result.add_option("--gn", |
| 88 help='Build with gyp.', | 88 help='Build with GN/Ninja', |
| 89 default=use_gyp(), | 89 default=use_gn(), |
| 90 action='store_true') | 90 action='store_true') |
| 91 return result | 91 return result |
| 92 | 92 |
| 93 | 93 |
| 94 def ProcessOsOption(os_name): | 94 def ProcessOsOption(os_name): |
| 95 if os_name == 'host': | 95 if os_name == 'host': |
| 96 return HOST_OS | 96 return HOST_OS |
| 97 return os_name | 97 return os_name |
| 98 | 98 |
| 99 | 99 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 | 429 |
| 430 def BuildNinjaCommand(options, target, target_os, mode, arch): | 430 def BuildNinjaCommand(options, target, target_os, mode, arch): |
| 431 out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os) | 431 out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os) |
| 432 if ShouldRunGN(out_dir): | 432 if ShouldRunGN(out_dir): |
| 433 RunGN(target_os, mode, arch) | 433 RunGN(target_os, mode, arch) |
| 434 command = ['ninja', '-C', out_dir] | 434 command = ['ninja', '-C', out_dir] |
| 435 if options.verbose: | 435 if options.verbose: |
| 436 command += ['-v'] | 436 command += ['-v'] |
| 437 if UseGoma(out_dir): | 437 if UseGoma(out_dir): |
| 438 command += ['-j1000'] | 438 command += ['-j200'] |
| 439 command += [target] | 439 command += [target] |
| 440 return command | 440 return command |
| 441 | 441 |
| 442 | 442 |
| 443 filter_xcodebuild_output = False | 443 filter_xcodebuild_output = False |
| 444 def BuildOneConfig(options, target, target_os, mode, arch, override_tools): | 444 def BuildOneConfig(options, target, target_os, mode, arch, override_tools): |
| 445 global filter_xcodebuild_output | 445 global filter_xcodebuild_output |
| 446 start_time = time.time() | 446 start_time = time.time() |
| 447 args = [] | 447 args = [] |
| 448 build_config = utils.GetBuildConf(mode, arch, target_os) | 448 build_config = utils.GetBuildConf(mode, arch, target_os) |
| 449 if not options.gyp: | 449 if options.gn: |
| 450 args = BuildNinjaCommand(options, target, target_os, mode, arch) | 450 args = BuildNinjaCommand(options, target, target_os, mode, arch) |
| 451 else: | 451 else: |
| 452 os.environ['DART_BUILD_MODE'] = mode | 452 os.environ['DART_BUILD_MODE'] = mode |
| 453 if HOST_OS == 'macos': | 453 if HOST_OS == 'macos': |
| 454 filter_xcodebuild_output = True | 454 filter_xcodebuild_output = True |
| 455 project_file = 'dart.xcodeproj' | 455 project_file = 'dart.xcodeproj' |
| 456 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 456 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| 457 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() | 457 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() |
| 458 args = ['xcodebuild', | 458 args = ['xcodebuild', |
| 459 '-project', | 459 '-project', |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 else: | 609 else: |
| 610 if BuildOneConfig(options, target, target_os, | 610 if BuildOneConfig(options, target, target_os, |
| 611 mode, arch, cross_build) != 0: | 611 mode, arch, cross_build) != 0: |
| 612 return 1 | 612 return 1 |
| 613 | 613 |
| 614 return 0 | 614 return 0 |
| 615 | 615 |
| 616 | 616 |
| 617 if __name__ == '__main__': | 617 if __name__ == '__main__': |
| 618 sys.exit(Main()) | 618 sys.exit(Main()) |
| OLD | NEW |