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

Side by Side Diff: tools/generate_buildfiles.py

Issue 2599673004: Revert "GN: Make GN the default" (Closed)
Patch Set: Created 3 years, 12 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 unified diff | Download patch
« no previous file with comments | « tools/build.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 12 SCRIPT_DIR = os.path.dirname(sys.argv[0])
13 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 13 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
14 DART_USE_GYP = "DART_USE_GYP" 14 DART_USE_GN = "DART_USE_GN"
15 DART_DISABLE_BUILDFILES = "DART_DISABLE_BUILDFILES" 15 DART_DISABLE_BUILDFILES = "DART_DISABLE_BUILDFILES"
16 16
17 17
18 def use_gyp(): 18 def use_gn():
19 return DART_USE_GYP in os.environ 19 return DART_USE_GN in os.environ
20 20
21 21
22 def disable_buildfiles(): 22 def disable_buildfiles():
23 return DART_DISABLE_BUILDFILES in os.environ 23 return DART_DISABLE_BUILDFILES in os.environ
24 24
25 25
26 def execute(args): 26 def execute(args):
27 process = subprocess.Popen(args, cwd=DART_ROOT) 27 process = subprocess.Popen(args, cwd=DART_ROOT)
28 process.wait() 28 process.wait()
29 return process.returncode 29 return process.returncode
30 30
31 31
32 def run_gn(options): 32 def run_gn():
33 gn_command = [ 33 gn_command = [
34 'python', 34 'python',
35 os.path.join(DART_ROOT, 'tools', 'gn.py'), 35 os.path.join(DART_ROOT, 'tools', 'gn.py'),
36 '-m', 'all', 36 '-m', 'all',
37 '-a', 'all', 37 '-a', 'all',
38 ] 38 ]
39 if options.verbose:
40 gn_command.append('-v')
41 print ' '.join(gn_command)
42 return execute(gn_command) 39 return execute(gn_command)
43 40
44 41
45 def run_gyp(options): 42 def run_gyp():
46 gyp_command = [ 43 gyp_command = [
47 'python', 44 'python',
48 os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'), 45 os.path.join(DART_ROOT, 'tools', 'gyp_dart.py'),
49 ] 46 ]
50 if options.verbose:
51 print ' '.join(gyp_command)
52 return execute(gyp_command) 47 return execute(gyp_command)
53 48
54 49
55 def parse_args(args): 50 def parse_args(args):
56 args = args[1:] 51 args = args[1:]
57 parser = argparse.ArgumentParser( 52 parser = argparse.ArgumentParser(
58 description="A script to generate Dart's build files.") 53 description="A script to generate Dart's build files.")
59 54
60 parser.add_argument("-v", "--verbose", 55 parser.add_argument("-v", "--verbose",
61 help='Verbose output.', 56 help='Verbose output.',
62 default=False, 57 default=False,
63 action="store_true") 58 action="store_true")
64 parser.add_argument("--gn", 59 parser.add_argument("--gn",
65 help='Use GN', 60 help='Use GN',
66 default=not use_gyp(), 61 default=use_gn(),
67 action='store_true') 62 action='store_true')
68 parser.add_argument("--gyp", 63 parser.add_argument("--gyp",
69 help='Use gyp', 64 help='Use gyp',
70 default=use_gyp(), 65 default=not use_gn(),
71 action='store_true') 66 action='store_true')
72 67
73 options = parser.parse_args(args) 68 options = parser.parse_args(args)
74 # If gyp is enabled one way or another, then disable gn 69 # If gn is enabled one way or another, then disable gyp
75 if options.gyp: 70 if options.gn:
76 options.gn = False 71 options.gyp = False
77 return options 72 return options
78 73
79 74
80 def main(argv): 75 def main(argv):
81 # Check the environment and become a no-op if directed. 76 # Check the environment and become a no-op if directed.
82 if disable_buildfiles(): 77 if disable_buildfiles():
83 return 0 78 return 0
84 options = parse_args(argv) 79 options = parse_args(argv)
85 if options.gn: 80 if options.gn:
86 return run_gn(options) 81 return run_gn()
87 else: 82 else:
88 return run_gyp(options) 83 return run_gyp()
89 84
90 85
91 if __name__ == '__main__': 86 if __name__ == '__main__':
92 sys.exit(main(sys.argv)) 87 sys.exit(main(sys.argv))
OLDNEW
« 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