From af374852e999a8fd546c5968e88436d6cd2f5163 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 14 Mar 2024 20:43:31 -0700 Subject: [PATCH 1/5] remove build/fuchais --- build/fuchsia/BUILD.gn | 13 -- build/fuchsia/config.gni | 9 - build/fuchsia/fidl/BUILD.gn | 11 - build/fuchsia/fidl_gen_cpp.py | 99 --------- build/fuchsia/fuchsia.cipd.yaml | 6 - build/fuchsia/pave_device.py | 73 ------- build/fuchsia/pkg/BUILD.gn | 14 -- build/fuchsia/sdk.gni | 363 -------------------------------- build/fuchsia/sysroot/BUILD.gn | 11 - 9 files changed, 599 deletions(-) delete mode 100644 build/fuchsia/BUILD.gn delete mode 100644 build/fuchsia/config.gni delete mode 100644 build/fuchsia/fidl/BUILD.gn delete mode 100755 build/fuchsia/fidl_gen_cpp.py delete mode 100644 build/fuchsia/fuchsia.cipd.yaml delete mode 100755 build/fuchsia/pave_device.py delete mode 100644 build/fuchsia/pkg/BUILD.gn delete mode 100644 build/fuchsia/sdk.gni delete mode 100644 build/fuchsia/sysroot/BUILD.gn diff --git a/build/fuchsia/BUILD.gn b/build/fuchsia/BUILD.gn deleted file mode 100644 index bfedb7090c..0000000000 --- a/build/fuchsia/BUILD.gn +++ /dev/null @@ -1,13 +0,0 @@ -# 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", - ] -} diff --git a/build/fuchsia/config.gni b/build/fuchsia/config.gni deleted file mode 100644 index 69c6aa33fc..0000000000 --- a/build/fuchsia/config.gni +++ /dev/null @@ -1,9 +0,0 @@ -# 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. - -declare_args() { - # The target API level for this repository. A value of -1 - # means that no API level will be passed to the tools that consume it. - fuchsia_target_api_level = -1 -} diff --git a/build/fuchsia/fidl/BUILD.gn b/build/fuchsia/fidl/BUILD.gn deleted file mode 100644 index 9042bc3ebc..0000000000 --- a/build/fuchsia/fidl/BUILD.gn +++ /dev/null @@ -1,11 +0,0 @@ -# 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" ] -} diff --git a/build/fuchsia/fidl_gen_cpp.py b/build/fuchsia/fidl_gen_cpp.py deleted file mode 100755 index add4d9fc81..0000000000 --- a/build/fuchsia/fidl_gen_cpp.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/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()) diff --git a/build/fuchsia/fuchsia.cipd.yaml b/build/fuchsia/fuchsia.cipd.yaml deleted file mode 100644 index db20acd772..0000000000 --- a/build/fuchsia/fuchsia.cipd.yaml +++ /dev/null @@ -1,6 +0,0 @@ -package: flutter/fuchsia -description: Flutter Fuchsia Artifacts -install_mode: copy -data: - # Don't modify this! This is where the build script put all bucket artifacts. - - dir: flutter/ diff --git a/build/fuchsia/pave_device.py b/build/fuchsia/pave_device.py deleted file mode 100755 index 865ceddc10..0000000000 --- a/build/fuchsia/pave_device.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/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. - -'''Pave and boot one of the known target types with the images in the Fuchsia -SDK. -''' - -import argparse -import collections -import json -import os -import subprocess -import sys -import tempfile - -def SDKSubDirectory(): - if sys.platform == 'darwin': - return 'mac' - elif sys.platform.startswith('linux'): - return 'linux' - else: - raise Error('Unsupported platform.') - -def main(): - parser = argparse.ArgumentParser(); - - parser.add_argument('--target', - type=str, dest='target', choices=['chromebook'], default='chromebook') - - args = parser.parse_args() - - sdk_dir = os.path.join(os.path.dirname(sys.argv[0]), - "..", "..", "fuchsia", "sdk", SDKSubDirectory()) - sdk_dir = os.path.abspath(sdk_dir) - - assert os.path.exists(sdk_dir) - - # TODO(chinmaygarde): This will be patched in the future for arm64. - target_dir = os.path.join(sdk_dir, "target", "x64") - target_dir = os.path.abspath(target_dir) - assert os.path.exists(target_dir) - - with tempfile.NamedTemporaryFile() as ssh_keys_file: - ssh_keys = subprocess.check_output(['ssh-add', '-L']) - ssh_keys_file.write(ssh_keys) - ssh_keys_file.flush() - - if args.target == 'chromebook': - bootserver_command = [ - os.path.join(sdk_dir, "tools", "bootserver"), - "--boot", - os.path.join(target_dir, "fuchsia.zbi"), - "--fvm", - os.path.join(target_dir, "fvm.sparse.blk"), - "--zircona", - os.path.join(target_dir, "fuchsia.zbi"), - "--zirconr", - os.path.join(target_dir, "zircon.vboot"), - "--authorized-keys", - ssh_keys_file.name - ] - else: - raise Error('Target not specified.') - - subprocess.check_call(bootserver_command) - - return 0 - -if __name__ == '__main__': - sys.exit(main()) diff --git a/build/fuchsia/pkg/BUILD.gn b/build/fuchsia/pkg/BUILD.gn deleted file mode 100644 index 35c3c7a12a..0000000000 --- a/build/fuchsia/pkg/BUILD.gn +++ /dev/null @@ -1,14 +0,0 @@ -# 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", - ] -} diff --git a/build/fuchsia/sdk.gni b/build/fuchsia/sdk.gni deleted file mode 100644 index ef6f3d94de..0000000000 --- a/build/fuchsia/sdk.gni +++ /dev/null @@ -1,363 +0,0 @@ -# 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/fuchsia/config.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 = "//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 = "//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" ] - - config_name = "config_$target_name" - config(config_name) { - include_dirs = _include_dirs - libs = _libs - } - - group(target_name) { - public_configs = [ ":$config_name" ] - public_deps = _deps - } -} - -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 - } - } -} diff --git a/build/fuchsia/sysroot/BUILD.gn b/build/fuchsia/sysroot/BUILD.gn deleted file mode 100644 index 7c3ce59d04..0000000000 --- a/build/fuchsia/sysroot/BUILD.gn +++ /dev/null @@ -1,11 +0,0 @@ -# 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" ] -} From 6abe1640650bc821199009a92b8b025eaea32c12 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Mon, 18 Mar 2024 10:44:54 -0700 Subject: [PATCH 2/5] remove legacy api-level --- build/config/compiler/BUILD.gn | 9 --------- 1 file changed, 9 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 2eb442fdec..c07f8617eb 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -17,7 +17,6 @@ if (is_win) { import("//build/config/c++/c++.gni") import("//build/config/profiler.gni") import("//build/config/sanitizers/sanitizers.gni") -import("//build/fuchsia/config.gni") import("//build/toolchain/ccache.gni") import("//build/toolchain/clang.gni") import("//build/toolchain/wasm.gni") @@ -423,14 +422,6 @@ config("compiler") { } } - # Fuchsia-specific flags setup. - # ----------------------------- - if (is_fuchsia) { - if (fuchsia_target_api_level != -1) { - cflags += [ "-ffuchsia-api-level=${fuchsia_target_api_level}" ] - } - } - asmflags = cflags } From 8f1e58b2e219f5e78c55242bf503965cfc3a0f94 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Mon, 18 Mar 2024 11:20:04 -0700 Subject: [PATCH 3/5] missing change --- build/config/compiler/BUILD.gn | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index c07f8617eb..9172a434dd 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -422,6 +422,12 @@ config("compiler") { } } + # Fuchsia-specific flags setup. + # ----------------------------- + if (is_fuchsia) { + configs = ["//flutter/tools/fuchsia/gn-sdk/src/config:compiler"] + } + asmflags = cflags } @@ -572,6 +578,11 @@ config("runtime_library") { libs += [ "gcc" ] } } + + # Fuchsia standard library setup. + if (is_fuchsia) { + configs = ["//flutter/tools/fuchsia/gn-sdk/src/config:runtime_library"] + } } # default_warning_flags collects all warning flags that are used by default. From 8ffe6002e3c9f1fa7004bd8af43dcca8047e3c93 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 18 Mar 2024 11:19:09 -0700 Subject: [PATCH 4/5] Add a GN arg that configures the path to the buildtools tree (#838) This is in preparation for moving //buildtools out of the buildroot and into //flutter/buildtools --- build/config/clang/BUILD.gn | 7 +- build/config/compiler/BUILD.gn | 5 +- build/config/sanitizers/BUILD.gn | 3 +- build/fuchsia/sdk.gni | 364 +++++++++++++++++++++++++++++++ build/toolchain/android/BUILD.gn | 3 +- build/toolchain/fuchsia/BUILD.gn | 3 +- build/toolchain/linux/BUILD.gn | 5 +- build/toolchain/mac/BUILD.gn | 5 +- build/toolchain/rbe.gni | 4 +- build/toolchain/toolchain.gni | 4 + build/toolchain/win/BUILD.gn | 3 +- 11 files changed, 392 insertions(+), 14 deletions(-) create mode 100644 build/fuchsia/sdk.gni diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn index d927bd5165..0fbd8850de 100644 --- a/build/config/clang/BUILD.gn +++ b/build/config/clang/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/toolchain/clang.gni") +import("//build/toolchain/toolchain.gni") import("clang.gni") # Empty entry to satisfy ANGLE build, which tries to remove this config. @@ -26,10 +27,10 @@ config("extra_warnings") { group("llvm-symbolizer_data") { if (is_win) { - data = [ "//buildtools/windows-x64/bin/llvm-symbolizer.exe" ] + data = [ "$buildtools_path/windows-x64/bin/llvm-symbolizer.exe" ] } else if (is_mac) { - data = [ "//buildtools/mac-${host_cpu}/clang/bin/llvm-symbolizer" ] + data = [ "$buildtools_path/mac-${host_cpu}/clang/bin/llvm-symbolizer" ] } else if (is_linux) { - data = [ "//buildtools/linux-${host_cpu}/clang/bin/llvm-symbolizer" ] + data = [ "$buildtools_path/linux-${host_cpu}/clang/bin/llvm-symbolizer" ] } } diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 9172a434dd..51d0b97b27 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -19,6 +19,7 @@ import("//build/config/profiler.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/toolchain/ccache.gni") import("//build/toolchain/clang.gni") +import("//build/toolchain/toolchain.gni") import("//build/toolchain/wasm.gni") declare_args() { @@ -151,8 +152,8 @@ config("compiler") { if (use_custom_libcxx) { cflags_cc += [ "-nostdinc++" ] include_dirs = [ - "//buildtools/third_party/libc++/trunk/include", - "//buildtools/third_party/libc++abi/trunk/include", + "$buildtools_path/third_party/libc++/trunk/include", + "$buildtools_path/third_party/libc++abi/trunk/include", ] } } diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn index 96fe079b54..243f07e172 100644 --- a/build/config/sanitizers/BUILD.gn +++ b/build/config/sanitizers/BUILD.gn @@ -4,6 +4,7 @@ import("//build/config/c++/c++.gni") import("//build/config/sanitizers/sanitizers.gni") +import("//build/toolchain/toolchain.gni") # Contains the dependencies needed for sanitizers to link into executables and # shared_libraries. Unconditionally depend upon this target as it is empty if @@ -14,7 +15,7 @@ group("deps") { deps += [ ":options_sources" ] } if (use_custom_libcxx) { - deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ] + deps += [ "$buildtools_path/third_party/libc++:libcxx_proxy" ] } } diff --git a/build/fuchsia/sdk.gni b/build/fuchsia/sdk.gni new file mode 100644 index 0000000000..b8ebff3150 --- /dev/null +++ b/build/fuchsia/sdk.gni @@ -0,0 +1,364 @@ +# 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/fuchsia/config.gni") +import("//build/toolchain/toolchain.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 = "//fuchsia/sdk/$host_os" + fuchsia_toolchain_path = "$buildtools_path/${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 = "//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" ] + + config_name = "config_$target_name" + config(config_name) { + include_dirs = _include_dirs + libs = _libs + } + + group(target_name) { + public_configs = [ ":$config_name" ] + public_deps = _deps + } +} + +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 + } + } +} diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index 610f58cd87..d634c128c2 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn @@ -8,6 +8,7 @@ import("//build/toolchain/clang.gni") import("//build/toolchain/gcc_toolchain.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") +import("//build/toolchain/toolchain.gni") # The Android GCC toolchains share most of the same parameters, so we have this # wrapper around gcc_toolchain to avoid duplication of logic. @@ -69,7 +70,7 @@ template("android_toolchain") { assert(false, "Unknown host") } - prefix = rebase_path("//buildtools/$host_dir/clang/bin", root_build_dir) + prefix = rebase_path("$buildtools_path/$host_dir/clang/bin", root_build_dir) cc = "${compiler_prefix}${prefix}/clang" cxx = "${compiler_prefix}${prefix}/clang++" diff --git a/build/toolchain/fuchsia/BUILD.gn b/build/toolchain/fuchsia/BUILD.gn index a0634d20a9..c6f9cd0b23 100644 --- a/build/toolchain/fuchsia/BUILD.gn +++ b/build/toolchain/fuchsia/BUILD.gn @@ -4,6 +4,7 @@ import("//build/toolchain/clang.gni") import("//build/toolchain/goma.gni") +import("//build/toolchain/toolchain.gni") if (use_goma) { goma_prefix = "$goma_dir/gomacc " @@ -15,7 +16,7 @@ toolchain("fuchsia") { assert(target_cpu == "x64" || target_cpu == "arm64", "We currently only support 'x64' and 'arm64' targets for fuchsia.") toolchain_bin = - rebase_path("//buildtools/${host_os}-${host_cpu}/clang/bin", root_out_dir) + rebase_path("$buildtools_path/${host_os}-${host_cpu}/clang/bin", root_out_dir) fuchsia_sdk = rebase_path("//fuchsia/sdk/$host_os", root_out_dir) # We can't do string interpolation ($ in strings) on things with dots in diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn index 282b524474..140ec771db 100644 --- a/build/toolchain/linux/BUILD.gn +++ b/build/toolchain/linux/BUILD.gn @@ -7,6 +7,7 @@ import("//build/toolchain/ccache.gni") import("//build/toolchain/gcc_toolchain.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") +import("//build/toolchain/toolchain.gni") declare_args() { toolchain_prefix = "" @@ -33,10 +34,10 @@ if (use_goma) { if (host_cpu == "arm64") { rebased_clang_dir = - rebase_path("//buildtools/linux-arm64/clang/bin", root_build_dir) + rebase_path("$buildtools_path/linux-arm64/clang/bin", root_build_dir) } else { rebased_clang_dir = - rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir) + rebase_path("$buildtools_path/linux-x64/clang/bin", root_build_dir) } gcc_toolchain("arm") { diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index bd22b73c79..f573fe7209 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -11,14 +11,15 @@ import("//build/toolchain/clang.gni") import("//build/toolchain/clang_static_analyzer.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") +import("//build/toolchain/toolchain.gni") # Goma doesn't support the host-arm64 toolchain, so continue using Rosetta. if (host_cpu == "arm64" && !use_goma) { rebased_clang_dir = - rebase_path("//buildtools/mac-arm64/clang/bin", root_build_dir) + rebase_path("$buildtools_path/mac-arm64/clang/bin", root_build_dir) } else { rebased_clang_dir = - rebase_path("//buildtools/mac-x64/clang/bin", root_build_dir) + rebase_path("$buildtools_path/mac-x64/clang/bin", root_build_dir) } if (use_goma) { diff --git a/build/toolchain/rbe.gni b/build/toolchain/rbe.gni index 23905e86ee..d0df929f84 100644 --- a/build/toolchain/rbe.gni +++ b/build/toolchain/rbe.gni @@ -4,6 +4,8 @@ # Defines the configuration of RBE. +import("//build/toolchain/toolchain.gni") + declare_args() { # Set to true to enable distributed compilation using Goma. use_rbe = false @@ -31,7 +33,7 @@ declare_args() { rbe_platform = "" - rbe_dir = rebase_path("//buildtools/linux-x64/reclient") + rbe_dir = rebase_path("$buildtools_path/linux-x64/reclient") rbe_cfg = rebase_path("//flutter/build/rbe/rewrapper-linux.cfg") } diff --git a/build/toolchain/toolchain.gni b/build/toolchain/toolchain.gni index 8c1586f50f..e9b251537f 100644 --- a/build/toolchain/toolchain.gni +++ b/build/toolchain/toolchain.gni @@ -2,4 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +declare_args() { + buildtools_path = "//buildtools" +} + use_xcode_clang = false diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn index 781c094adf..fbfc3b320f 100644 --- a/build/toolchain/win/BUILD.gn +++ b/build/toolchain/win/BUILD.gn @@ -3,9 +3,10 @@ # found in the LICENSE file. import("//build/toolchain/rbe.gni") +import("//build/toolchain/toolchain.gni") import("//build/toolchain/win/win_toolchain_data.gni") -default_clang_base_path = "//buildtools/windows-x64/clang" +default_clang_base_path = "$buildtools_path/windows-x64/clang" declare_args() { # Path to the directory containing the VC binaries for the right From 1b1724cb8b4fc73d1dc3fac246f0f7d7b6c9532d Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Mon, 18 Mar 2024 12:02:45 -0700 Subject: [PATCH 5/5] remove build/fuchais --- build/fuchsia/sdk.gni | 364 ------------------------------------------ 1 file changed, 364 deletions(-) delete mode 100644 build/fuchsia/sdk.gni diff --git a/build/fuchsia/sdk.gni b/build/fuchsia/sdk.gni deleted file mode 100644 index b8ebff3150..0000000000 --- a/build/fuchsia/sdk.gni +++ /dev/null @@ -1,364 +0,0 @@ -# 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/fuchsia/config.gni") -import("//build/toolchain/toolchain.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 = "//fuchsia/sdk/$host_os" - fuchsia_toolchain_path = "$buildtools_path/${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 = "//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" ] - - config_name = "config_$target_name" - config(config_name) { - include_dirs = _include_dirs - libs = _libs - } - - group(target_name) { - public_configs = [ ":$config_name" ] - public_deps = _deps - } -} - -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 - } - } -}