Skip to content

Commit 81e428f

Browse files
committed
[infra] Assembles the SDK using GN rather than create_sdk.py
This has a few advantages: - We can track dependencies more precisely - ninja can assemble things in parallel as they're ready rather than sequentially all at once. - It is easier to customize SDKs depending on target platform, e.g. Fuchsia. This CL also has a number of cleanups: - Defining is_fuchsia and is_fuchsia host so we don't always have to check - Piping through toolchain overrides in more places - Fixing bugs in copy_tree.py, not using list_files.py, which is broken on Windows related #29558 [email protected] Review-Url: https://codereview.chromium.org/2848943003 .
1 parent bf15116 commit 81e428f

File tree

15 files changed

+902
-772
lines changed

15 files changed

+902
-772
lines changed

BUILD.gn

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# This target will be built if no target is specified when invoking ninja.
66
group("default") {
7-
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
7+
if (is_fuchsia || is_fuchsia_host) {
88
# Fuchsia has run_vm_tests marked testonly.
99
testonly = true
1010
}
@@ -14,7 +14,7 @@ group("default") {
1414
}
1515

1616
group("most") {
17-
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
17+
if (is_fuchsia || is_fuchsia_host) {
1818
# Fuchsia has run_vm_tests marked testonly.
1919
testonly = true
2020
}
@@ -30,7 +30,7 @@ group("most") {
3030
}
3131

3232
group("runtime") {
33-
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
33+
if (is_fuchsia || is_fuchsia_host) {
3434
# Fuchsia has run_vm_tests marked testonly.
3535
testonly = true
3636
}
@@ -46,7 +46,7 @@ group("runtime") {
4646
}
4747

4848
group("runtime_kernel") {
49-
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
49+
if (is_fuchsia || is_fuchsia_host) {
5050
# Fuchsia has run_vm_tests marked testonly.
5151
testonly = true
5252
}
@@ -121,85 +121,83 @@ group("samples") {
121121
# The rules below build a qemu Fuchsia OS image that includes the Dart tree
122122
# under /system/test/dart. Building this image is gated by the GN argument
123123
# 'dart_build_fuchsia_test_image' because building the image is slow.
124-
if (defined(is_fuchsia) && is_fuchsia) {
124+
if (is_fuchsia) {
125125
declare_args() {
126126
dart_build_fuchsia_test_image = false
127127
}
128128

129-
if (dart_build_fuchsia_test_image) {
130-
action("generate_dart_test_manifest") {
131-
testonly = true
132-
133-
deps = [
134-
"//packages/gn:mkbootfs",
135-
]
136-
137-
output_prefix = "$target_gen_dir/dart_test_tree"
138-
outputs = [
139-
"$output_prefix.manifest",
140-
]
141-
142-
mode = "release"
143-
if (is_debug) {
144-
mode = "debug"
145-
}
146-
147-
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
148-
user_manifest = "$mkbootfs_gen/user.bootfs.manifest"
149-
150-
script = "tools/gen_fuchsia_test_manifest.py"
151-
args = [
152-
"-m",
153-
mode,
154-
"-u",
155-
rebase_path(user_manifest),
156-
"-o",
157-
rebase_path(output_prefix),
158-
]
129+
action("generate_dart_test_manifest") {
130+
testonly = true
131+
132+
deps = [
133+
"//packages/gn:mkbootfs",
134+
]
135+
136+
output_prefix = "$target_gen_dir/dart_test_tree"
137+
outputs = [
138+
"$output_prefix.manifest",
139+
]
140+
141+
mode = "release"
142+
if (is_debug) {
143+
mode = "debug"
159144
}
160145

161-
action("generate_dart_test_image") {
162-
testonly = true
163-
deps = [
164-
":generate_dart_test_manifest",
165-
"runtime/bin:dart",
166-
"runtime/bin:process_test",
167-
"runtime/bin:run_vm_tests",
168-
]
169-
170-
# Compute path to magenta bootdata.bin
171-
if (current_cpu == "arm64") {
172-
magenta_bootdata =
173-
"//out/build-magenta/build-magenta-qemu-arm64/bootdata.bin"
174-
} else if (current_cpu == "x64") {
175-
magenta_bootdata =
176-
"//out/build-magenta/build-magenta-pc-x86-64/bootdata.bin"
177-
} else {
178-
assert(false, "unable to determine path to magenta's bootdata.bin")
179-
}
180-
181-
input = "$target_gen_dir/dart_test_tree.manifest"
182-
inputs = [
183-
magenta_bootdata,
184-
input,
185-
]
186-
187-
output = "$root_out_dir/dart_test_tree.bin"
188-
outputs = [
189-
output,
190-
]
191-
192-
script = "//packages/gn/make_bootfs.py"
193-
args = [
194-
"--manifest",
195-
rebase_path(input),
196-
"--output-file",
197-
rebase_path(output),
198-
"--build-id-map",
199-
rebase_path("$target_gen_dir/build_id_map"),
200-
"--pre-binaries",
201-
rebase_path(magenta_bootdata),
202-
]
146+
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
147+
user_manifest = "$mkbootfs_gen/user.bootfs.manifest"
148+
149+
script = "tools/gen_fuchsia_test_manifest.py"
150+
args = [
151+
"-m",
152+
mode,
153+
"-u",
154+
rebase_path(user_manifest),
155+
"-o",
156+
rebase_path(output_prefix),
157+
]
158+
}
159+
160+
action("generate_dart_test_image") {
161+
testonly = true
162+
deps = [
163+
":generate_dart_test_manifest",
164+
"runtime/bin:dart",
165+
"runtime/bin:process_test",
166+
"runtime/bin:run_vm_tests",
167+
]
168+
169+
# Compute path to magenta bootdata.bin
170+
if (current_cpu == "arm64") {
171+
magenta_bootdata =
172+
"//out/build-magenta/build-magenta-qemu-arm64/bootdata.bin"
173+
} else if (current_cpu == "x64") {
174+
magenta_bootdata =
175+
"//out/build-magenta/build-magenta-pc-x86-64/bootdata.bin"
176+
} else {
177+
assert(false, "unable to determine path to magenta's bootdata.bin")
203178
}
179+
180+
input = "$target_gen_dir/dart_test_tree.manifest"
181+
inputs = [
182+
magenta_bootdata,
183+
input,
184+
]
185+
186+
output = "$root_out_dir/dart_test_tree.bin"
187+
outputs = [
188+
output,
189+
]
190+
191+
script = "//packages/gn/make_bootfs.py"
192+
args = [
193+
"--manifest",
194+
rebase_path(input),
195+
"--output-file",
196+
rebase_path(output),
197+
"--build-id-map",
198+
rebase_path("$target_gen_dir/build_id_map"),
199+
"--pre-binaries",
200+
rebase_path(magenta_bootdata),
201+
]
204202
}
205203
}

build/config/BUILDCONFIG.gn

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ declare_args() {
153153
if (current_os == "win") {
154154
is_android = false
155155
is_chromeos = false
156+
is_fuchsia = false
157+
is_fuchsia_host = false
156158
is_ios = false
157159
is_linux = false
158160
is_mac = false
@@ -162,6 +164,8 @@ if (current_os == "win") {
162164
} else if (current_os == "mac") {
163165
is_android = false
164166
is_chromeos = false
167+
is_fuchsia = false
168+
is_fuchsia_host = false
165169
is_ios = false
166170
is_linux = false
167171
is_mac = true
@@ -171,6 +175,8 @@ if (current_os == "win") {
171175
} else if (current_os == "android") {
172176
is_android = true
173177
is_chromeos = false
178+
is_fuchsia = false
179+
is_fuchsia_host = false
174180
is_ios = false
175181
is_linux = false
176182
is_mac = false
@@ -180,6 +186,8 @@ if (current_os == "win") {
180186
} else if (current_os == "linux") {
181187
is_android = false
182188
is_chromeos = false
189+
is_fuchsia = false
190+
is_fuchsia_host = false
183191
is_ios = false
184192
is_linux = true
185193
is_mac = false
@@ -227,9 +235,7 @@ if (is_win) {
227235
]
228236
}
229237
if (is_posix) {
230-
_native_compiler_configs += [
231-
"//build/config/gcc:no_exceptions",
232-
]
238+
_native_compiler_configs += [ "//build/config/gcc:no_exceptions" ]
233239
}
234240

235241
if (is_linux) {

build/config/win/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ config("common_linker_setup") {
7373
# exceeds maximum allowable size (80000000)
7474
# which started happening more regularly after VS2013 Update 4.
7575
"/maxilksize:2147483647",
76+
77+
# Force the creation of a .lib file for all executable() targets.
78+
"/EXPORT:main",
7679
]
7780

7881
# ASLR makes debugging with windbg difficult because Chrome.exe and

build/copy_tree.gni

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
_dart_root = rebase_path("..")
6+
7+
# copy_tree() copies a directory tree rooted at `source` to `dest`, which should
8+
# be somewhere under $root_out_dir.
9+
#
10+
# Optional parameters:
11+
# exclude - A comma separated list that is passed to shutil.ignore_patterns()
12+
# in tools/copy_tree.py.
13+
template("copy_tree") {
14+
assert(defined(invoker.source), "copy_tree must define 'source'")
15+
assert(defined(invoker.dest), "copy_tree must define 'dest'")
16+
source = invoker.source
17+
dest = invoker.dest
18+
action(target_name) {
19+
if (defined(invoker.visibility)) {
20+
visibility = invoker.visibility
21+
}
22+
23+
deps = []
24+
if (defined(invoker.deps)) {
25+
deps += invoker.deps
26+
}
27+
28+
common_args = [
29+
"--from",
30+
rebase_path(source),
31+
"--to",
32+
rebase_path(dest),
33+
]
34+
if (defined(invoker.exclude)) {
35+
common_args += [
36+
"--exclude",
37+
invoker.exclude,
38+
]
39+
}
40+
41+
dry_run_args = common_args + [ "--dry-run" ]
42+
input_files = exec_script("$_dart_root/tools/copy_tree.py",
43+
dry_run_args,
44+
"list lines")
45+
inputs = input_files
46+
relative_files = rebase_path(input_files, rebase_path(source))
47+
48+
output_files = []
49+
foreach(input, relative_files) {
50+
output_files += [ "$dest/$input" ]
51+
}
52+
53+
outputs = output_files
54+
script = "$_dart_root/tools/copy_tree.py"
55+
args = common_args
56+
}
57+
}

build/toolchain/gcc_toolchain.gni

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ concurrent_links = exec_script("get_concurrent_links.py", [], "value")
3838
# - is_clang
3939
# - strip
4040
# Location of the strip executable. When specified, strip will be run on
41-
# all shared libraries and executables as they are built. The pre-stripped
42-
# artifacts will be put in lib.stripped/ and exe.stripped/.
41+
# all executables as they are built. The stripped artifacts will be put in
42+
# exe.stripped/.
4343
template("gcc_toolchain") {
4444
toolchain(target_name) {
4545
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
@@ -192,17 +192,16 @@ template("gcc_toolchain") {
192192
exename = "{{target_output_name}}{{output_extension}}"
193193
outfile = "{{root_out_dir}}/$exename"
194194
rspfile = "$outfile.rsp"
195-
unstripped_outfile = outfile
196195

197196
if (defined(invoker.strip)) {
198-
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
197+
stripped_outfile = "{{root_out_dir}}/exe.stripped/$exename"
199198
}
200199

201-
command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
200+
command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
202201
if (defined(invoker.strip)) {
203202
strip = invoker.strip
204203
strip_command =
205-
"${strip} --strip-unneeded -o $outfile $unstripped_outfile"
204+
"${strip} --strip-unneeded -o $stripped_outfile $outfile"
206205
command += " && " + strip_command
207206
}
208207
if (defined(invoker.postlink)) {
@@ -213,8 +212,8 @@ template("gcc_toolchain") {
213212
outputs = [
214213
outfile,
215214
]
216-
if (outfile != unstripped_outfile) {
217-
outputs += [ unstripped_outfile ]
215+
if (defined(invoker.strip)) {
216+
outputs += [ stripped_outfile ]
218217
}
219218
if (defined(invoker.link_outputs)) {
220219
outputs += invoker.link_outputs

0 commit comments

Comments
 (0)