OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import argparse |
| 7 import os |
| 8 import subprocess |
| 9 import sys |
| 10 import utils |
| 11 |
| 12 SCRIPT_DIR = os.path.dirname(sys.argv[0]) |
| 13 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) |
| 14 DART_USE_GN = "DART_USE_GN" |
| 15 |
| 16 |
| 17 def use_gn(): |
| 18 return DART_USE_GN in os.environ |
| 19 |
| 20 |
| 21 def execute(args): |
| 22 process = subprocess.Popen(args, cwd=DART_ROOT) |
| 23 process.wait() |
| 24 return process.returncode |
| 25 |
| 26 |
| 27 def run_gn(): |
| 28 gn_command = [ |
| 29 'python', |
| 30 os.path.join(DART_ROOT, 'tools', 'gn.py'), |
| 31 '-m', 'all', |
| 32 '-a', 'all', |
| 33 ] |
| 34 return execute(gn_command) |
| 35 |
| 36 |
| 37 def run_gyp(): |
| 38 gyp_command = [ |
| 39 'python', |
| 40 os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'), |
| 41 ] |
| 42 return execute(gyp_command) |
| 43 |
| 44 |
| 45 def parse_args(args): |
| 46 args = args[1:] |
| 47 parser = argparse.ArgumentParser( |
| 48 description="A script to generate Dart's build files.") |
| 49 |
| 50 parser.add_argument("-v", "--verbose", |
| 51 help='Verbose output.', |
| 52 default=False, |
| 53 action="store_true") |
| 54 parser.add_argument("--gn", |
| 55 help='Use GN', |
| 56 default=use_gn(), |
| 57 action='store_true') |
| 58 parser.add_argument("--gyp", |
| 59 help='Use gyp', |
| 60 default=not use_gn(), |
| 61 action='store_true') |
| 62 |
| 63 options = parser.parse_args(args) |
| 64 # If gn is enabled one way or another, then disable gyp |
| 65 if options.gn: |
| 66 options.gyp = False |
| 67 return options |
| 68 |
| 69 |
| 70 def main(argv): |
| 71 options = parse_args(argv) |
| 72 if options.gn: |
| 73 return run_gn() |
| 74 else: |
| 75 return run_gyp() |
| 76 |
| 77 |
| 78 if __name__ == '__main__': |
| 79 sys.exit(main(sys.argv)) |
OLD | NEW |