Skip to content

Commit 089d6fc

Browse files
liamappelbecommit-bot@chromium.org
authored andcommitted
[vm] Build a runnable Fuchsia package containing Dart
Everything in the build/fuchsia director (except for tests.cmx) was copied and modified from: https://fuchsia.googlesource.com/samples/+/refs/heads/master/build This doesn't include any tests yet, but its runnable on the emulator. Change-Id: Id64ae71062447c789ca4d10ed3a4a09e0a6d7b99 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152589 Reviewed-by: Siva Annamalai <[email protected]> Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Liam Appelbe <[email protected]>
1 parent 57cf6eb commit 089d6fc

File tree

14 files changed

+1095
-0
lines changed

14 files changed

+1095
-0
lines changed

BUILD.gn

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,21 @@ group("observatory_archive") {
149149
group("compressed_observatory_archive") {
150150
deps = [ "runtime/observatory:copy_compressed_observatory_archive" ]
151151
}
152+
153+
if (is_fuchsia) {
154+
import("third_party/fuchsia/sdk/linux/build/component.gni")
155+
import("third_party/fuchsia/sdk/linux/build/package.gni")
156+
157+
fuchsia_component("dart_sdk_fuchsia_test_component") {
158+
testonly = true
159+
data_deps = [
160+
"runtime/bin:dart",
161+
]
162+
manifest = "build/fuchsia/tests.cmx"
163+
}
164+
165+
fuchsia_package("dart_sdk_fuchsia_test_package") {
166+
testonly = true
167+
deps = [ ":dart_sdk_fuchsia_test_component" ]
168+
}
169+
}

build/config/BUILDCONFIG.gn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ if (is_posix) {
258258
[ "//build/config/gcc:symbol_visibility_hidden" ]
259259
}
260260
}
261+
if (is_fuchsia) {
262+
_native_compiler_configs += [
263+
"//third_party/fuchsia/sdk/linux/build/config:compiler",
264+
"//third_party/fuchsia/sdk/linux/build/config:runtime_library",
265+
]
266+
}
261267

262268
if (is_linux) {
263269
_native_compiler_configs += [ "//build/config/linux:sdk" ]

build/fuchsia/BUILD.gn

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2019 The Fuchsia Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
config("compiler_defaults") {
6+
if (current_os == "linux") {
7+
cflags = [
8+
"-fPIC",
9+
"-pthread",
10+
]
11+
}
12+
}
13+
14+
config("executable_ldconfig") {
15+
ldflags = [
16+
"-Wl,-rpath=\$ORIGIN/",
17+
"-Wl,-rpath-link=",
18+
]
19+
}

build/fuchsia/BUILDCONFIG.gn

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Copyright 2019 The Fuchsia Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
if (target_os == "") {
6+
target_os = host_os
7+
}
8+
9+
if (target_cpu == "") {
10+
target_cpu = host_cpu
11+
}
12+
13+
if (current_cpu == "") {
14+
current_cpu = target_cpu
15+
}
16+
if (current_os == "") {
17+
current_os = target_os
18+
}
19+
20+
is_fuchsia = current_os == "fuchsia"
21+
is_linux = current_os == "linux"
22+
23+
declare_args() {
24+
is_debug = true
25+
}
26+
27+
# Set the host_toolchain
28+
declare_args() {
29+
host_toolchain = ""
30+
}
31+
32+
# ==============================================================================
33+
# TOOLCHAIN SETUP
34+
# ==============================================================================
35+
#
36+
# Here we set the default toolchain, as well as the variable host_toolchain
37+
# which will identify the toolchain corresponding to the local system when
38+
# doing cross-compiles. When not cross-compiling, this will be the same as the
39+
# default toolchain.
40+
#
41+
# We do this before anything else to make sure we complain about any
42+
# unsupported os/cpu combinations as early as possible.
43+
44+
if (host_toolchain == "") {
45+
# This should only happen in the top-level context.
46+
# In a specific toolchain context, the toolchain_args()
47+
# block should have propagated a value down.
48+
49+
if (host_os == "linux") {
50+
host_toolchain = "//build/fuchsia/toolchain/linux:clang_$host_cpu"
51+
} else if (host_os == "mac") {
52+
host_toolchain = "//build/fuchsia/toolchain/mac:$host_cpu"
53+
} else {
54+
assert(false, "Unsupported host_os: $host_os")
55+
}
56+
}
57+
58+
# Set toolchain based on target_os and target_cpu
59+
_default_toolchain = ""
60+
61+
if (target_os == "linux") {
62+
_default_toolchain = "//build/fuchsia/toolchain/linux:clang_$target_cpu"
63+
} else if (target_os == "fuchsia") {
64+
_default_toolchain = "//build/fuchsia/toolchain/fuchsia:$target_cpu"
65+
} else {
66+
assert(false, "Unsupported target_os: $target_os")
67+
}
68+
69+
set_default_toolchain(_default_toolchain)
70+
71+
# Set compiler defaults
72+
73+
# Holds all configs used for running the compiler.
74+
default_compiler_configs = [
75+
"//build/fuchsia:compiler_defaults",
76+
"//build/fuchsia/config/compiler:assembler_debug_dir",
77+
"//build/fuchsia/config/compiler:compiler",
78+
"//build/fuchsia/config/compiler:compiler_arm_fpu",
79+
"//build/fuchsia/config/compiler:c++",
80+
"//build/fuchsia/config/compiler:default_include_dirs",
81+
"//build/fuchsia/config/compiler:default_optimization",
82+
"//build/fuchsia/config/compiler:default_symbols",
83+
"//build/fuchsia/config/compiler:no_exceptions",
84+
"//build/fuchsia/config/compiler:no_rtti",
85+
"//build/fuchsia/config/compiler:runtime_library",
86+
"//build/fuchsia/config/compiler:extra_warnings",
87+
"//build/fuchsia/config/compiler:symbol_visibility_hidden",
88+
]
89+
90+
if (is_fuchsia) {
91+
default_compiler_configs += [
92+
"//third_party/fuchsia-sdk/build/config:compiler",
93+
"//third_party/fuchsia-sdk/build/config:runtime_library",
94+
]
95+
96+
# these are additional flags recommended
97+
default_compiler_configs += [ "//build/fuchsia/config/compiler:default_stack_frames" ]
98+
}
99+
100+
# Debug/release-related defines.
101+
if (is_debug) {
102+
default_compiler_configs += [ "//build/fuchsia/config:debug" ]
103+
} else {
104+
default_compiler_configs += [ "//build/fuchsia/config:release" ]
105+
}
106+
107+
# Static libraries and source sets use only the compiler ones.
108+
set_defaults("static_library") {
109+
configs = default_compiler_configs
110+
}
111+
set_defaults("source_set") {
112+
configs = default_compiler_configs
113+
}
114+
115+
# Executable defaults.
116+
default_executable_configs = default_compiler_configs + [
117+
"//build/fuchsia:executable_ldconfig",
118+
"//build/fuchsia/config:default_libs",
119+
]
120+
set_defaults("executable") {
121+
configs = default_executable_configs
122+
}
123+
124+
# Shared library and loadable module defaults (also for components in component
125+
# mode).
126+
default_shared_library_configs =
127+
default_compiler_configs + [ "//build/fuchsia/config:default_libs" ]
128+
129+
set_defaults("shared_library") {
130+
configs = default_shared_library_configs
131+
}
132+
set_defaults("loadable_module") {
133+
configs = default_shared_library_configs
134+
}
135+
136+
if (is_fuchsia) {
137+
# Sets default dependencies for executable and shared_library targets.
138+
#
139+
# Variables
140+
# no_default_deps: If true, no standard dependencies will be added.
141+
foreach(_target_type,
142+
[
143+
"executable",
144+
"shared_library",
145+
]) {
146+
template(_target_type) {
147+
target(_target_type, target_name) {
148+
forward_variables_from(invoker, "*", [ "no_default_deps" ])
149+
if (!defined(deps)) {
150+
deps = []
151+
}
152+
if (!defined(data_deps)) {
153+
data_deps = []
154+
}
155+
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
156+
data_deps += [ "//build/fuchsia/config/clang:c++-runtime-deps" ]
157+
deps += [ "//third_party/fuchsia-sdk/build/config:runtime_library_group" ]
158+
}
159+
}
160+
}
161+
}
162+
}

