Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
tools
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
6
import
argparse
7
import
os
8
import
subprocess
9
import
sys
10
import
utils
11
12
HOST_OS =
utils.GuessOS
()
13
SCRIPT_DIR = os.path.dirname(sys.argv[0])
14
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR,
'..'
))
15
DART_DISABLE_BUILDFILES =
"DART_DISABLE_BUILDFILES"
16
17
18
def
DisableBuildfiles
():
19
return
DART_DISABLE_BUILDFILES
in
os.environ
20
21
22
def
Execute
(args):
23
process = subprocess.Popen(args, cwd=DART_ROOT)
24
process.wait()
25
return
process.returncode
26
27
28
def
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
47
def
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
64
def
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
79
def
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
89
def
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
104
def
main
(argv):
105
# Check the environment and become a no-op if directed.
106
if
DisableBuildfiles
():
107
return
0
108
options =
ParseArgs
(argv)
109
RunGn
(options)
110
111
112
if
__name__ ==
'__main__'
:
113
sys.exit(
main
(sys.argv))
print
void print(void *str)
Definition
bridge.cpp:126
generate_buildfiles.RunAndroidGn
RunAndroidGn(options)
Definition
generate_buildfiles.py:28
generate_buildfiles.Execute
Execute(args)
Definition
generate_buildfiles.py:22
generate_buildfiles.RunCrossGn
RunCrossGn(options)
Definition
generate_buildfiles.py:47
generate_buildfiles.DisableBuildfiles
DisableBuildfiles()
Definition
generate_buildfiles.py:18
generate_buildfiles.RunHostGn
RunHostGn(options)
Definition
generate_buildfiles.py:64
generate_buildfiles.ParseArgs
ParseArgs(args)
Definition
generate_buildfiles.py:89
generate_buildfiles.RunGn
RunGn(options)
Definition
generate_buildfiles.py:79
main
Definition
main.py:1
utils.GuessOS
GuessOS()
Definition
utils.py:21
Generated on Fri Apr 26 2024 06:15:22 for Flutter Engine by
1.9.8