| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Dart project authors. All rights reserved. | 2 # Copyright 2016 The Dart project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import utils | 10 import utils |
| 11 | 11 |
| 12 HOST_OS = utils.GuessOS() |
| 12 SCRIPT_DIR = os.path.dirname(sys.argv[0]) | 13 SCRIPT_DIR = os.path.dirname(sys.argv[0]) |
| 13 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) | 14 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) |
| 14 DART_USE_GYP = "DART_USE_GYP" | 15 DART_USE_GYP = "DART_USE_GYP" |
| 15 DART_DISABLE_BUILDFILES = "DART_DISABLE_BUILDFILES" | 16 DART_DISABLE_BUILDFILES = "DART_DISABLE_BUILDFILES" |
| 16 | 17 |
| 17 | 18 |
| 18 def use_gyp(): | 19 def use_gyp(): |
| 19 return DART_USE_GYP in os.environ | 20 return DART_USE_GYP in os.environ |
| 20 | 21 |
| 21 | 22 |
| 22 def disable_buildfiles(): | 23 def disable_buildfiles(): |
| 23 return DART_DISABLE_BUILDFILES in os.environ | 24 return DART_DISABLE_BUILDFILES in os.environ |
| 24 | 25 |
| 25 | 26 |
| 26 def execute(args): | 27 def execute(args): |
| 27 process = subprocess.Popen(args, cwd=DART_ROOT) | 28 process = subprocess.Popen(args, cwd=DART_ROOT) |
| 28 process.wait() | 29 process.wait() |
| 29 return process.returncode | 30 return process.returncode |
| 30 | 31 |
| 31 | 32 |
| 32 def run_gn(options): | 33 def run_android_gn(options): |
| 34 if not HOST_OS in ['linux', 'macos']: |
| 35 return 0 |
| 33 gn_command = [ | 36 gn_command = [ |
| 34 'python', | 37 'python', |
| 35 os.path.join(DART_ROOT, 'tools', 'gn.py'), | 38 os.path.join(DART_ROOT, 'tools', 'gn.py'), |
| 39 '-m', 'all', |
| 40 '-a', 'arm,arm64', |
| 41 '--os', 'android', |
| 42 ] |
| 43 if options.verbose: |
| 44 gn_command.append('-v') |
| 45 print ' '.join(gn_command) |
| 46 return execute(gn_command) |
| 47 |
| 48 |
| 49 def run_host_gn(options): |
| 50 gn_command = [ |
| 51 'python', |
| 52 os.path.join(DART_ROOT, 'tools', 'gn.py'), |
| 36 '-m', 'all', | 53 '-m', 'all', |
| 37 '-a', 'all', | 54 '-a', 'all', |
| 38 ] | 55 ] |
| 39 if options.verbose: | 56 if options.verbose: |
| 40 gn_command.append('-v') | 57 gn_command.append('-v') |
| 41 print ' '.join(gn_command) | 58 print ' '.join(gn_command) |
| 42 return execute(gn_command) | 59 return execute(gn_command) |
| 43 | 60 |
| 44 | 61 |
| 62 def run_gn(options): |
| 63 status = run_host_gn(options) |
| 64 if status != 0: |
| 65 return status |
| 66 return run_android_gn(options) |
| 67 |
| 68 |
| 45 def run_gyp(options): | 69 def run_gyp(options): |
| 46 gyp_command = [ | 70 gyp_command = [ |
| 47 'python', | 71 'python', |
| 48 os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'), | 72 os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'), |
| 49 ] | 73 ] |
| 50 if options.verbose: | 74 if options.verbose: |
| 51 print ' '.join(gyp_command) | 75 print ' '.join(gyp_command) |
| 52 return execute(gyp_command) | 76 return execute(gyp_command) |
| 53 | 77 |
| 54 | 78 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 83 return 0 | 107 return 0 |
| 84 options = parse_args(argv) | 108 options = parse_args(argv) |
| 85 if options.gn: | 109 if options.gn: |
| 86 return run_gn(options) | 110 return run_gn(options) |
| 87 else: | 111 else: |
| 88 return run_gyp(options) | 112 return run_gyp(options) |
| 89 | 113 |
| 90 | 114 |
| 91 if __name__ == '__main__': | 115 if __name__ == '__main__': |
| 92 sys.exit(main(sys.argv)) | 116 sys.exit(main(sys.argv)) |
| OLD | NEW |