[vm] Add tests and packages to the Fuchsia package

Also, delete some unnecessary files from build/fuchsia, and add an async
dispatcher to os_fuchsia.

Change-Id: I477e58d54330e83b2c7b6463395a1212707f8ab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154162
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
This commit is contained in:
Liam Appelbe 2020-07-15 20:44:06 +00:00 committed by commit-bot@chromium.org
parent a2edb7976c
commit 6fc75e6a2b
14 changed files with 132 additions and 1034 deletions

View file

@ -156,10 +156,35 @@ if (is_fuchsia) {
fuchsia_component("dart_sdk_fuchsia_test_component") {
testonly = true
data_deps = [
"runtime/bin:dart",
data_deps = [ "runtime/bin:dart" ]
manifest = "build/fuchsia/dart.cmx"
resource_files = [
".packages",
]
manifest = "build/fuchsia/tests.cmx"
resource_dirs = [
"tests/standalone",
"pkg/async_helper",
"pkg/expect",
"pkg/meta",
"pkg/smith",
"third_party/pkg/args",
"third_party/pkg/async",
"third_party/pkg/collection",
"third_party/pkg/path",
"third_party/pkg/pool",
"third_party/pkg/stack_trace",
]
resources = []
foreach(file, resource_files) {
resources += [{
path = file
dest = "data/" + file
}]
}
resources += exec_script(
"tools/fuchsia/find_resources.py", resource_dirs, "json")
}
fuchsia_package("dart_sdk_fuchsia_test_package") {

View file

@ -1,19 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
config("compiler_defaults") {
if (current_os == "linux") {
cflags = [
"-fPIC",
"-pthread",
]
}
}
config("executable_ldconfig") {
ldflags = [
"-Wl,-rpath=\$ORIGIN/",
"-Wl,-rpath-link=",
]
}

View file

@ -1,162 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if (target_os == "") {
target_os = host_os
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_cpu == "") {
current_cpu = target_cpu
}
if (current_os == "") {
current_os = target_os
}
is_fuchsia = current_os == "fuchsia"
is_linux = current_os == "linux"
declare_args() {
is_debug = true
}
# Set the host_toolchain
declare_args() {
host_toolchain = ""
}
# ==============================================================================
# TOOLCHAIN SETUP
# ==============================================================================
#
# Here we set the default toolchain, as well as the variable host_toolchain
# which will identify the toolchain corresponding to the local system when
# doing cross-compiles. When not cross-compiling, this will be the same as the
# default toolchain.
#
# We do this before anything else to make sure we complain about any
# unsupported os/cpu combinations as early as possible.
if (host_toolchain == "") {
# This should only happen in the top-level context.
# In a specific toolchain context, the toolchain_args()
# block should have propagated a value down.
if (host_os == "linux") {
host_toolchain = "//build/fuchsia/toolchain/linux:clang_$host_cpu"
} else if (host_os == "mac") {
host_toolchain = "//build/fuchsia/toolchain/mac:$host_cpu"
} else {
assert(false, "Unsupported host_os: $host_os")
}
}
# Set toolchain based on target_os and target_cpu
_default_toolchain = ""
if (target_os == "linux") {
_default_toolchain = "//build/fuchsia/toolchain/linux:clang_$target_cpu"
} else if (target_os == "fuchsia") {
_default_toolchain = "//build/fuchsia/toolchain/fuchsia:$target_cpu"
} else {
assert(false, "Unsupported target_os: $target_os")
}
set_default_toolchain(_default_toolchain)
# Set compiler defaults
# Holds all configs used for running the compiler.
default_compiler_configs = [
"//build/fuchsia:compiler_defaults",
"//build/fuchsia/config/compiler:assembler_debug_dir",
"//build/fuchsia/config/compiler:compiler",
"//build/fuchsia/config/compiler:compiler_arm_fpu",
"//build/fuchsia/config/compiler:c++",
"//build/fuchsia/config/compiler:default_include_dirs",
"//build/fuchsia/config/compiler:default_optimization",
"//build/fuchsia/config/compiler:default_symbols",
"//build/fuchsia/config/compiler:no_exceptions",
"//build/fuchsia/config/compiler:no_rtti",
"//build/fuchsia/config/compiler:runtime_library",
"//build/fuchsia/config/compiler:extra_warnings",
"//build/fuchsia/config/compiler:symbol_visibility_hidden",
]
if (is_fuchsia) {
default_compiler_configs += [
"//third_party/fuchsia-sdk/build/config:compiler",
"//third_party/fuchsia-sdk/build/config:runtime_library",
]
# these are additional flags recommended
default_compiler_configs += [ "//build/fuchsia/config/compiler:default_stack_frames" ]
}
# Debug/release-related defines.
if (is_debug) {
default_compiler_configs += [ "//build/fuchsia/config:debug" ]
} else {
default_compiler_configs += [ "//build/fuchsia/config:release" ]
}
# Static libraries and source sets use only the compiler ones.
set_defaults("static_library") {
configs = default_compiler_configs
}
set_defaults("source_set") {
configs = default_compiler_configs
}
# Executable defaults.
default_executable_configs = default_compiler_configs + [
"//build/fuchsia:executable_ldconfig",
"//build/fuchsia/config:default_libs",
]
set_defaults("executable") {
configs = default_executable_configs
}
# Shared library and loadable module defaults (also for components in component
# mode).
default_shared_library_configs =
default_compiler_configs + [ "//build/fuchsia/config:default_libs" ]
set_defaults("shared_library") {
configs = default_shared_library_configs
}
set_defaults("loadable_module") {
configs = default_shared_library_configs
}
if (is_fuchsia) {
# Sets default dependencies for executable and shared_library targets.
#
# Variables
# no_default_deps: If true, no standard dependencies will be added.
foreach(_target_type,
[
"executable",
"shared_library",
]) {
template(_target_type) {
target(_target_type, target_name) {
forward_variables_from(invoker, "*", [ "no_default_deps" ])
if (!defined(deps)) {
deps = []
}
if (!defined(data_deps)) {
data_deps = []
}
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
data_deps += [ "//build/fuchsia/config/clang:c++-runtime-deps" ]
deps += [ "//third_party/fuchsia-sdk/build/config:runtime_library_group" ]
}
}
}
}
}

View file

@ -1,37 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Debug/release ----------------------------------------------------------------
config("debug") {
defines = [
"_DEBUG",
"DYNAMIC_ANNOTATIONS_ENABLED=1",
"WTF_USE_DYNAMIC_ANNOTATIONS=1",
]
if (current_cpu == "x64") {
# Enable libstdc++ debugging facilities to help catch problems early.
defines += [ "_GLIBCXX_DEBUG=1" ]
}
}
config("release") {
defines = [ "NDEBUG" ]
defines += [ "NVALGRIND" ]
defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
}
# Default libraries ------------------------------------------------------------
# This config defines the default libraries applied to all targets.
config("default_libs") {
if (is_linux) {
libs = [
"dl",
"pthread",
"rt",
]
}
}

View file

@ -1,235 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# compiler ---------------------------------------------------------------------
#
# Base compiler configuration.
#
# See also "runtime_library" below for related stuff and a discussion about
# where stuff should go. Put warning related stuff in the "warnings" config.
import("//build/fuchsia/config/clang/clang.gni")
config("compiler") {
asmflags = []
cflags = []
cflags_c = []
cflags_cc = []
cflags_objc = []
cflags_objcc = []
ldflags = []
defines = []
configs = []
# System-specific flags. If your compiler flags apply to one of the
# categories here, add it to the associated file to keep this shared config
# smaller.
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
cflags += [ "-fcolor-diagnostics" ]
cflags += [ "-fmerge-all-constants" ]
cflags += [ "-fcomplete-member-pointers" ]
cflags += [
"-Xclang",
"-mllvm",
"-Xclang",
"-instcombine-lower-dbg-declare=0",
]
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
ldflags += [
"-Wl,-z,noexecstack",
"-Wl,-z,relro",
]
ldflags += [ "-Wl,-z,now" ]
# Compiler instrumentation can introduce dependencies in DSOs to symbols in
# the executable they are loaded into, so they are unresolved at link-time.
ldflags += [
"-Wl,-z,defs",
"-Wl,--as-needed",
]
if (is_debug) {
# Allow comparing the address of references and 'this' against 0
# in debug builds. Technically, these can never be null in
# well-defined C/C++ and Clang can optimize such checks away in
# release builds, but they may be used in asserts in debug builds.
cflags_cc += [
"-Wno-undefined-bool-conversion",
"-Wno-tautological-undefined-compare",
]
}
cflags_c += [ "-std=c11" ]
cflags_cc += [ "-std=c++14" ]
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
}
config("c++") {
cflags_cc = [ "-isystem" + rebase_path(clang_base_path, root_build_dir) ]
}
config("assembler_debug_dir") {
asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
}
# This config causes functions not to be automatically exported from shared
# libraries. By default, all symbols are exported but this means there are
# lots of exports that slow everything down. In general we explicitly mark
# which functions we want to export from components.
#
# Some third_party code assumes all functions are exported so this is separated
# into its own config so such libraries can remove this config to make symbols
# public again.
#
# See http://gcc.gnu.org/wiki/Visibility
config("symbol_visibility_hidden") {
cflags = [ "-fvisibility=hidden" ]
cflags_cc = [ "-fvisibility-inlines-hidden" ]
cflags_objcc = cflags_cc
}
config("compiler_arm_fpu") {
if (current_cpu == "arm") {
cflags = [ "-mfpu=$arm_fpu" ]
asmflags = cflags
}
}
# export_dynamic ---------------------------------------------------------------
#
# Ensures all exported symbols are added to the dynamic symbol table. This is
# necessary to expose Chrome's custom operator new() and operator delete() (and
# other memory-related symbols) to libraries. Otherwise, they might
# (de)allocate memory on a different heap, which would spell trouble if pointers
# to heap-allocated memory are passed over shared library boundaries.
config("export_dynamic") {
}
# default_include_dirs ---------------------------------------------------------
#
# This is a separate config so that third_party code (which would not use the
# source root and might have conflicting versions of some headers) can remove
# this and specify their own include paths.
config("default_include_dirs") {
include_dirs = [
"//",
root_gen_dir,
]
}
config("default_stack_frames") {
cflags = [ "-fomit-frame-pointer" ]
}
# The default optimization applied to all targets. This will be equivalent to
# either "optimize" or "no_optimize", depending on the build flags.
config("default_optimization") {
if (is_debug) {
configs = [ ":no_optimize" ]
} else {
configs = [ ":optimize" ]
}
}
config("optimize") {
cflags = [
"-O2",
"-fno-ident",
"-fdata-sections",
"-ffunction-sections",
]
ldflags = [
"-Wl,-O2",
"-Wl,--gc-sections",
]
}
# Turn off optimizations.
config("no_optimize") {
cflags = [ "-O0" ]
ldflags = []
}
# Full symbols.
config("symbols") {
cflags = []
if (current_cpu == "arm") {
cflags += [ "-gdwarf-3" ]
}
cflags += [ "-g2" ]
asmflags = cflags
ldflags = []
cflags += [ "-ggnu-pubnames" ]
}
# No symbols.
config("no_symbols") {
cflags = [ "-g0" ]
asmflags = cflags
}
# Default symbols.
config("default_symbols") {
if (is_debug) {
configs = [ ":symbols" ]
} else {
configs = [ ":no_symbols" ]
}
}
config("no_exceptions") {
cflags_cc = [ "-fno-exceptions" ]
cflags_objcc = cflags_cc
}
config("exceptions") {
cflags_cc = [ "-fexceptions" ]
cflags_objcc = cflags_cc
}
config("no_rtti") {
cflags_cc = [ "-fno-rtti" ]
cflags_objcc = cflags_cc
}
config("rtti") {
cflags_cc = [ "-frtti" ]
cflags_objcc = cflags_cc
}
config("runtime_library") {
libs = [ "pthread" ]
}
# Enables some extra Clang-specific warnings. Some third-party code won't
# compile with these so may want to remove this config.
config("extra_warnings") {
cflags = [
"-Wheader-hygiene",
# Warns when a const char[] is converted to bool.
"-Wstring-conversion",
"-Wtautological-overlap-compare",
]
}
# Settings for executables.
config("executable_config") {
configs = []
ldflags = [ "-pie" ]
ldflags += [ "-Wl,--disable-new-dtags" ]
}

27
build/fuchsia/dart.cmx Normal file
View file

@ -0,0 +1,27 @@
{
"program": {
"binary": "exe.stripped/dart"
},
"sandbox": {
"features": [
"config-data",
"deprecated-ambient-replace-as-executable",
"root-ssl-certificates",
"isolated-cache-storage",
"isolated-persistent-storage"
],
"services": [
"fuchsia.deprecatedtimezone.Timezone",
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReporter",
"fuchsia.intl.PropertyProvider",
"fuchsia.logger.LogSink",
"fuchsia.net.NameLookup",
"fuchsia.netstack.Netstack",
"fuchsia.posix.socket.Provider",
"fuchsia.sysmem.Allocator",
"fuchsia.timezone.Timezone",
"fuchsia.tracing.provider.Registry"
]
}
}

View file

@ -1,40 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# ==============================================================================
# TEST SETUP
# ==============================================================================
# Define a test as an executable with the "testonly" flag
# set.
# Variable:
template("test") {
executable(target_name + "_exe") {
forward_variables_from(invoker, "*")
if (!defined(deps)) {
deps = []
}
testonly = true
metadata = {
if (current_toolchain == default_toolchain) {
host_test_name = [ "./" + target_name + "_exe" ]
} else {
host_test_name = [ get_label_info(current_toolchain, "name") + "/" +
target_name + "_exe" ]
}
}
}
group(target_name) {
testonly = true
deps = [
":" + target_name + "_exe($host_toolchain)",
]
}
}
# Test defaults.
set_defaults("test") {
configs = default_executable_configs
}

View file

@ -1,5 +0,0 @@
{
"program": {
"binary": "exe.stripped/dart"
}
}

View file

@ -1,473 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/fuchsia/config/clang/clang.gni")
# This template defines a toolchain.
#
# It requires the following variables specifying the executables to run:
# - ar
# - cc
# - cxx
# - ld
#
# Optional parameters that control the tools:
#
# - extra_cflags
# Extra flags to be appended when compiling C files (but not C++ files).
# - extra_cppflags
# Extra flags to be appended when compiling both C and C++ files. "CPP"
# stands for "C PreProcessor" in this context, although it can be
# used for non-preprocessor flags as well. Not to be confused with
# "CXX" (which follows).
# - extra_cxxflags
# Extra flags to be appended when compiling C++ files (but not C files).
# - extra_asmflags
# Extra flags to be appended when compiling assembly.
# - extra_ldflags
# Extra flags to be appended when linking
#
# - libs_section_prefix
# - libs_section_postfix
# The contents of these strings, if specified, will be placed around
# the libs section of the linker line. It allows one to inject libraries
# at the beginning and end for all targets in a toolchain.
# - solink_libs_section_prefix
# - solink_libs_section_postfix
# Same as libs_section_{pre,post}fix except used for solink instead of link.
# - link_outputs
# The content of this array, if specified, will be added to the list of
# outputs from the link command. This can be useful in conjunction with
# the post_link parameter.
# - use_unstripped_as_runtime_outputs
# When |strip| is set, mark unstripped executables as runtime deps rather
# than stripped ones.
# - post_link
# The content of this string, if specified, will be run as a separate
# command following the the link command.
# - deps
# Just forwarded to the toolchain definition.
# - executable_extension
# If this string is specified it will be used for the file extension
# for an executable, rather than using no extension; targets will
# still be able to override the extension using the output_extension
# variable.
# - rebuild_define
# The contents of this string, if specified, will be passed as a #define
# to the toolchain. It can be used to force recompiles whenever a
# toolchain is updated.
# - shlib_extension
# If this string is specified it will be used for the file extension
# for a shared library, rather than default value specified in
# toolchain.gni
# - use_strip
# Enable stripping symbols out of binaries. The pre-stripped
# artifacts will be put in lib.unstripped/ and exe.unstripped/.
template("clang_toolchain") {
declare_args() {
shlib_prefix = "lib"
shlib_extension = ".so"
}
params = {
if (defined(invoker.prefix)) {
prefix = invoker.prefix
} else {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
}
if (defined(invoker.ar)) {
ar = invoker.ar
} else {
ar = "${prefix}/llvm-ar"
}
if (defined(invoker.cc)) {
cc = invoker.cc
} else {
cc = "${prefix}/clang"
}
if (defined(invoker.cxx)) {
cxx = invoker.cxx
} else {
cxx = "${prefix}/clang++"
}
if (defined(invoker.ld)) {
ld = invoker.ld
} else {
ld = cxx
}
}
toolchain(target_name) {
assert(defined(params.ar), "clang_toolchain() must specify a \"ar\" value")
assert(defined(params.cc), "clang_toolchain() must specify a \"cc\" value")
assert(defined(params.cxx),
"clang_toolchain() must specify a \"cxx\" value")
assert(defined(params.ld), "clang_toolchain() must specify a \"ld\" value")
# This define changes when the toolchain changes, forcing a rebuild.
# Nothing should ever use this define.
if (defined(invoker.rebuild_define)) {
rebuild_string = "-D" + invoker.rebuild_define + " "
} else {
rebuild_string = ""
}
# GN's syntax can't handle more than one scope dereference at once, like
# "invoker.toolchain_args.foo", so make a temporary to hold the toolchain
# args so we can do "invoker_toolchain_args.foo".
assert(defined(invoker.toolchain_args),
"Toolchains must specify toolchain_args")
invoker_toolchain_args = invoker.toolchain_args
assert(defined(invoker_toolchain_args.current_cpu),
"toolchain_args must specify a current_cpu")
assert(defined(invoker_toolchain_args.current_os),
"toolchain_args must specify a current_os")
# When invoking this toolchain not as the default one, these args will be
# passed to the build. They are ignored when this is the default toolchain.
toolchain_args = {
# Populate toolchain args from the invoker.
forward_variables_from(invoker_toolchain_args, "*")
# The host toolchain value computed by the default toolchain's setup
# needs to be passed through unchanged to all secondary toolchains to
# ensure that it's always the same, regardless of the values that may be
# set on those toolchains.
host_toolchain = host_toolchain
}
compiler_prefix = " "
# Create a distinct variable for "asm", since analysis runs pass # a bunch
# of flags to clang/clang++ that are nonsensical on assembler runs.
asm_prefix = compiler_prefix
cc = compiler_prefix + params.cc
cxx = compiler_prefix + params.cxx
asm = asm_prefix + params.cc
ar = params.ar
ld = params.ld
if (defined(invoker.shlib_extension)) {
default_shlib_extension = invoker.shlib_extension
} else {
default_shlib_extension = shlib_extension
}
if (defined(invoker.default_shlib_subdir)) {
default_shlib_subdir = invoker.default_shlib_subdir
} else {
default_shlib_subdir = ""
}
if (defined(invoker.executable_extension)) {
default_executable_extension = invoker.executable_extension
} else {
default_executable_extension = ""
}
# Bring these into our scope for string interpolation with default values.
if (defined(invoker.libs_section_prefix)) {
libs_section_prefix = invoker.libs_section_prefix
} else {
libs_section_prefix = ""
}
if (defined(invoker.libs_section_postfix)) {
libs_section_postfix = invoker.libs_section_postfix
} else {
libs_section_postfix = ""
}
if (defined(invoker.solink_libs_section_prefix)) {
solink_libs_section_prefix = invoker.solink_libs_section_prefix
} else {
solink_libs_section_prefix = ""
}
if (defined(invoker.solink_libs_section_postfix)) {
solink_libs_section_postfix = invoker.solink_libs_section_postfix
} else {
solink_libs_section_postfix = ""
}
if (defined(invoker.extra_cflags) && invoker.extra_cflags != "") {
extra_cflags = " " + invoker.extra_cflags
} else {
extra_cflags = ""
}
if (defined(invoker.extra_cppflags) && invoker.extra_cppflags != "") {
extra_cppflags = " " + invoker.extra_cppflags
} else {
extra_cppflags = ""
}
if (defined(invoker.extra_cxxflags) && invoker.extra_cxxflags != "") {
extra_cxxflags = " " + invoker.extra_cxxflags
} else {
extra_cxxflags = ""
}
if (defined(invoker.extra_asmflags) && invoker.extra_asmflags != "") {
extra_asmflags = " " + invoker.extra_asmflags
} else {
extra_asmflags = ""
}
if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {
extra_ldflags = " " + invoker.extra_ldflags
} else {
extra_ldflags = ""
}
use_strip = false
if (defined(invoker.use_strip)) {
use_strip = invoker.use_strip
}
if (use_strip) {
if (toolchain_args.current_os == "mac") {
strip = "xcrun strip -Sx"
} else {
strip = "${params.prefix}/llvm-objcopy"
buildidtool =
rebase_path("//buildtools/linux64/buildidtool", root_build_dir)
}
}
# These library switches can apply to all tools below.
lib_switch = "-l"
lib_dir_switch = "-L"
# Object files go in this directory.
object_subdir = "{{target_out_dir}}/{{label_name}}"
tool("cc") {
depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CC {{output}}"
outputs = [ "$object_subdir/{{source_name_part}}.o" ]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs = [ "$object_subdir/{{source_name_part}}.o" ]
}
tool("asm") {
# For clang we can just use the C compiler to compile assembly.
depfile = "{{output}}.d"
command = "$asm -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "ASM {{output}}"
outputs = [ "$object_subdir/{{source_name_part}}.o" ]
}
tool("alink") {
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
command = "\"$ar\" {{arflags}} -r -c -s -D {{output}} @\"$rspfile\""
# Remove the output file first so that ar doesn't try to modify the
# existing file.
command = "rm -f {{output}} && $command"
# Almost all targets build with //build/fuchsia/config/compiler:thin_archive which
# adds -T to arflags.
description = "AR {{output}}"
outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ]
# Shared libraries go in the target out directory by default so we can
# generate different targets with the same name and not have them collide.
default_output_dir = "{{target_out_dir}}"
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
rspfile = sofile + ".rsp"
if (defined(invoker.use_strip)) {
unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
} else {
unstripped_sofile = sofile
}
# These variables are not built into GN but are helpers that
# implement (1) linking to produce a .so, (2) extracting the symbols
# from that file (3) if the extracted list differs from the existing
# .TOC file, overwrite it, otherwise, don't change it.
tocfile = sofile + ".TOC"
link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
command = "$link_command"
if (defined(invoker.use_strip)) {
strip_command = "$strip --strip-all \"$unstripped_sofile\" \"$sofile\""
command += " && " + strip_command
command +=
" && $buildidtool -build-id-dir .build-id" +
" -stamp \"$sofile.build-id.stamp\"" + " -entry \"=$sofile\"" +
" -entry \".debug=$unstripped_sofile\""
}
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
description = "SOLINK $sofile"
# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
default_output_extension = default_shlib_extension
default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
output_prefix = "lib"
# Since the above commands only updates the .TOC file when it changes, ask
# Ninja to check if the timestamp actually changed to know if downstream
# dependencies should be recompiled.
restat = true
# Tell GN about the output files. It will link to the sofile but use the
# tocfile for dependency management.
outputs = [
sofile,
tocfile,
]
if (sofile != unstripped_sofile) {
outputs += [ unstripped_sofile ]
if (defined(invoker.use_unstripped_as_runtime_outputs) &&
invoker.use_unstripped_as_runtime_outputs) {
runtime_outputs = [ unstripped_sofile ]
}
}
if (defined(map_file)) {
outputs += [ map_file ]
}
link_output = sofile
depend_output = tocfile
}
tool("solink_module") {
soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
sofile = "{{output_dir}}/$soname"
rspfile = sofile + ".rsp"
if (defined(invoker.use_strip)) {
unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
} else {
unstripped_sofile = sofile
}
command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
if (defined(invoker.use_strip)) {
strip_command =
"$strip --strip-sections \"$unstripped_sofile\" \"$sofile\""
command += " && " + strip_command
command +=
" && $buildidtool -build-id-dir .build-id" +
" -stamp \"$sofile.build-id.stamp\"" + " -entry \"=$sofile\"" +
" -entry \".debug=$unstripped_sofile\""
}
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
description = "SOLINK_MODULE $sofile"
# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
if (defined(invoker.loadable_module_extension)) {
default_output_extension = invoker.loadable_module_extension
} else {
default_output_extension = default_shlib_extension
}
default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
output_prefix = "lib"
outputs = [ sofile ]
if (sofile != unstripped_sofile) {
outputs += [ unstripped_sofile ]
if (defined(invoker.use_unstripped_as_runtime_outputs) &&
invoker.use_unstripped_as_runtime_outputs) {
runtime_outputs = [ unstripped_sofile ]
}
}
}
tool("link") {
exename = "{{target_output_name}}{{output_extension}}"
outfile = "{{output_dir}}/$exename"
rspfile = "$outfile.rsp"
unstripped_outfile = outfile
# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
default_output_extension = default_executable_extension
default_output_dir = "{{root_out_dir}}"
if (defined(invoker.use_strip)) {
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
}
# Generate a map file to be used for binary size analysis.
# Map file adds ~10% to the link time on a z620.
# With target_os="android", libchrome.so.map.gz is ~20MB.
start_group_flag = "-Wl,--start-group"
end_group_flag = "-Wl,--end-group "
link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag $libs_section_prefix {{libs}} $libs_section_postfix"
command = "$link_command"
if (defined(invoker.use_strip)) {
strip_command =
"$strip --strip-sections \"$unstripped_outfile\" \"$outfile\""
command += " && " + strip_command
command +=
" && $buildidtool -build-id-dir .build-id" +
" -stamp \"$outfile.build-id.stamp\"" + " -entry \"=$outfile\"" +
" -entry \".debug=$unstripped_outfile\""
}
description = "LINK $outfile"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
if (outfile != unstripped_outfile) {
outputs += [ unstripped_outfile ]
}
if (defined(invoker.link_outputs)) {
outputs += invoker.link_outputs
}
if (defined(map_file)) {
outputs += [ map_file ]
}
}
# These two are really entirely generic, but have to be repeated in
# each toolchain because GN doesn't allow a template to be used here.
# See //build/fuchsia/toolchain/toolchain.gni for details.
tool("stamp") {
command = "touch {{output}}"
description = "STAMP {{output}}"
}
tool("copy") {
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
description = "COPY {{source}} {{output}}"
}
forward_variables_from(invoker, [ "deps" ])
}
}

View file

@ -1,39 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/fuchsia/toolchain/clang_toolchain.gni")
# Fuchsia builds using the Clang toolchain, with most parameters common across
# the different target architectures.
template("fuchsia_toolchain") {
clang_toolchain(target_name) {
assert(host_os == "linux" || host_os == "mac")
assert(defined(invoker.toolchain_args),
"toolchain_args must be defined for fuchsia_clang_toolchain()")
default_shlib_subdir = "/lib"
toolchain_args = invoker.toolchain_args
toolchain_args.current_os = "fuchsia"
#
# We want to build and strip binaries, but retain the unstripped binaries
# in runtime_deps to make them available for isolates.
if (host_os == "linux") {
use_strip = true
use_unstripped_as_runtime_outputs = true
}
}
}
fuchsia_toolchain("x64") {
toolchain_args = {
current_cpu = "x64"
}
}
fuchsia_toolchain("arm64") {
toolchain_args = {
current_cpu = "arm64"
}
}

View file

@ -1,21 +0,0 @@
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/fuchsia/toolchain/clang_toolchain.gni")
template("linux_toolchain") {
clang_toolchain(target_name) {
assert(host_os == "linux")
assert(defined(invoker.toolchain_args),
"toolchain_args must be defined for linux_toolchain()")
toolchain_args = invoker.toolchain_args
toolchain_args.current_os = "linux"
}
}
linux_toolchain("clang_x64") {
toolchain_args = {
current_cpu = "x64"
}
}

View file

@ -75,6 +75,10 @@ library_for_all_configs("libdart_vm") {
if (using_fuchsia_gn_sdk) {
extra_deps = [
"$fuchsia_sdk_root/fidl/fuchsia.intl",
"$fuchsia_sdk_root/pkg/async",
"$fuchsia_sdk_root/pkg/async-default",
"$fuchsia_sdk_root/pkg/async-loop",
"$fuchsia_sdk_root/pkg/async-loop-default",
"$fuchsia_sdk_root/pkg/inspect",
"$fuchsia_sdk_root/pkg/inspect_service_cpp",
"$fuchsia_sdk_root/pkg/sys_cpp",
@ -84,6 +88,8 @@ library_for_all_configs("libdart_vm") {
} else if (using_fuchsia_sdk) {
extra_deps = [
"$fuchsia_sdk_root/fidl:fuchsia.intl",
"$fuchsia_sdk_root/pkg:async-loop",
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:inspect",
"$fuchsia_sdk_root/pkg:inspect_service_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",

View file

@ -12,6 +12,9 @@
#include <stdint.h>
#include <fuchsia/intl/cpp/fidl.h>
#include <lib/async/default.h>
#include <lib/async-loop/loop.h>
#include <lib/async-loop/default.h>
#include <lib/inspect/cpp/inspect.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/sys/cpp/service_directory.h>
@ -128,6 +131,7 @@ class InspectMetrics {
// Initialized on OS:Init(), deinitialized on OS::Cleanup.
std::unique_ptr<sys::ComponentInspector> component_inspector;
std::unique_ptr<InspectMetrics> metrics;
async_loop_t* message_loop = nullptr;
// Initializes the source of timezone data if available. Timezone data file in
// Fuchsia is at a fixed directory path. Returns true on success.
@ -418,6 +422,12 @@ void OS::PrintErr(const char* format, ...) {
}
void OS::Init() {
if (async_get_default_dispatcher() == NULL) {
async_loop_create(&kAsyncLoopConfigAttachToCurrentThread, &message_loop);
async_set_default_dispatcher(async_loop_get_dispatcher(message_loop));
async_loop_start_thread(message_loop, "Fuchsia async loop", nullptr);
}
sys::ComponentContext* context = dart::ComponentContext();
component_inspector = std::make_unique<sys::ComponentInspector>(context);
metrics = std::make_unique<InspectMetrics>(component_inspector->inspector());
@ -430,6 +440,10 @@ void OS::Init() {
void OS::Cleanup() {
metrics = nullptr;
component_inspector = nullptr;
if (message_loop != nullptr) {
async_loop_destroy(message_loop);
message_loop = nullptr;
}
}
void OS::PrepareToAbort() {}

57
tools/fuchsia/find_resources.py Executable file
View file

@ -0,0 +1,57 @@
#!/usr/bin/env python
#
# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
#
# Finds files in the given directories and their subdirectories, and prints them
# in the json format expected by GN fuchsia_component's resources arg:
# [
# {
# "path": "path/to/file.dart",
# "dest": "data/path/to/file.dart"
# },
# ...
# ]
import sys
import os
from os.path import join, abspath, relpath
DART_DIR = abspath(join(__file__, '..', '..', '..'))
def listFiles(path):
allFiles = []
for dirpath, dirs, files in os.walk(join(DART_DIR, path)):
allFiles += [relpath(abspath(join(dirpath, p)), DART_DIR) for p in files]
return allFiles
def printOutput(files):
print('[')
print(',\n'.join([
' {\n "path": "%s",\n "dest": "data/%s"\n }' % (f, f) for f in files
]))
print(']')
def main():
if len(sys.argv) < 2:
print('Expected at least 1 arg, the paths to search.')
return 1
allFiles = []
for directory in sys.argv[1:]:
files = listFiles(directory)
if len(files) == 0:
print('Did not find any files in the directory: ' + directory)
return 2
allFiles += files
printOutput(sorted(allFiles))
return 0
if __name__ == '__main__':
sys.exit(main())