Flutter Engine
The Flutter Engine
generate_buildfiles.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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
6import argparse
7import os
8import subprocess
9import sys
10import utils
11
12HOST_OS = utils.GuessOS()
13SCRIPT_DIR = os.path.dirname(sys.argv[0])
14DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
15DART_DISABLE_BUILDFILES = "DART_DISABLE_BUILDFILES"
16
17
19 return DART_DISABLE_BUILDFILES in os.environ
20
21
22def Execute(args):
23 process = subprocess.Popen(args, cwd=DART_ROOT)
24 process.wait()
25 return process.returncode
26
27
28def RunAndroidGn(options):
29 if not HOST_OS in ['linux', 'macos']:
30 return 0
31 gn_command = [
32 'python3',
33 os.path.join(DART_ROOT, 'tools', 'gn.py'),
34 '-m',
35 'all',
36 '-a',
37 'arm,arm64',
38 '--os',
39 'android',
40 ]
41 if options.verbose:
42 gn_command.append('-v')
43 print(' '.join(gn_command))
44 return Execute(gn_command)
45
46
47def RunCrossGn(options):
48 if HOST_OS != 'linux':
49 return 0
50 gn_command = [
51 'python3',
52 os.path.join(DART_ROOT, 'tools', 'gn.py'),
53 '-m',
54 'all',
55 '-a',
56 'arm,arm64',
57 ]
58 if options.verbose:
59 gn_command.append('-v')
60 print(' '.join(gn_command))
61 return Execute(gn_command)
62
63
64def RunHostGn(options):
65 gn_command = [
66 'python3',
67 os.path.join(DART_ROOT, 'tools', 'gn.py'),
68 '-m',
69 'all',
70 '-a',
71 'all',
72 ]
73 if options.verbose:
74 gn_command.append('-v')
75 print(' '.join(gn_command))
76 return Execute(gn_command)
77
78
79def RunGn(options):
80 status = RunHostGn(options)
81 if status != 0:
82 return status
83 status = RunCrossGn(options)
84 if status != 0:
85 return status
86 return RunAndroidGn(options)
87
88
89def ParseArgs(args):
90 args = args[1:]
91 parser = argparse.ArgumentParser(
92 description="A script to generate Dart's build files.")
93
94 parser.add_argument(
95 "-v",
96 "--verbose",
97 help='Verbose output.',
98 default=False,
99 action="store_true")
100
101 return parser.parse_args(args)
102
103
104def main(argv):
105 # Check the environment and become a no-op if directed.
107 return 0
108 options = ParseArgs(argv)
109 RunGn(options)
110
111
112if __name__ == '__main__':
113 sys.exit(main(sys.argv))
Definition: main.py:1
def print(*args, **kwargs)
Definition: run_tests.py:49
def GuessOS()
Definition: utils.py:21
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741