mirror of
https://github.com/dart-lang/sdk
synced 2024-09-30 04:48:37 +00:00
[build] Switch to Fuchsia core SDK.
build/fuchsia/gn-sdk is a copy of the current GN SDK with paths adjusted. The rest of build/fuchsia comes from Flutter. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/38752 Change-Id: I192cca955d05991bde3931d053df9835c5a2195d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334142 Reviewed-by: Zijie He <zijiehe@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
parent
4830c96420
commit
63aaca8c9a
4
.gn
4
.gn
|
@ -15,7 +15,3 @@ secondary_source = "//build/secondary/"
|
|||
|
||||
# Override the default script executable to always be python3.
|
||||
script_executable = "python3"
|
||||
|
||||
default_args = {
|
||||
fuchsia_target_api_level = 15
|
||||
}
|
||||
|
|
4
BUILD.gn
4
BUILD.gn
|
@ -165,8 +165,8 @@ group("compressed_observatory_archive") {
|
|||
}
|
||||
|
||||
if (is_fuchsia) {
|
||||
import("third_party/fuchsia/sdk/${host_os}/build/component.gni")
|
||||
import("third_party/fuchsia/sdk/${host_os}/build/package.gni")
|
||||
import("third_party/fuchsia-gn-sdk/src/component.gni")
|
||||
import("third_party/fuchsia-gn-sdk/src/package.gni")
|
||||
|
||||
test_binaries = [
|
||||
"dart",
|
||||
|
|
39
DEPS
39
DEPS
|
@ -84,7 +84,7 @@ vars = {
|
|||
|
||||
"reclient_version": "git_revision:81e819b39d4743462857cc55430d898b9fcca1af",
|
||||
|
||||
# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/gn
|
||||
# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core
|
||||
"fuchsia_sdk_version": "version:16.20231105.3.1",
|
||||
"download_fuchsia_deps": False,
|
||||
|
||||
|
@ -649,41 +649,36 @@ Var("dart_root") + "/third_party/pkg/tar":
|
|||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
# TODO(38752): Confirm if mac sdk is necessary in dart.
|
||||
Var("dart_root") + "/third_party/fuchsia/sdk/mac": {
|
||||
"packages": [
|
||||
{
|
||||
"package": "fuchsia/sdk/gn/mac-amd64",
|
||||
"version": Var("fuchsia_sdk_version"),
|
||||
}
|
||||
],
|
||||
"condition":
|
||||
'download_fuchsia_deps and host_os == "mac" and host_cpu == "x64"',
|
||||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
# TODO(38752): Migrate to core sdk, gn sdk is deprecating.
|
||||
Var("dart_root") + "/third_party/fuchsia/sdk/linux": {
|
||||
"packages": [
|
||||
{
|
||||
"package": "fuchsia/sdk/gn/linux-amd64",
|
||||
"package": "fuchsia/sdk/core/${{platform}}",
|
||||
"version": Var("fuchsia_sdk_version"),
|
||||
}
|
||||
],
|
||||
"condition":
|
||||
'download_fuchsia_deps and host_os == "linux" and host_cpu == "x64"',
|
||||
"condition": 'download_fuchsia_deps and host_os == "linux"',
|
||||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
Var("dart_root") + "/third_party/fuchsia/test_scripts": {
|
||||
"packages": [
|
||||
{
|
||||
"package": "chromium/fuchsia/test-scripts/fuchsia",
|
||||
"version": "version:2@56179f1724e9bf82ce7abf5577884e5d217b52e9",
|
||||
"package": "chromium/fuchsia/test-scripts",
|
||||
"version": "version:2@542d79b983ec1cdf95d9cb3aea0ea528a4b3569d",
|
||||
}
|
||||
],
|
||||
"condition":
|
||||
'download_fuchsia_deps and host_os == "linux" and host_cpu == "x64"',
|
||||
"condition": 'download_fuchsia_deps',
|
||||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
Var("dart_root") + "/third_party/fuchsia-gn-sdk": {
|
||||
"packages": [
|
||||
{
|
||||
"package": "chromium/fuchsia/gn-sdk",
|
||||
"version": "version:2@691dde4a86f8f32790942eb025c3e9fe74102811",
|
||||
}
|
||||
],
|
||||
"condition": 'download_fuchsia_deps',
|
||||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
|
|
|
@ -271,8 +271,8 @@ if (is_posix) {
|
|||
}
|
||||
if (is_fuchsia) {
|
||||
_native_compiler_configs += [
|
||||
"//third_party/fuchsia/sdk/${host_os}/build/config:compiler",
|
||||
"//third_party/fuchsia/sdk/${host_os}/build/config:runtime_library",
|
||||
"//build/config/fuchsia:compiler",
|
||||
"//build/config/fuchsia:runtime_library",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -433,22 +433,28 @@ if (is_win) {
|
|||
#
|
||||
# Variables
|
||||
# no_default_deps: If true, no standard dependencies will be added.
|
||||
if (use_flutter_cxx) {
|
||||
foreach(_target_type,
|
||||
[
|
||||
"executable",
|
||||
"loadable_module",
|
||||
"shared_library",
|
||||
]) {
|
||||
template(_target_type) {
|
||||
target(_target_type, target_name) {
|
||||
forward_variables_from(invoker, "*", [ "no_default_deps" ])
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
|
||||
foreach(_target_type,
|
||||
[
|
||||
"executable",
|
||||
"loadable_module",
|
||||
"shared_library",
|
||||
]) {
|
||||
template(_target_type) {
|
||||
target(_target_type, target_name) {
|
||||
forward_variables_from(invoker, "*", [ "no_default_deps" ])
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
|
||||
if (use_flutter_cxx) {
|
||||
deps += [ "//third_party/libcxx" ]
|
||||
}
|
||||
if (is_fuchsia) {
|
||||
deps += [
|
||||
"//build/config/fuchsia:runtime_library_group",
|
||||
"//build/fuchsia/config/clang:c++-runtime-deps",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
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" ]
|
||||
}
|
57
build/config/fuchsia/gn_configs.gni
Normal file
57
build/config/fuchsia/gn_configs.gni
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Copyright 2023 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_fuchsia)
|
||||
|
||||
declare_args() {
|
||||
# The target API level for this repository. Embedders should override this
|
||||
# value to specify the API level the packages produced from this repository
|
||||
# should be targeting, e.g. in their top-level //.gn file. A value of -1
|
||||
# means that no API level will be passed to the tools that consumes it.
|
||||
fuchsia_target_api_level = 12
|
||||
|
||||
# Path to the fuchsia SDK. This is intended for use in other templates &
|
||||
# rules to reference the contents of the fuchsia SDK.
|
||||
fuchsia_sdk = "//third_party/fuchsia/sdk/$host_os"
|
||||
|
||||
# ID uniquely identifying the Fuchsia IDK build. This is exposed as a
|
||||
# property so it can be used to locate images and packages on GCS and
|
||||
# as a marker to indicate the "version" of the IDK.
|
||||
# Defaults to the id found in the manifest.json file of the SDK.
|
||||
fuchsia_sdk_id = ""
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# The SDK manifest file. This is useful to include as a dependency
|
||||
# for some targets in order to cause a rebuild when the version of the
|
||||
# SDK is changed.
|
||||
fuchsia_sdk_manifest_file = "$fuchsia_sdk/meta/manifest.json"
|
||||
|
||||
# fuchsia_tool_dir is used to specify the directory in the SDK to locate
|
||||
# tools for the host cpu architecture. If the host_cpu is not recognized,
|
||||
# then tool dir defaults to x64.
|
||||
fuchsia_tool_dir = "${fuchsia_sdk}/tools/x64"
|
||||
if (host_cpu == "arm64") {
|
||||
fuchsia_tool_dir = "${fuchsia_sdk}/tools/arm64"
|
||||
}
|
||||
}
|
||||
|
||||
if (fuchsia_sdk_id == "") {
|
||||
# Note: If we need to expose more than just the id in the future,
|
||||
# we should consider exposing the entire json object for the metadata vs.
|
||||
# adding a bunch of variables.
|
||||
_meta = read_file(fuchsia_sdk_manifest_file, "json")
|
||||
fuchsia_sdk_id = _meta.id
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# Specify a readelf_exec path to use. If not specified, the host's system
|
||||
# executable will be used. Passed to populate_build_id_dir.py and
|
||||
# prepare_package_inputs.py via the --readelf-exec flag.
|
||||
# Must be a GN path (not an absolute path) since it is adjusted with
|
||||
# rebase_path().
|
||||
if (!defined(fuchsia_sdk_readelf_exec)) {
|
||||
fuchsia_sdk_readelf_exec = ""
|
||||
}
|
||||
}
|
13
build/fuchsia/BUILD.gn
Normal file
13
build/fuchsia/BUILD.gn
Normal file
|
@ -0,0 +1,13 @@
|
|||
# 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)
|
||||
|
||||
group("fuchsia") {
|
||||
deps = [
|
||||
"fidl",
|
||||
"pkg",
|
||||
"sysroot",
|
||||
]
|
||||
}
|
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" ]
|
||||
}
|
116
build/fuchsia/fidl_gen_cpp.py
Executable file
116
build/fuchsia/fidl_gen_cpp.py
Executable file
|
@ -0,0 +1,116 @@
|
|||
#!/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('--output-c-tables',
|
||||
dest='output_c_tables',
|
||||
action='store',
|
||||
required=True)
|
||||
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, '--tables', args.output_c_tables, '--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",
|
||||
]
|
||||
}
|
|
@ -1,10 +1,369 @@
|
|||
# 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.
|
||||
# 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() {
|
||||
using_fuchsia_gn_sdk = true
|
||||
fuchsia_sdk_root = "//third_party/fuchsia/sdk/$host_os"
|
||||
# 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 = "//third_party/fuchsia/toolchain/$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) {
|
||||
_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 ]
|
||||
|
||||
outputs = [ "$target_gen_dir/$library_name_slashes/cpp/tables.c" ]
|
||||
|
||||
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"),
|
||||
"--output-c-tables",
|
||||
rebase_path("$target_gen_dir/$library_name_slashes/cpp/tables.c"),
|
||||
]
|
||||
|
||||
if (fuchsia_target_api_level != -1) {
|
||||
args += [
|
||||
"--target-api-level",
|
||||
"${fuchsia_target_api_level}",
|
||||
]
|
||||
}
|
||||
|
||||
if (!defined(invoker.only_generate_tables) ||
|
||||
!invoker.only_generate_tables) {
|
||||
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/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" ]
|
||||
}
|
||||
|
||||
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") {
|
||||
fuchsia_fidl_library(subtarget_name) {
|
||||
meta = part_meta_rebased
|
||||
|
||||
# TODO(fxbug.dev/90838): Remove the zx special-case when generic
|
||||
# option is available.
|
||||
only_generate_tables = subtarget_name == "zx"
|
||||
}
|
||||
} 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 = "//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" ]
|
||||
}
|
|
@ -308,10 +308,8 @@ library_for_all_configs("libdart") {
|
|||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
extra_deps += [
|
||||
"$fuchsia_sdk_root/build/config:runtime_library_group",
|
||||
"$fuchsia_sdk_root/pkg/fdio",
|
||||
"$fuchsia_sdk_root/pkg/trace-engine",
|
||||
"//build/fuchsia/config/clang:c++-runtime-deps",
|
||||
]
|
||||
} else if (using_fuchsia_sdk) {
|
||||
extra_deps += [
|
||||
|
|
|
@ -992,11 +992,11 @@ executable("run_vm_tests") {
|
|||
|
||||
if (is_fuchsia) {
|
||||
if (using_fuchsia_gn_sdk) {
|
||||
include_dirs += [ "$fuchsia_sdk_path/pkg/trace-engine/include" ]
|
||||
libs = [ "zircon" ]
|
||||
}
|
||||
if (!using_fuchsia_gn_sdk && !using_fuchsia_sdk) {
|
||||
deps += [ "//zircon/system/ulib/trace" ]
|
||||
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" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,6 +232,8 @@ def ToGnArgs(args, mode, arch, target_os, sanitizer, verify_sdk_hash):
|
|||
gn_args['arm_version'] = 7
|
||||
gn_args['arm_float_abi'] = floatabi
|
||||
gn_args['arm_use_neon'] = True
|
||||
if gn_args['target_os'] == 'fuchsia':
|
||||
gn_args['fuchsia_target_api_level'] = 15
|
||||
|
||||
gn_args['is_debug'] = mode == 'debug'
|
||||
gn_args['is_release'] = mode == 'release'
|
||||
|
|
Loading…
Reference in a new issue