mirror of
https://github.com/dart-lang/sdk
synced 2024-10-01 19:19:16 +00:00
Revert "[Fuchsia] Remove the legacy gn build rules for fuchsia"
This reverts commit 094202bb91
.
Reason for revert: Break flutter, this change should happen after
flutter being migrated to the same gn-sdk.
Original change's description:
> [Fuchsia] Remove the legacy gn build rules for fuchsia
>
> The updated test-scripts contains https://crrev.com/c/5341620 which
> allows to generate fidl apis with an env var controlled location
> rather than a hard-coded one. So the existing fuchsia gn build rules
> in dart/sdk become obsolete and can be fully removed in favor of the
> one in //third_party/fuchsia/gn-sdk/.
>
> Meanwhile the gn-sdk has been updated with
> https://crrev.com/c/5325282 to use api-level version'ed idk but not
> the ones in arch/.
>
> Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
> Tested: ^^^^^
> Bug: 40935282
> Change-Id: I2ce958e6db1ff8221beef7b7ff953c32bb4525ba
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355283
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>
> Commit-Queue: Zijie He <zijiehe@google.com>
Bug: 40935282
Change-Id: I7c455d1d362210523671c97d99ef018ede1743f4
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356307
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Zijie He <zijiehe@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Zijie He <zijiehe@google.com>
This commit is contained in:
parent
f60d32167f
commit
283051acba
24
DEPS
24
DEPS
|
@ -700,7 +700,7 @@ Var("dart_root") + "/third_party/pkg/tar":
|
|||
"packages": [
|
||||
{
|
||||
"package": "chromium/fuchsia/test-scripts",
|
||||
"version": "EAdD2YcYwVrhF2q_zR6xUvPkcKlPb1tJyM_6_oOc84kC",
|
||||
"version": "version:2@49064713a73ae92d8c28164938b97869afd336aa",
|
||||
}
|
||||
],
|
||||
"condition": 'download_fuchsia_deps',
|
||||
|
@ -711,7 +711,7 @@ Var("dart_root") + "/third_party/pkg/tar":
|
|||
"packages": [
|
||||
{
|
||||
"package": "chromium/fuchsia/gn-sdk",
|
||||
"version": "RgErspyYHapUO2SpcW-vo2p8yaRUMUrq0eWjRVPfQjoC",
|
||||
"version": "version:2@7f1f23fce153ca079a77492d9d47d803d60b774e",
|
||||
}
|
||||
],
|
||||
"condition": 'download_fuchsia_deps',
|
||||
|
@ -836,16 +836,6 @@ hooks = [
|
|||
Var('emsdk_ver')],
|
||||
'condition': 'download_emscripten'
|
||||
},
|
||||
{
|
||||
'name': 'Erase arch/ from fuchsia sdk',
|
||||
'pattern': '.',
|
||||
'action': [
|
||||
'rm',
|
||||
'-rf',
|
||||
'sdk/third_party/fuchsia/sdk/linux/arch',
|
||||
],
|
||||
'condition': 'download_fuchsia_deps'
|
||||
},
|
||||
{
|
||||
'name': 'Download Fuchsia system images',
|
||||
'pattern': '.',
|
||||
|
@ -857,14 +847,4 @@ hooks = [
|
|||
],
|
||||
'condition': 'download_fuchsia_deps'
|
||||
},
|
||||
{
|
||||
'name': 'Generate Fuchsia GN build rules',
|
||||
'pattern': '.',
|
||||
'action': [
|
||||
'python3',
|
||||
'sdk/build/fuchsia/with_envs.py',
|
||||
'sdk/third_party/fuchsia/test_scripts/gen_build_defs.py',
|
||||
],
|
||||
'condition': 'download_fuchsia_deps'
|
||||
},
|
||||
]
|
||||
|
|
|
@ -257,7 +257,9 @@ if (is_win) {
|
|||
"//build/config/win:winver",
|
||||
]
|
||||
if (is_clang) {
|
||||
_native_compiler_configs += [ "//build/config/win:relative_paths" ]
|
||||
_native_compiler_configs += [
|
||||
"//build/config/win:relative_paths",
|
||||
]
|
||||
}
|
||||
}
|
||||
if (is_posix) {
|
||||
|
@ -268,8 +270,8 @@ if (is_posix) {
|
|||
}
|
||||
if (is_fuchsia) {
|
||||
_native_compiler_configs += [
|
||||
"//third_party/fuchsia/gn-sdk/src/config:compiler",
|
||||
"//third_party/fuchsia/gn-sdk/src/config:runtime_library",
|
||||
"//build/config/fuchsia:compiler",
|
||||
"//build/config/fuchsia:runtime_library",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -448,8 +450,8 @@ foreach(_target_type,
|
|||
}
|
||||
if (is_fuchsia) {
|
||||
deps += [
|
||||
"//build/config/fuchsia:runtime_library_group",
|
||||
"//build/fuchsia/config/clang:c++-runtime-deps",
|
||||
"//third_party/fuchsia/gn-sdk/src/config:runtime_library_group",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
89
build/config/fuchsia/BUILD.gn
Normal file
89
build/config/fuchsia/BUILD.gn
Normal file
|
@ -0,0 +1,89 @@
|
|||
# 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/config/fuchsia/gn_configs.gni")
|
||||
|
||||
config("compiler") {
|
||||
sdk_version = "${fuchsia_sdk_id}"
|
||||
defines = [
|
||||
# To force full builds after SDK updates in case of ABI changes.
|
||||
"FUCHSIA_SDK_VERSION=$sdk_version",
|
||||
]
|
||||
cflags = []
|
||||
ldflags = []
|
||||
if (current_cpu == "arm64") {
|
||||
cflags += [ "--target=aarch64-fuchsia" ]
|
||||
} else if (current_cpu == "x64") {
|
||||
cflags += [ "--target=x86_64-fuchsia" ]
|
||||
} else {
|
||||
assert(false, "Unsupported architecture")
|
||||
}
|
||||
|
||||
# Pass the target API level to the compiler if specified.
|
||||
if (fuchsia_target_api_level != -1) {
|
||||
cflags += [ "-ffuchsia-api-level=${fuchsia_target_api_level}" ]
|
||||
}
|
||||
|
||||
# Add libfdio by default. This may change in future versions
|
||||
# in order to move away from POSIX applications and towards
|
||||
# the Fuchsia programming model.
|
||||
ldflags += [
|
||||
# We always want fdio or else e.g. stdio wouldn't be initialized if fdio
|
||||
# happens to not be directly referenced. The common POSIX-y compiler setup
|
||||
# uses -Wl,--as-needed which drops it if it's simply "-lfdio" from a libs
|
||||
# setting. Disable --as-needed, add fdio, and then set back to --as-needed.
|
||||
"-Wl,--no-as-needed",
|
||||
"-lfdio",
|
||||
"-Wl,--as-needed",
|
||||
]
|
||||
|
||||
lib_dirs = [ "${fuchsia_sdk}/arch/${current_cpu}/lib" ]
|
||||
|
||||
libs = [ "zircon" ]
|
||||
|
||||
ldflags += cflags
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
# This should be applied to all targets.
|
||||
config("runtime_library") {
|
||||
asmflags = []
|
||||
cflags = []
|
||||
cflags_c = []
|
||||
cflags_cc = []
|
||||
cflags_objc = []
|
||||
cflags_objcc = []
|
||||
defines = []
|
||||
ldflags = []
|
||||
|
||||
sysroot = "${fuchsia_sdk}/arch/$current_cpu/sysroot"
|
||||
|
||||
# Pass the sysroot to all C compiler variants, the assembler, and linker.
|
||||
cflags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
|
||||
ldflags = cflags
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
# Copy the loader to place it at the expected path in the final package.
|
||||
copy("sysroot_dist_libs") {
|
||||
sources = [ "${fuchsia_sdk}/arch/${target_cpu}/sysroot/dist/lib/ld.so.1" ]
|
||||
outputs = [ "${root_out_dir}/lib/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
# This adds the runtime deps for //build/config/compiler:runtime_library
|
||||
# as that is a config target and thus cannot include data_deps.
|
||||
group("runtime_library_group") {
|
||||
data_deps = [
|
||||
":sysroot_dist_libs",
|
||||
|
||||
# This is used directly from //build/config/fuchsia:compiler and thus
|
||||
# also needs to be included by default.
|
||||
# "${fuchsia_sdk}/pkg/fdio",
|
||||
]
|
||||
}
|
||||
|
||||
config("sdk_lib_dirs_config") {
|
||||
visibility = [ "${fuchsia_sdk}/*" ]
|
||||
lib_dirs = [ "arch/${target_cpu}/lib" ]
|
||||
}
|
11
build/fuchsia/fidl/BUILD.gn
Normal file
11
build/fuchsia/fidl/BUILD.gn
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_fuchsia)
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
fuchsia_sdk("fidl") {
|
||||
meta = "$fuchsia_sdk_path/meta/manifest.json"
|
||||
enabled_parts = [ "fidl_library" ]
|
||||
}
|
99
build/fuchsia/fidl_gen_cpp.py
Executable file
99
build/fuchsia/fidl_gen_cpp.py
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
""" Generate C/C++ headers and source files from the set of FIDL files specified
|
||||
in the meta.json manifest.
|
||||
"""
|
||||
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def GetFIDLFilesRecursive(libraries, sdk_base, path):
|
||||
with open(path) as json_file:
|
||||
parsed = json.load(json_file)
|
||||
result = []
|
||||
deps = parsed['deps']
|
||||
for dep in deps:
|
||||
dep_meta_json = os.path.abspath('%s/fidl/%s/meta.json' % (sdk_base, dep))
|
||||
GetFIDLFilesRecursive(libraries, sdk_base, dep_meta_json)
|
||||
libraries[parsed['name']] = result + parsed['sources']
|
||||
|
||||
def GetFIDLFilesByLibraryName(sdk_base, root):
|
||||
libraries = collections.OrderedDict()
|
||||
GetFIDLFilesRecursive(libraries, sdk_base, root)
|
||||
return libraries
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser();
|
||||
|
||||
parser.add_argument('--fidlc-bin', dest='fidlc_bin', action='store', required=True)
|
||||
parser.add_argument('--fidlgen-bin', dest='fidlgen_bin', action='append', required=False)
|
||||
|
||||
parser.add_argument('--sdk-base', dest='sdk_base', action='store', required=True)
|
||||
parser.add_argument('--root', dest='root', action='store', required=True)
|
||||
parser.add_argument('--json', dest='json', action='store', required=True)
|
||||
parser.add_argument('--fidlgen-output-root', dest='fidlgen_output_root', action='store', required=False)
|
||||
parser.add_argument('--target-api-level', dest='target_api_level', action='store', required=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
assert os.path.exists(args.fidlc_bin)
|
||||
|
||||
fidl_files_by_name = GetFIDLFilesByLibraryName(args.sdk_base, args.root)
|
||||
|
||||
fidlc_command = [
|
||||
args.fidlc_bin,
|
||||
'--json',
|
||||
args.json
|
||||
]
|
||||
|
||||
if args.target_api_level:
|
||||
fidlc_command += [
|
||||
'--available',
|
||||
'fuchsia:{api_level}'.format(api_level=args.target_api_level),
|
||||
]
|
||||
|
||||
# Create an iterator that works on both python3 and python2
|
||||
try:
|
||||
fidl_files_by_name_iter = list(fidl_files_by_name.items())
|
||||
except AttributeError:
|
||||
fidl_files_by_name_iter = iter(fidl_files_by_name.items())
|
||||
|
||||
for _, fidl_files in fidl_files_by_name_iter:
|
||||
fidlc_command.append('--files')
|
||||
for fidl_file in fidl_files:
|
||||
fidl_abspath = os.path.abspath('%s/%s' % (args.sdk_base, fidl_file))
|
||||
fidlc_command.append(fidl_abspath)
|
||||
|
||||
subprocess.check_call(fidlc_command)
|
||||
|
||||
if args.fidlgen_output_root:
|
||||
assert os.path.exists(args.json)
|
||||
for fidlgen_bin in args.fidlgen_bin:
|
||||
assert os.path.exists(fidlgen_bin)
|
||||
|
||||
fidlgen_command = [
|
||||
fidlgen_bin,
|
||||
'-json',
|
||||
args.json,
|
||||
'-root',
|
||||
args.fidlgen_output_root
|
||||
]
|
||||
|
||||
subprocess.check_call(fidlgen_command)
|
||||
else:
|
||||
# --fidlgen-bin and --fidlgen-output-root should be passed in together.
|
||||
assert not args.fidlgen_bin
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
14
build/fuchsia/pkg/BUILD.gn
Normal file
14
build/fuchsia/pkg/BUILD.gn
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_fuchsia)
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
fuchsia_sdk("pkg") {
|
||||
meta = "$fuchsia_sdk_path/meta/manifest.json"
|
||||
enabled_parts = [
|
||||
"cc_source_library",
|
||||
"cc_prebuilt_library",
|
||||
]
|
||||
}
|
373
build/fuchsia/sdk.gni
Normal file
373
build/fuchsia/sdk.gni
Normal file
|
@ -0,0 +1,373 @@
|
|||
# Copyright 2013 The Flutter 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/config/fuchsia/gn_configs.gni")
|
||||
|
||||
declare_args() {
|
||||
# The path to where GN targets derived from the Fuchsia SDK are instantiated.
|
||||
fuchsia_sdk_root = "//build/fuchsia"
|
||||
|
||||
# The Flutter buildroot is outside the Fuchsia root and can only use the SDK.
|
||||
using_fuchsia_sdk = true
|
||||
|
||||
# This is set by the dart sources. Once the engine repo switches to using the GN SDK,
|
||||
# this flag can be unified with `using_fuchsia_sdk`.
|
||||
using_fuchsia_gn_sdk = false
|
||||
|
||||
# The following variables are Flutter buildroot specific.
|
||||
fuchsia_sdk_path = "//third_party/fuchsia/sdk/$host_os"
|
||||
fuchsia_toolchain_path = "//buildtools/${host_os}-${host_cpu}/clang"
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# The Skia buildroot uses this flag to decide if it should be using the
|
||||
# Fuchsia SDK to build its translation units.
|
||||
skia_using_fuchsia_sdk = using_fuchsia_sdk
|
||||
}
|
||||
|
||||
_fuchsia_sdk_path = "//third_party/fuchsia/sdk/$host_os"
|
||||
_fuchsia_tools_path = "${_fuchsia_sdk_path}/tools/${host_cpu}"
|
||||
|
||||
template("_fuchsia_sysroot") {
|
||||
assert(defined(invoker.meta), "The meta.json file path must be specified.")
|
||||
assert(target_cpu == "x64" || target_cpu == "arm64",
|
||||
"We currently only support 'x64' and 'arm64' targets for fuchsia.")
|
||||
|
||||
meta_json = read_file(invoker.meta, "json")
|
||||
|
||||
assert(meta_json.type == "sysroot")
|
||||
|
||||
meta_json_versions = meta_json.versions
|
||||
if (target_cpu == "x64") {
|
||||
defs = meta_json_versions.x64
|
||||
} else {
|
||||
defs = meta_json_versions.arm64
|
||||
}
|
||||
|
||||
_libs = []
|
||||
_lib_dirs = []
|
||||
_include_dirs = []
|
||||
|
||||
foreach(link_lib, defs.link_libs) {
|
||||
if (link_lib != "arch/${target_cpu}/sysroot/lib/Scrt1.o") {
|
||||
_libs += [ "$_fuchsia_sdk_path/$link_lib" ]
|
||||
}
|
||||
}
|
||||
|
||||
defs_include_dir = defs.include_dir
|
||||
_include_dirs += [ "$_fuchsia_sdk_path/$defs_include_dir" ]
|
||||
|
||||
config_name = "config_$target_name"
|
||||
config(config_name) {
|
||||
lib_dirs = _lib_dirs
|
||||
libs = _libs
|
||||
include_dirs = _include_dirs
|
||||
}
|
||||
|
||||
group(target_name) {
|
||||
public_configs = [ ":$config_name" ]
|
||||
}
|
||||
}
|
||||
|
||||
template("fuchsia_fidl_library") {
|
||||
assert(defined(invoker.meta), "The meta.json file path must be specified.")
|
||||
assert(target_cpu == "x64" || target_cpu == "arm64",
|
||||
"We currently only support 'x64' and 'arm64' targets for fuchsia.")
|
||||
|
||||
meta_json = read_file(invoker.meta, "json")
|
||||
assert(meta_json.type == "fidl_library")
|
||||
|
||||
_deps = [
|
||||
"//build/fuchsia/pkg:fidl_cpp",
|
||||
"//build/fuchsia/pkg:fidl_cpp_hlcpp_conversion",
|
||||
"//build/fuchsia/pkg:fidl_cpp_natural_ostream",
|
||||
"//build/fuchsia/pkg:fidl_cpp_v2",
|
||||
"//build/fuchsia/pkg:fidl_cpp_wire",
|
||||
]
|
||||
|
||||
library_name = meta_json.name
|
||||
library_name_json = "${meta_json.name}.json"
|
||||
|
||||
foreach(dep, meta_json.deps) {
|
||||
# TODO(https://fxbug.dev/42172334): Make zx less special.
|
||||
if (dep != "zx") {
|
||||
_deps += [ ":$dep" ]
|
||||
}
|
||||
}
|
||||
|
||||
config_name = "config_$target_name"
|
||||
config(config_name) {
|
||||
include_dirs = [ target_gen_dir ]
|
||||
}
|
||||
|
||||
fidl_gen_target_name = "fidlgen_$target_name"
|
||||
action(fidl_gen_target_name) {
|
||||
script = "//build/fuchsia/fidl_gen_cpp.py"
|
||||
|
||||
library_name_slashes = string_replace(library_name, ".", "/")
|
||||
|
||||
inputs = [ invoker.meta ]
|
||||
|
||||
args = [
|
||||
"--fidlc-bin",
|
||||
rebase_path("${_fuchsia_tools_path}/fidlc"),
|
||||
"--sdk-base",
|
||||
rebase_path(_fuchsia_sdk_path),
|
||||
"--root",
|
||||
rebase_path(invoker.meta),
|
||||
"--json",
|
||||
rebase_path("$target_gen_dir/$library_name_json"),
|
||||
]
|
||||
|
||||
if (fuchsia_target_api_level != -1) {
|
||||
args += [
|
||||
"--target-api-level",
|
||||
"${fuchsia_target_api_level}",
|
||||
]
|
||||
}
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/$library_name_slashes/cpp/fidl.cc",
|
||||
"$target_gen_dir/$library_name_slashes/cpp/fidl.h",
|
||||
"$target_gen_dir/$library_name_slashes/cpp/fidl_test_base.h",
|
||||
"$target_gen_dir/$library_name_slashes/cpp/tables.c",
|
||||
|
||||
"$target_gen_dir/fidl/$library_name/cpp/common_types.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/common_types.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/fidl.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/hlcpp_conversion.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/markers.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_messaging.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_messaging.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_ostream.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_ostream.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_types.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/natural_types.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/type_conversions.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/type_conversions.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire_messaging.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire_messaging.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire_test_base.h",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire_types.cc",
|
||||
"$target_gen_dir/fidl/$library_name/cpp/wire_types.h",
|
||||
]
|
||||
|
||||
args += [
|
||||
"--fidlgen-bin",
|
||||
rebase_path("${_fuchsia_tools_path}/fidlgen_cpp"),
|
||||
"--fidlgen-bin",
|
||||
rebase_path("${_fuchsia_tools_path}/fidlgen_hlcpp"),
|
||||
"--fidlgen-output-root",
|
||||
rebase_path("$target_gen_dir"),
|
||||
]
|
||||
}
|
||||
|
||||
source_set(target_name) {
|
||||
public_configs = [ ":$config_name" ]
|
||||
|
||||
sources = get_target_outputs(":$fidl_gen_target_name")
|
||||
|
||||
deps = [ ":$fidl_gen_target_name" ]
|
||||
|
||||
public_deps = _deps
|
||||
}
|
||||
}
|
||||
|
||||
template("_fuchsia_cc_source_library") {
|
||||
assert(defined(invoker.meta), "The meta.json file path must be specified.")
|
||||
|
||||
meta_json = read_file(invoker.meta, "json")
|
||||
|
||||
assert(meta_json.type == "cc_source_library")
|
||||
|
||||
_output_name = meta_json.name
|
||||
_include_dirs = []
|
||||
_public_headers = []
|
||||
_sources = []
|
||||
_deps = []
|
||||
|
||||
meta_json_include_dir = meta_json.include_dir
|
||||
_include_dirs += [ "$_fuchsia_sdk_path/$meta_json_include_dir" ]
|
||||
|
||||
foreach(header, meta_json.headers) {
|
||||
rebased_header = []
|
||||
rebased_header = [ "$_fuchsia_sdk_path/$header" ]
|
||||
_public_headers += rebased_header
|
||||
_sources += rebased_header
|
||||
}
|
||||
|
||||
foreach(source, meta_json.sources) {
|
||||
_sources += [ "$_fuchsia_sdk_path/$source" ]
|
||||
}
|
||||
|
||||
config_name = "config_$target_name"
|
||||
config(config_name) {
|
||||
include_dirs = _include_dirs
|
||||
}
|
||||
|
||||
foreach(dep, meta_json.deps) {
|
||||
_deps += [ "../pkg:$dep" ]
|
||||
}
|
||||
|
||||
foreach(dep, meta_json.fidl_deps) {
|
||||
_deps += [ "../fidl:$dep" ]
|
||||
}
|
||||
|
||||
foreach(binding_dep, meta_json.fidl_binding_deps) {
|
||||
# No need to check "binding_deps.binding_type" because we always
|
||||
# generate both hlcpp and natural bindings.
|
||||
foreach(dep, binding_dep.deps) {
|
||||
_deps += [ "../fidl:$dep" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set(target_name) {
|
||||
output_name = _output_name
|
||||
public = _public_headers
|
||||
sources = _sources
|
||||
public_configs = [ ":$config_name" ]
|
||||
public_deps = _deps
|
||||
}
|
||||
}
|
||||
|
||||
template("_fuchsia_cc_prebuilt_library") {
|
||||
assert(defined(invoker.meta), "The meta.json file path must be specified.")
|
||||
meta_json = read_file(invoker.meta, "json")
|
||||
|
||||
_include_dirs = []
|
||||
_deps = []
|
||||
_libs = []
|
||||
|
||||
meta_json_include_dir = meta_json.include_dir
|
||||
_include_dirs += [ "$_fuchsia_sdk_path/$meta_json_include_dir" ]
|
||||
|
||||
foreach(dep, meta_json.deps) {
|
||||
_deps += [ ":$dep" ]
|
||||
}
|
||||
|
||||
meta_json_binaries = meta_json.binaries
|
||||
if (target_cpu == "x64") {
|
||||
meta_json_binaries_arch = meta_json_binaries.x64
|
||||
} else {
|
||||
meta_json_binaries_arch = meta_json_binaries.arm64
|
||||
}
|
||||
prebuilt_lib = meta_json_binaries_arch.link
|
||||
_libs = [ "$_fuchsia_sdk_path/$prebuilt_lib" ]
|
||||
|
||||
if (meta_json.format == "shared") {
|
||||
copy("${target_name}_dist_libs") {
|
||||
sources = [ "$_fuchsia_sdk_path/${meta_json_binaries_arch.dist}" ]
|
||||
outputs = [ "${root_out_dir}/${meta_json_binaries_arch.dist_path}" ]
|
||||
}
|
||||
}
|
||||
|
||||
config_name = "config_$target_name"
|
||||
config(config_name) {
|
||||
include_dirs = _include_dirs
|
||||
libs = _libs
|
||||
}
|
||||
|
||||
group(target_name) {
|
||||
public_configs = [ ":$config_name" ]
|
||||
public_deps = _deps
|
||||
if (meta_json.format == "shared") {
|
||||
data_deps = [ ":${target_name}_dist_libs" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template("fuchsia_sdk") {
|
||||
assert(defined(invoker.meta), "The meta.json file path must be specified.")
|
||||
assert(defined(invoker.enabled_parts),
|
||||
"A list containing the parts of the SDK to generate targets for.")
|
||||
|
||||
meta_json = read_file(invoker.meta, "json")
|
||||
|
||||
foreach(part, meta_json.parts) {
|
||||
part_meta_json = {
|
||||
}
|
||||
part_meta = part.meta
|
||||
part_meta_rebased = "$_fuchsia_sdk_path/$part_meta"
|
||||
|
||||
# Check if the part is using `part.element_type` or `part.type`.
|
||||
part_type = ""
|
||||
if (defined(part.element_type)) {
|
||||
part_type = part.element_type
|
||||
} else if (defined(part.type)) {
|
||||
part_type = part.type
|
||||
}
|
||||
|
||||
# Check if the part type is in `invoker.enabled_parts`.
|
||||
if (invoker.enabled_parts + [ part_type ] - [ part_type ] !=
|
||||
invoker.enabled_parts) {
|
||||
part_meta_json = read_file(part_meta_rebased, "json")
|
||||
subtarget_name = part_meta_json.name
|
||||
|
||||
if (part_type == "cc_source_library") {
|
||||
_fuchsia_cc_source_library(subtarget_name) {
|
||||
meta = part_meta_rebased
|
||||
}
|
||||
} else if (part_type == "sysroot") {
|
||||
_fuchsia_sysroot(subtarget_name) {
|
||||
meta = part_meta_rebased
|
||||
}
|
||||
} else if (part_type == "fidl_library") {
|
||||
# TODO(https://fxbug.dev/42172334): Make zx less special.
|
||||
if (subtarget_name != "zx") {
|
||||
fuchsia_fidl_library(subtarget_name) {
|
||||
meta = part_meta_rebased
|
||||
}
|
||||
}
|
||||
} else if (part_type == "cc_prebuilt_library") {
|
||||
_fuchsia_cc_prebuilt_library(subtarget_name) {
|
||||
meta = part_meta_rebased
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group(target_name) {
|
||||
}
|
||||
}
|
||||
|
||||
template("fuchsia_repo") {
|
||||
assert(defined(invoker.archives),
|
||||
"The list of archives to publish must be specified.")
|
||||
assert(defined(invoker.repo), "The location of the repo should be specified.")
|
||||
|
||||
action(target_name) {
|
||||
script = "//flutter/tools/fuchsia/gen_repo.py"
|
||||
|
||||
pm_binary = rebase_path("${_fuchsia_tools_path}/pm")
|
||||
repo_directory = invoker.repo
|
||||
|
||||
inputs = [ pm_binary ]
|
||||
|
||||
archive_flags = []
|
||||
|
||||
foreach(archive, invoker.archives) {
|
||||
assert(get_path_info(archive, "extension") == "far",
|
||||
"Archive '$archive' does not have the .far extension.")
|
||||
inputs += [ archive ]
|
||||
archive_flags += [
|
||||
"--archive",
|
||||
rebase_path(archive),
|
||||
]
|
||||
}
|
||||
|
||||
outputs = [ repo_directory ]
|
||||
|
||||
args = [
|
||||
"--pm-bin",
|
||||
pm_binary,
|
||||
"--repo-dir",
|
||||
rebase_path(repo_directory),
|
||||
] + archive_flags
|
||||
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps
|
||||
}
|
||||
}
|
||||
}
|
11
build/fuchsia/sysroot/BUILD.gn
Normal file
11
build/fuchsia/sysroot/BUILD.gn
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_fuchsia)
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
fuchsia_sdk("sdk_sysroot") {
|
||||
meta = "$fuchsia_sdk_path/meta/manifest.json"
|
||||
enabled_parts = [ "sysroot" ]
|
||||
}
|
|
@ -42,10 +42,6 @@ def Main():
|
|||
'third_party', 'fuchsia',
|
||||
'sdk', sdk_dir)
|
||||
|
||||
os.environ['FUCHSIA_GN_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
|
||||
'third_party', 'fuchsia',
|
||||
'gn-sdk', 'src')
|
||||
|
||||
with subprocess.Popen(sys.argv[1:]) as proc:
|
||||
try:
|
||||
proc.wait()
|
||||
|
|
|
@ -8,6 +8,10 @@ import("runtime_args.gni")
|
|||
|
||||
import("//build/config/sysroot.gni")
|
||||
|
||||
if (is_fuchsia) {
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
}
|
||||
|
||||
config("dart_public_config") {
|
||||
include_dirs = [
|
||||
".",
|
||||
|
@ -171,14 +175,19 @@ config("dart_config") {
|
|||
}
|
||||
|
||||
if (is_fuchsia) {
|
||||
lib_dirs = [ "${fuchsia_arch_root}/lib" ]
|
||||
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
lib_dirs = [ root_out_dir + "/lib" ]
|
||||
}
|
||||
if (using_fuchsia_gn_sdk || using_fuchsia_sdk) {
|
||||
# TODO(chinmaygarde): Currently these targets need to be build in the
|
||||
# Fuchsia tree as well as outside it using the SDK. However, not all
|
||||
# Fuchsia features are available in the SDK. As these features are added,
|
||||
# the guards can be removed. Eventually, only SDK builds will be present.
|
||||
# Then, this flag can be removed completely.
|
||||
defines += [ "FUCHSIA_SDK" ]
|
||||
} else {
|
||||
include_dirs += [ "//zircon/system/ulib/zx/include" ]
|
||||
}
|
||||
}
|
||||
|
||||
# Below are flags copied from ../build/config/compiler/BUILD.gn that should
|
||||
|
@ -297,10 +306,22 @@ library_for_all_configs("libdart") {
|
|||
"../third_party/double-conversion/src:libdouble_conversion",
|
||||
]
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk/pkg/fdio",
|
||||
"$fuchsia_sdk/pkg/trace-engine",
|
||||
"$fuchsia_sdk_root/pkg/fdio",
|
||||
"$fuchsia_sdk_root/pkg/trace-engine",
|
||||
]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk_root/pkg:fdio",
|
||||
"$fuchsia_sdk_root/pkg:trace-engine",
|
||||
]
|
||||
} else {
|
||||
extra_deps += [
|
||||
"//zircon/public/lib/fbl",
|
||||
"//zircon/system/ulib/trace-engine",
|
||||
]
|
||||
}
|
||||
}
|
||||
configurable_deps = [
|
||||
"platform:libdart_platform",
|
||||
|
|
|
@ -16,6 +16,10 @@ import("cli_sources.gni")
|
|||
import("io_impl_sources.gni")
|
||||
import("io_sources.gni")
|
||||
|
||||
if (is_fuchsia) {
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
}
|
||||
|
||||
config("libdart_builtin_config") {
|
||||
if (is_win) {
|
||||
libs = [ "bcrypt.lib" ]
|
||||
|
@ -59,7 +63,13 @@ template("build_libdart_builtin") {
|
|||
public_configs = [ ":libdart_builtin_config" ]
|
||||
deps = []
|
||||
if (is_fuchsia) {
|
||||
public_deps = [ "$fuchsia_sdk/pkg/fdio" ]
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg:fdio" ]
|
||||
} else {
|
||||
public_deps = [ "//sdk/lib/fdio" ]
|
||||
}
|
||||
}
|
||||
if (is_win) {
|
||||
libs = [ "Pathcch.lib" ]
|
||||
|
@ -323,11 +333,25 @@ template("build_gen_snapshot_dart_io") {
|
|||
deps = [ "//third_party/zlib" ]
|
||||
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
deps += [
|
||||
"$fuchsia_sdk/fidl/fuchsia.io",
|
||||
"$fuchsia_sdk/fidl/fuchsia.kernel",
|
||||
"$fuchsia_sdk_root/fidl/fuchsia.io",
|
||||
"$fuchsia_sdk_root/fidl/fuchsia.kernel",
|
||||
]
|
||||
public_deps = [ "$fuchsia_sdk/pkg/fdio" ]
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
deps += [
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.io",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.kernel",
|
||||
]
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg:fdio" ]
|
||||
} else {
|
||||
deps += [
|
||||
"//sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
|
||||
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_hlcpp",
|
||||
]
|
||||
public_deps = [ "//sdk/lib/fdio" ]
|
||||
}
|
||||
}
|
||||
|
||||
defines = [ "DART_IO_SECURE_SOCKET_DISABLED" ]
|
||||
|
@ -430,11 +454,25 @@ template("dart_io") {
|
|||
deps += [ "//third_party/boringssl" ]
|
||||
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
deps += [
|
||||
"$fuchsia_sdk/fidl/fuchsia.io",
|
||||
"$fuchsia_sdk/fidl/fuchsia.kernel",
|
||||
"$fuchsia_sdk_root/fidl/fuchsia.io",
|
||||
"$fuchsia_sdk_root/fidl/fuchsia.kernel",
|
||||
]
|
||||
public_deps = [ "$fuchsia_sdk/pkg/fdio" ]
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
deps += [
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.io",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.kernel",
|
||||
]
|
||||
public_deps = [ "$fuchsia_sdk_root/pkg:fdio" ]
|
||||
} else {
|
||||
deps += [
|
||||
"//sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
|
||||
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_hlcpp",
|
||||
]
|
||||
public_deps = [ "//sdk/lib/fdio" ]
|
||||
}
|
||||
}
|
||||
|
||||
sources = io_impl_sources
|
||||
|
@ -955,7 +993,13 @@ executable("run_vm_tests") {
|
|||
defines = [ "TESTING" ]
|
||||
|
||||
if (is_fuchsia) {
|
||||
deps += [ "$fuchsia_sdk/pkg/trace-engine" ]
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
deps += [ "$fuchsia_sdk_root/pkg/trace-engine" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
deps += [ "$fuchsia_sdk_root/pkg:trace-engine" ]
|
||||
} else {
|
||||
deps += [ "//zircon/system/ulib/trace-engine" ]
|
||||
}
|
||||
}
|
||||
|
||||
# The VM sources are already included in libdart, so we just want to add in
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
import("../configs.gni")
|
||||
import("platform_sources.gni")
|
||||
|
||||
if (is_fuchsia) {
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
}
|
||||
|
||||
library_for_all_configs("libdart_platform") {
|
||||
target_type = "source_set"
|
||||
public_configs = [ "../vm:libdart_vm_config" ]
|
||||
|
@ -13,9 +17,21 @@ library_for_all_configs("libdart_platform") {
|
|||
extra_deps = []
|
||||
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk/pkg/inspect_component_cpp",
|
||||
"$fuchsia_sdk/pkg/sys_cpp",
|
||||
"$fuchsia_sdk_root/pkg/inspect_component_cpp",
|
||||
"$fuchsia_sdk_root/pkg/sys_cpp",
|
||||
]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
|
||||
"$fuchsia_sdk_root/pkg:sys_cpp",
|
||||
]
|
||||
} else {
|
||||
extra_deps += [
|
||||
"//sdk/lib/inspect/component/cpp",
|
||||
"//sdk/lib/sys/cpp",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,14 +85,3 @@ declare_args() {
|
|||
(dart_target_arch == "x64" || dart_target_arch == "arm64" ||
|
||||
dart_target_arch == "riscv64")
|
||||
}
|
||||
|
||||
if (is_fuchsia) {
|
||||
declare_args() {
|
||||
# In case some repo uses build rules in dart/sdk, but put fuchsia-gn-sdk in
|
||||
# a different folder, this gn arg can specify the location of fuchsia-gn-sdk.
|
||||
if (!defined(fuchsia_gn_sdk)) {
|
||||
fuchsia_gn_sdk = "//third_party/fuchsia/gn-sdk"
|
||||
}
|
||||
}
|
||||
import(fuchsia_gn_sdk + "/src/gn_configs.gni")
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ import("ffi/ffi_sources.gni")
|
|||
import("heap/heap_sources.gni")
|
||||
import("vm_sources.gni")
|
||||
|
||||
if (is_fuchsia) {
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
}
|
||||
|
||||
config("libdart_vm_config") {
|
||||
if (is_fuchsia) {
|
||||
libs = [ "zircon" ]
|
||||
|
@ -168,17 +172,38 @@ library_for_all_configs("libdart_vm") {
|
|||
]
|
||||
extra_deps = []
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk/fidl/fuchsia.intl",
|
||||
"$fuchsia_sdk/pkg/async",
|
||||
"$fuchsia_sdk/pkg/async-default",
|
||||
"$fuchsia_sdk/pkg/async-loop",
|
||||
"$fuchsia_sdk/pkg/async-loop-default",
|
||||
"$fuchsia_sdk/pkg/inspect",
|
||||
"$fuchsia_sdk/pkg/inspect_component_cpp",
|
||||
"$fuchsia_sdk/pkg/sys_cpp",
|
||||
"$fuchsia_sdk/pkg/trace-engine",
|
||||
"$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_component_cpp",
|
||||
"$fuchsia_sdk_root/pkg/sys_cpp",
|
||||
"$fuchsia_sdk_root/pkg/trace-engine",
|
||||
]
|
||||
} 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_component_cpp",
|
||||
"$fuchsia_sdk_root/pkg:sys_cpp",
|
||||
"$fuchsia_sdk_root/pkg:trace-engine",
|
||||
]
|
||||
} else {
|
||||
extra_deps += [
|
||||
"//sdk/fidl/fuchsia.intl",
|
||||
"//sdk/lib/inspect/component/cpp",
|
||||
"//sdk/lib/sys/cpp",
|
||||
"//zircon/public/lib/fbl",
|
||||
"//zircon/system/ulib/inspect",
|
||||
"//zircon/system/ulib/trace-engine",
|
||||
]
|
||||
}
|
||||
}
|
||||
public_configs = [ ":libdart_vm_config" ]
|
||||
sources = vm_sources + rebase_path(compiler_api_sources, ".", "./compiler/") +
|
||||
|
@ -202,7 +227,16 @@ library_for_all_configs_with_compiler("libdart_compiler") {
|
|||
extra_nonproduct_deps = [ ":libprotozero" ]
|
||||
extra_deps = []
|
||||
if (is_fuchsia) {
|
||||
extra_deps += [ "$fuchsia_sdk/pkg/trace-engine" ]
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [ "$fuchsia_sdk_root/pkg/trace-engine" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
extra_deps += [ "$fuchsia_sdk_root/pkg:trace-engine" ]
|
||||
} else {
|
||||
extra_deps += [
|
||||
"//zircon/public/lib/fbl",
|
||||
"//zircon/system/ulib/trace-engine",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +245,16 @@ library_for_all_configs("libdart_lib") {
|
|||
extra_nonproduct_deps = [ ":libprotozero" ]
|
||||
extra_deps = []
|
||||
if (is_fuchsia) {
|
||||
extra_deps += [ "$fuchsia_sdk/pkg/trace-engine" ]
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [ "$fuchsia_sdk_root/pkg/trace-engine" ]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
extra_deps += [ "$fuchsia_sdk_root/pkg:trace-engine" ]
|
||||
} else {
|
||||
extra_deps += [
|
||||
"//zircon/public/lib/fbl",
|
||||
"//zircon/system/ulib/trace-engine",
|
||||
]
|
||||
}
|
||||
}
|
||||
include_dirs = [ ".." ]
|
||||
allsources = async_runtime_cc_files + core_runtime_cc_files +
|
||||
|
|
Loading…
Reference in a new issue