mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
c67bd01d76
Setting DART_USE_GN to anything will cause 'gclient runhooks' and build.py to use GN. R=johnmccutchan@google.com Review URL: https://codereview.chromium.org/2400493002 .
79 lines
1.6 KiB
Python
79 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
# Copyright 2016 The Dart project authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import utils
|
|
|
|
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
|
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
|
|
DART_USE_GN = "DART_USE_GN"
|
|
|
|
|
|
def use_gn():
|
|
return DART_USE_GN in os.environ
|
|
|
|
|
|
def execute(args):
|
|
process = subprocess.Popen(args, cwd=DART_ROOT)
|
|
process.wait()
|
|
return process.returncode
|
|
|
|
|
|
def run_gn():
|
|
gn_command = [
|
|
'python',
|
|
os.path.join(DART_ROOT, 'tools', 'gn.py'),
|
|
'-m', 'all',
|
|
'-a', 'all',
|
|
]
|
|
return execute(gn_command)
|
|
|
|
|
|
def run_gyp():
|
|
gyp_command = [
|
|
'python',
|
|
os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'),
|
|
]
|
|
return execute(gyp_command)
|
|
|
|
|
|
def parse_args(args):
|
|
args = args[1:]
|
|
parser = argparse.ArgumentParser(
|
|
description="A script to generate Dart's build files.")
|
|
|
|
parser.add_argument("-v", "--verbose",
|
|
help='Verbose output.',
|
|
default=False,
|
|
action="store_true")
|
|
parser.add_argument("--gn",
|
|
help='Use GN',
|
|
default=use_gn(),
|
|
action='store_true')
|
|
parser.add_argument("--gyp",
|
|
help='Use gyp',
|
|
default=not use_gn(),
|
|
action='store_true')
|
|
|
|
options = parser.parse_args(args)
|
|
# If gn is enabled one way or another, then disable gyp
|
|
if options.gn:
|
|
options.gyp = False
|
|
return options
|
|
|
|
|
|
def main(argv):
|
|
options = parse_args(argv)
|
|
if options.gn:
|
|
return run_gn()
|
|
else:
|
|
return run_gyp()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv))
|