| 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 shutil | 9 import shutil |
| 10 import sys | 10 import sys |
| 11 import utils | 11 import utils |
| 12 | 12 |
| 13 HOST_OS = utils.GuessOS() | 13 HOST_OS = utils.GuessOS() |
| 14 | 14 |
| 15 def BuildOptions(): | 15 def BuildOptions(): |
| 16 result = optparse.OptionParser() | 16 result = optparse.OptionParser() |
| 17 result.add_option("-m", "--mode", | 17 result.add_option("-m", "--mode", |
| 18 help='Build variants (comma-separated).', | 18 help='Build variants (comma-separated).', |
| 19 metavar='[all,debug,release]', | 19 metavar='[all,debug,release]', |
| 20 default='all') | 20 default='all') |
| 21 result.add_option("--arch", | 21 result.add_option("--arch", |
| 22 help='Target architectures (comma-separated).', | 22 help='Target architectures (comma-separated).', |
| 23 metavar='[all,ia32,x64,simarm,arm]', | 23 metavar='[all,ia32,x64,simarm,arm]', |
| 24 default=utils.GuessArchitecture()) | 24 default=utils.GuessArchitecture()) |
| 25 result.add_option("--os", |
| 26 help='Target OSs (comma-separated).', |
| 27 metavar='[all,host,android]', |
| 28 default='all') |
| 25 return result | 29 return result |
| 26 | 30 |
| 31 |
| 32 def ProcessOsOption(os): |
| 33 if os == 'host': |
| 34 return HOST_OS |
| 35 return os |
| 36 |
| 37 |
| 27 def ProcessOptions(options): | 38 def ProcessOptions(options): |
| 28 if options.arch == 'all': | 39 if options.arch == 'all': |
| 29 options.arch = 'ia32,x64' | 40 options.arch = 'ia32,x64' |
| 30 if options.mode == 'all': | 41 if options.mode == 'all': |
| 31 options.mode = 'release,debug' | 42 options.mode = 'release,debug' |
| 43 if options.os == 'all': |
| 44 options.os = 'host,android' |
| 32 options.mode = options.mode.split(',') | 45 options.mode = options.mode.split(',') |
| 33 options.arch = options.arch.split(',') | 46 options.arch = options.arch.split(',') |
| 47 options.os = options.os.split(',') |
| 34 for mode in options.mode: | 48 for mode in options.mode: |
| 35 if not mode in ['debug', 'release']: | 49 if not mode in ['debug', 'release']: |
| 36 print "Unknown mode %s" % mode | 50 print "Unknown mode %s" % mode |
| 37 return False | 51 return False |
| 38 for arch in options.arch: | 52 for arch in options.arch: |
| 39 if not arch in ['ia32', 'x64', 'simarm', 'arm']: | 53 if not arch in ['ia32', 'x64', 'simarm', 'arm']: |
| 40 print "Unknown arch %s" % arch | 54 print "Unknown arch %s" % arch |
| 41 return False | 55 return False |
| 56 options.os = [ProcessOsOption(os) for os in options.os] |
| 57 for os in options.os: |
| 58 if not os in ['android', 'freebsd', 'linux', 'macos', 'win32']: |
| 59 print "Unknown os %s" % os |
| 60 return False |
| 42 return True | 61 return True |
| 43 | 62 |
| 44 def Main(): | 63 def Main(): |
| 45 parser = BuildOptions() | 64 parser = BuildOptions() |
| 46 (options, args) = parser.parse_args() | 65 (options, args) = parser.parse_args() |
| 47 if not ProcessOptions(options): | 66 if not ProcessOptions(options): |
| 48 parser.print_help() | 67 parser.print_help() |
| 49 return 1 | 68 return 1 |
| 50 | 69 |
| 51 # Delete the output for the targets for each requested configuration. | 70 # Delete the output for the targets for each requested configuration. |
| 52 for mode in options.mode: | 71 for mode in options.mode: |
| 53 for arch in options.arch: | 72 for arch in options.arch: |
| 54 build_root = utils.GetBuildRoot(HOST_OS, mode=mode, arch=arch) | 73 for target_os in options.os: |
| 55 print "Deleting %s" % (build_root) | 74 build_root = utils.GetBuildRoot( |
| 56 shutil.rmtree(build_root, ignore_errors=True) | 75 HOST_OS, mode=mode, arch=arch, target_os=target_os) |
| 57 # On windows we have additional object files within the runtime library. | 76 print "Deleting %s" % (build_root) |
| 58 if HOST_OS == 'win32': | 77 shutil.rmtree(build_root, ignore_errors=True) |
| 59 runtime_root = 'runtime/' + build_root | 78 # On windows we have additional object files within the runtime library. |
| 60 print "Deleting %s" % (runtime_root) | 79 if HOST_OS == 'win32': |
| 61 shutil.rmtree(runtime_root, ignore_errors=True) | 80 runtime_root = 'runtime/' + build_root |
| 81 print "Deleting %s" % (runtime_root) |
| 82 shutil.rmtree(runtime_root, ignore_errors=True) |
| 62 return 0 | 83 return 0 |
| 63 | 84 |
| 64 if __name__ == '__main__': | 85 if __name__ == '__main__': |
| 65 sys.exit(Main()) | 86 sys.exit(Main()) |
| OLD | NEW |