build/fuchsia/config/BUILD.gn

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2019 The Fuchsia Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# Debug/release ----------------------------------------------------------------
6+
7+
config("debug") {
8+
defines = [
9+
"_DEBUG",
10+
"DYNAMIC_ANNOTATIONS_ENABLED=1",
11+
"WTF_USE_DYNAMIC_ANNOTATIONS=1",
12+
]
13+
14+
if (current_cpu == "x64") {
15+
# Enable libstdc++ debugging facilities to help catch problems early.
16+
defines += [ "_GLIBCXX_DEBUG=1" ]
17+
}
18+
}
19+
20+
config("release") {
21+
defines = [ "NDEBUG" ]
22+
defines += [ "NVALGRIND" ]
23+
defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
24+
}
25+
26+
# Default libraries ------------------------------------------------------------
27+
28+
# This config defines the default libraries applied to all targets.
29+
config("default_libs") {
30+
if (is_linux) {
31+
libs = [
32+
"dl",
33+
"pthread",
34+
"rt",
35+
]
36+
}
37+
}

build/fuchsia/config/clang/BUILD.gn

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2019 The Fuchsia Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("//build/fuchsia/config/clang/clang.gni")
6+
7+
# This adds the runtime deps for C++ for usage when cross compiling.
8+
group("c++-runtime-deps") {
9+
data_deps = [
10+
":clang-runtime-libs",
11+
]
12+
}
13+
14+
copy("clang-runtime-libs") {
15+
if (target_cpu == "arm64") {
16+
arch = "aarch64"
17+
} else if (target_cpu == "x64") {
18+
arch = "x86_64"
19+
}
20+
vendor = "unknown"
21+
22+
sys = target_os
23+
sources = [
24+
"${clang_base_path}/lib/${arch}-${vendor}-${sys}/c++/libc++.so.2.0",
25+
"${clang_base_path}/lib/${arch}-${vendor}-${sys}/c++/libc++abi.so.1.0",
26+
"${clang_base_path}/lib/${arch}-${vendor}-${sys}/c++/libunwind.so.1.0",
27+
]
28+
outputs = [
29+
"${root_out_dir}/lib/{{source_name_part}}",
30+
]
31+
}

build/fuchsia/config/clang/clang.gni

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2019 The Fuchsia Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
declare_args() {
6+
clang_base_path = "//buildtools/linux-x64/clang"
7+
}

0 commit comments

Comments
 (0)