Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: tools/generate_buildfiles.py

Issue 2400493002: Select GN build with an environment variable (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/build.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/generate_buildfiles.py
diff --git a/tools/generate_buildfiles.py b/tools/generate_buildfiles.py
new file mode 100644
index 0000000000000000000000000000000000000000..391a15a07ea4358d84c0ed8783ebdaa8b4f7b0b2
--- /dev/null
+++ b/tools/generate_buildfiles.py
@@ -0,0 +1,79 @@
+#!/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))
« no previous file with comments | « tools/build.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698