From b01176fa575a58683bea4158c51cb331b22efdf0 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Wed, 21 Feb 2024 15:17:46 -0800 Subject: [PATCH 01/24] lets go --- .gitignore | 3 + DEPS | 14 + .../config/fuchsia/gn_configs.gni | 0 .../platform/fuchsia/dart-pkg/zircon/BUILD.gn | 2 +- .../dart_echo_server/BUILD.gn | 2 +- .../integration/embedder/child-view/BUILD.gn | 2 +- .../integration/embedder/parent-view/BUILD.gn | 2 +- .../tests/integration/mouse-input/BUILD.gn | 2 +- .../mouse-input/mouse-input-view/BUILD.gn | 4 +- .../tests/integration/text-input/BUILD.gn | 2 +- .../text-input/text-input-view/BUILD.gn | 4 +- .../tests/integration/touch-input/BUILD.gn | 2 +- .../embedding-flutter-view/BUILD.gn | 4 +- .../touch-input/touch-input-view/BUILD.gn | 4 +- tools/fuchsia/fidl/fidl_library.gni | 2 +- .../internal/flutter_dart_component.gni | 4 +- tools/fuchsia/fuchsia_archive.gni | 2 +- tools/fuchsia/gn-sdk/README.md | 73 ---- tools/fuchsia/gn-sdk/cmc.gni | 252 ------------ tools/fuchsia/gn-sdk/component.gni | 252 ------------ tools/fuchsia/gn-sdk/package.gni | 198 ---------- tools/fuchsia/gn-sdk/pm_tool.gni | 104 ----- .../fuchsia/gn-sdk/prepare_package_inputs.py | 373 ------------------ tools/fuchsia/gn-sdk/symbol_index.gni | 63 --- 24 files changed, 36 insertions(+), 1334 deletions(-) rename tools/fuchsia/gn-sdk/config/config.gni => build/config/fuchsia/gn_configs.gni (100%) delete mode 100644 tools/fuchsia/gn-sdk/README.md delete mode 100644 tools/fuchsia/gn-sdk/cmc.gni delete mode 100644 tools/fuchsia/gn-sdk/component.gni delete mode 100644 tools/fuchsia/gn-sdk/package.gni delete mode 100644 tools/fuchsia/gn-sdk/pm_tool.gni delete mode 100755 tools/fuchsia/gn-sdk/prepare_package_inputs.py delete mode 100644 tools/fuchsia/gn-sdk/symbol_index.gni diff --git a/.gitignore b/.gitignore index be9e96cceee3b..2f7c262793c6d 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,6 @@ app.*.symbols # The test-scripts from Chromium and managed by DEPS and gclient. /tools/fuchsia/test_scripts + +# The gn-sdk from Chromium and managed by DEPS and gclient. +/tools/fuchsia/gn-sdk diff --git a/DEPS b/DEPS index 7dee1028db86e..ced1f8b373c04 100644 --- a/DEPS +++ b/DEPS @@ -254,6 +254,10 @@ vars = { # will be used altogether with fuchsia-sdk to setup the build / test # environment. 'fuchsia_test_scripts_version': 'vf8imeAzGv_gjYQDoqub2laI-6nkB3gQNiGuVaFForMC', + + # The version / instance id of the cipd:chromium/fuchsia/gn-sdk which will be + # used altogether with fuchsia-sdk to generate gn based build rules. + 'fuchsia_gn_sdk_version': 'GEILx3JhMHrLut6n15rcvfmdudN_txrEbV70XHeqmusC', } gclient_gn_args_file = 'src/third_party/dart/build/config/gclient_args.gni' @@ -1018,6 +1022,16 @@ deps = { 'dep_type': 'cipd', }, + 'src/flutter/tools/fuchsia/gn-sdk': { + 'packages': [ + { + 'package': 'chromium/fuchsia/gn-sdk', + 'version': Var('fuchsia_gn_sdk_version'), + } + ], + 'dep_type': 'cipd', + }, + 'src/third_party/impeller-cmake-example': { 'url': Var('flutter_git') + '/third_party/impeller-cmake-example.git' + '@' + 'c44e8093972c969acf171be72591e408a85fdc53', 'condition': 'download_impeller_cmake_example', diff --git a/tools/fuchsia/gn-sdk/config/config.gni b/build/config/fuchsia/gn_configs.gni similarity index 100% rename from tools/fuchsia/gn-sdk/config/config.gni rename to build/config/fuchsia/gn_configs.gni diff --git a/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn b/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn index 2a67cf61993c7..a354ae5c5da59 100644 --- a/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn +++ b/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn @@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni") import("//flutter/testing/testing.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") config("zircon_config") { include_dirs = [ "." ] diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/BUILD.gn index dcc827d782bb8..100b1d04ff724 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/BUILD.gn @@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_component.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/embedder/child-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/embedder/child-view/BUILD.gn index dedf77c3eb950..22534d2566a09 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/embedder/child-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/embedder/child-view/BUILD.gn @@ -5,7 +5,7 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { package_name = "child-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/BUILD.gn index b5c8eec195340..1e0def98cbd1f 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/BUILD.gn @@ -5,7 +5,7 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { package_name = "parent-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/BUILD.gn index 661d374f4ecf2..1c1081d9bf299 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/BUILD.gn @@ -6,7 +6,7 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/fuchsia_archive.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") group("tests") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn index effd9f040543a..a0ca2b8005c23 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") dart_library("lib") { package_name = "mouse-input-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/text-input/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/text-input/BUILD.gn index 41bcd16e90a80..1e6e297ec8eb5 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/text-input/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/text-input/BUILD.gn @@ -6,7 +6,7 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/fuchsia_archive.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") group("tests") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn index a70b06ce1ad2c..fb6c43d0bb3e8 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") dart_library("lib") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/touch-input/BUILD.gn index 40942926e41f0..b3c4061d797d5 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/BUILD.gn @@ -6,7 +6,7 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/fuchsia_archive.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") group("tests") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn index b0b402777599e..0d026824ce0a3 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") dart_library("lib") { package_name = "embedding-flutter-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn index 8dd9006d810f6..1a6e4eafd43b4 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") dart_library("lib") { package_name = "touch-input-view" diff --git a/tools/fuchsia/fidl/fidl_library.gni b/tools/fuchsia/fidl/fidl_library.gni index a3722c155fe62..22236cedb7a19 100644 --- a/tools/fuchsia/fidl/fidl_library.gni +++ b/tools/fuchsia/fidl/fidl_library.gni @@ -5,7 +5,7 @@ import("//flutter/tools/executable_action.gni") import("//flutter/tools/fuchsia/fidl/fidl.gni") import("//flutter/tools/fuchsia/fidl/toolchain.gni") -import("//flutter/tools/fuchsia/gn-sdk/config/config.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/config/config.gni") # Generates some representation of a FIDL library that's consumable by Language # bindings generators. diff --git a/tools/fuchsia/flutter/internal/flutter_dart_component.gni b/tools/fuchsia/flutter/internal/flutter_dart_component.gni index 35e616a0ce54c..07ed4671c3f2b 100644 --- a/tools/fuchsia/flutter/internal/flutter_dart_component.gni +++ b/tools/fuchsia/flutter/internal/flutter_dart_component.gni @@ -7,8 +7,8 @@ import("//flutter/tools/fuchsia/dart/config.gni") import("//flutter/tools/fuchsia/dart/dart.gni") import("//flutter/tools/fuchsia/dart/dart_package_config.gni") import("//flutter/tools/fuchsia/dart/kernel/dart_kernel.gni") -import("//flutter/tools/fuchsia/gn-sdk/cmc.gni") -import("//flutter/tools/fuchsia/gn-sdk/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/cmc.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") # Defines a component which will run in a flutter_runner or dart_runner # diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 5606565987a90..0ac36e8cc8214 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -5,7 +5,7 @@ import("//build/fuchsia/config.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") -import("//flutter/tools/fuchsia/gn-sdk/config/config.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/config/config.gni") # Compiles a CML file for a V2 component. # diff --git a/tools/fuchsia/gn-sdk/README.md b/tools/fuchsia/gn-sdk/README.md deleted file mode 100644 index c46e963a0dab6..0000000000000 --- a/tools/fuchsia/gn-sdk/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# flutter/tools/fuchsia/gn-sdk - -This directory contains a few build rules imported from an August 2021 snapshot -of the Fuchsia GN SDK, with small (required) path adjustments. - -The Dart Fuchsia tests require the Fuchsia _Core_ SDK, and the build rules in -the GN SDK require slight path modification to support building against the -Fuchsia Core SDK from a different location. Therefore, the Fuchsia Core SDK is -downloaded via `gclient sync` (versioned according to its fingerprint in DEPS), -and the modified build rules from Fuchsia GN SDK are, for now, copied to -and maintained in flutter/engine. - -It is not yet clear if Fuchsia will want to provide SDK resources that support -GN build rules with Dart libraries and tests, but if that does happen, these -files should be replaced by the Fuchsia-provided build rules. - - - - -## Other GN SDK build rules to be considered - - - -It may be wise to consider replacing a few other duplicated (but differently -built) build rules in `//flutter/tools/fuchsia` and `//build` with up-to-date -(via `gclient sync`) rules from the GN SDK. Some of the flutter versions of -these rules were originally imported from the fuchsia.git `//build` directory, -and tailored for flutter. The GN SDK build rules offer simplified versions of -these rules, pre-tailored for the Fuchsia SDK layout and out-of-tree use cases. - -Known build files in this category, with the same file name and similar GN -templates, in both Flutter and Fuchsia GN SDK, include: - -* fidl_library.gni -* gn_run_binary.py - -Other Flutter GN SDK build rules that could replace flutter implemented logic -include: - -* gn-sdk/build/fuchsia_sdk_pkg.gni could potentially replace some of the build - logic in `//flutter/tools/fuchsia/sdk/sdk_targets.gni` and/or - `//build/fuchsia/sdk.gni` -* gn-sdk/build/pm_tool.gni rules could potentially replace some flutter pm - invocations - -SDK build logic that might improve GN target implementations in flutter include: - -* gn-sdk/build/test.gni diff --git a/tools/fuchsia/gn-sdk/cmc.gni b/tools/fuchsia/gn-sdk/cmc.gni deleted file mode 100644 index 99cdbc1c5e7c4..0000000000000 --- a/tools/fuchsia/gn-sdk/cmc.gni +++ /dev/null @@ -1,252 +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("config/config.gni") - -# Internal template for the cmc tool. -# -# Invokes cmc -# -# Example: -# -# ``` -# _cmc_tool("validate_cmx") { -# inputs = [ manifest ] -# outputs = [ stamp_file ] -# -# args = [ -# "--stamp", -# rebase_path(stamp_file, root_build_dir), -# "validate", -# rebase_path(invoker.manifest), -# ] -# } -# ``` -# -# Parameters: -# -# inputs (required) -# List of files that are input for cmc. -# Type: list(path) -# -# outputs (required) -# List paths that are output for the run of cmc. -# Type: list(path) -# -# args (required) -# List command line args for cmc. -# Type: list(path) -# -# deps -# public_deps -# testonly -# visibility -# -template("_cmc_tool") { - action(target_name) { - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "testonly", - "visibility", - ]) - script = "//build/gn_run_binary.py" - _cmc_tool_path = "${fuchsia_tool_dir}/cmc" - - assert(defined(invoker.inputs), "inputs is a required parameter.") - assert(defined(invoker.outputs), "outputs is a required parameter.") - assert(defined(invoker.args), "args is a required parameter.") - - inputs = - [ - _cmc_tool_path, - - # Depend on the SDK hash, to ensure rebuild if the SDK tools change. - fuchsia_sdk_manifest_file, - ] + invoker.inputs - - outputs = invoker.outputs - - args = [ rebase_path(_cmc_tool_path, root_build_dir) ] + invoker.args - } -} - -# Compiles a Components Framework v2 manifest (.cml) file to .cm -# -# Example: -# -# ``` -# cmc_compile(_compiled_manifest_target) { -# forward_variables_from(invoker, [ "deps" ]) -# manifest = rebase_path(manifest) -# } -# ``` -# -# Parameters: -# -# manifest (required) -# The input Component Framework v2 manifest source (.cml) file. -# The file must have the extension ".cml". -# -# output_name (optional) -# Name of the output file to generate. Defaults to $target_name. -# This should not include a file extension (.cm) -# -# deps -# public_deps -# testonly -# visibility -# -template("cmc_compile") { - output_name = target_name - if (defined(invoker.output_name)) { - output_name = invoker.output_name - } - - _cmc_tool(target_name) { - forward_variables_from(invoker, - [ - "deps", - "manifest", - "public_deps", - "testonly", - "visibility", - ]) - assert(defined(manifest), "manifest file required") - - inputs = [ manifest ] - - output_file = "$target_out_dir/$output_name.cm" - outputs = [ output_file ] - - depfile = "$target_out_dir/$target_name.d" - - args = [ - "compile", - rebase_path(manifest, root_build_dir), - "--output", - rebase_path(output_file, root_build_dir), - "--includeroot", - rebase_path("//", root_build_dir), - "--includepath", - rebase_path("$fuchsia_sdk/pkg/", root_build_dir), - "--depfile", - rebase_path(depfile, root_build_dir), - ] - } -} - -# Validates a component manifest file -# -# The cmc_validate template will ensure that a given cmx file is conformant to -# the cmx schema, as defined by //tools/cmc/schema.json. A stamp file is -# generated to mark that a given cmx file has passed. -# -# Parameters: -# -# manifest (required) -# [file] The path to the cmx file that is to be validated -# -# deps -# testonly -# visibility -# -template("cmc_validate") { - _cmc_tool(target_name) { - forward_variables_from(invoker, - [ - "manifest", - "deps", - "testonly", - "visibility", - ]) - stamp_file = "$target_gen_dir/$target_name.verified" - - assert(defined(manifest), "manifest file required") - - inputs = [ manifest ] - - outputs = [ stamp_file ] - - args = [ - "--stamp", - rebase_path(stamp_file, root_build_dir), - "validate", - rebase_path(invoker.manifest), - ] - } -} - -# Merges multiple component manifest files into one. -# -# Combines mutliple component manifests into a single manifest. -# This is useful for merging fragments of sandbox configurations into -# a single component manifest. -# -# Example -# -# ``` -# cmc_merge("combined_cmx") { -# sources = ["sandbox.cmx", "services.cmx", "program.cmx"] -# output_name = "my-component.cmx" -# } -# ``` -# -# Parameters -# -# sources -# The list of cmx files to merge together. -# -# Type: list of strings (filepath) -# -# output_name [optional] -# The name of the merged cmx file. This file is created in $target_out_dir. -# If not specified, $target_name.cmx is used. -# -# Type: string -# -# Standard parameters: -# deps -# testonly -# visibility -# -template("cmc_merge") { - _cmc_tool(target_name) { - forward_variables_from(invoker, - [ - "deps", - "output_name", - "sources", - "testonly", - "visibility", - ]) - if (!defined(output_name)) { - # TODO(richkadel): THE GN SDK VERSION OF CMC.GNI IS INCONSISTENT WITH fuchsia.git! - # The default name should be `target_name`, which should already include the - # extension... Or change fuchsia.git to add the extension, and fix calls that - # append .cmx to the target name, like flutter_dart_component.gni. - # With the target_name representing the base of the CMC filename results - # in a "Duplicate definition" error in GN, because "flutter_component()" - # typically has the same target name. My current workaround is to - # redundantly assign `output_name` to the same value as the `target_name`, - # which includes the `.cmx` extension. - output_name = "${target_name}.cmx" - } - - merged_output = "${target_out_dir}/${output_name}" - inputs = invoker.sources - outputs = [ merged_output ] - - args = [ - "merge", - "--output", - rebase_path(merged_output, root_build_dir), - ] - - foreach(source, sources) { - args += [ rebase_path(source, root_build_dir) ] - } - } -} diff --git a/tools/fuchsia/gn-sdk/component.gni b/tools/fuchsia/gn-sdk/component.gni deleted file mode 100644 index 6c06b45286ebc..0000000000000 --- a/tools/fuchsia/gn-sdk/component.gni +++ /dev/null @@ -1,252 +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("cmc.gni") - -declare_args() { - # Enable code coverage for Fuchsia components. Only applies to v1 components. - fuchsia_code_coverage = false -} - -# Defines a Fuchsia component. -# See: https://fuchsia.dev/fuchsia-src/glossary#component -# -# A component is defined by a component manifest. -# A component is a unit of executable software on Fuchsia. When the componet is executed, there are usually many files -# needed at runtime, such as the executable itself, shared libraries, and possibly other data resources. These files are -# specified by using the GN concept of "data_deps". -# -# Components are distributed using a fuchsia package which can contain multiple components. The component manifest and -# the runtime dependencies of the component are packaged using the fuchsia_package rule. -# -# By default, the runtime depenencies of the component are included in the package using relative paths calcualted from -# the "closest" root of: $root_gen_dir, $root_dir, $out_dir. If a specific path is desired in the package, the "resources" parameter can -# be used to explicitly specify the path of a specific file. -# -# A component is launched by a URL which identifies the package and the component manifest. -# See: https://fuchsia.dev/fuchsia-src/glossary#component_url -# -# Example -# -# ``` -# fuchsia_component("my_component") { -# manifest = "meta/component-manifest.cmx" -# resources = [ -# { -# path = "testdata/use_case1.json" -# dest = "data/testdata/use_case1.json" -# }, -# ] -# data_deps = [ ":hello_world_executable"] -# } -# ``` -# -# Parameters -# -# manifest -# The source manifest file for this component. This can be either v1 (.cmx) -# or v2 (.cml) manifest. -# -# Type: string (filepath) -# -# data_deps -# The labels of targets that generate the files needed at runtime by the component. -# At minimum, this should include the label of the binary to include in the component. -# -# Type: list of labels -# -# manifest_output_name [optional] -# The name of the manifest file contained in the distribution that this -# component is included in. The output name should have no extension or -# prefixes. The resulting filename will have the extension correct for the -# manifest version. For example, if `manifest` is "foo.cmx" -# and `manifest_output_name` is "bar", the filename will be "bar.cmx". If -# `manifest` is "foo.cml" (a v2 manifest), the filename will be "bar.cm". -# -# Type: string -# Default: The base file name of `manifest` without an extension. -# -# resources [optional] -# Lists additional files to include for runtime access by the component. -# Defines the resources in a package containing this component. A resource -# is a data file that may be produced by the build system, checked in to a -# source repository, or produced by another system that runs before the -# build. Resources are placed in the `data/` directory of the assembled -# package. -# -# Type: list of scopes. Entries in a scope in the resources list: -# path (required) -# Location of resource in source or build directory. If the -# resource is checked in, this will typically be specified -# as a path relative to the BUILD.gn file containing the -# `package()` target. If the resource is generated, this will -# typically be specified relative to `$target_gen_dir`. -# -# dest (required) string (path) Location the resource will be placed within `data/`. -# -# Standard parameters: -# deps -# testonly -# visibility -# -# Metadata -# contents - list of scopes describing files for this component. This metadata is consumed by -# The fuchsia_package rule, which describes the entries used. -# Entries in scope: -# type: the usage type of the element, manifest or resource. -# Each type can have specific properties included in the scope. -# source [type == manifest || resource] The source file to include in -# the package for this component. In the case of v2 components, -# this is the compiled manifest. -# output_name [type == manifest] The basename of the manifest as it should appear in the package. -# manifest_version [type == manifest] -# dest: [type == resource] The package relative path of the resource. - -template("fuchsia_component") { - forward_variables_from(invoker, - [ - "manifest", - "manifest_output_name", - ]) - - assert(defined(manifest), "manifest file required for this component") - - if (!defined(manifest_output_name)) { - manifest_output_name = get_path_info(manifest, "name") - } - - # Determine manifest_version from the `manifest` file extension. - _manifest_extension = get_path_info(manifest, "extension") - assert(_manifest_extension == "cmx" || _manifest_extension == "cml", - "Manifest file extension must be .cmx or .cml") - if (_manifest_extension == "cmx") { - _manifest_version = "v1" - } else if (_manifest_extension == "cml") { - _manifest_version = "v2" - } - - if (fuchsia_code_coverage) { - if (_manifest_version == "v1") { - merged_manifest = "${target_name}-coverage.cmx" - cmc_merge(merged_manifest) { - forward_variables_from(invoker, - [ - "deps", - "testonly", - ]) - sources = [ - "${fuchsia_sdk}/build/enable_coverage_data.cmx", - manifest, - ] - output_name = merged_manifest - } - manifest = "${target_out_dir}/${merged_manifest}" - } - } - - # The component manifest validated using cmx_validation for v1, - # or cmc_compile for v2. - _cm_validation_target = - "${target_name}_validate_" + get_path_info(manifest, "file") - - if (_manifest_version == "v1") { - cmc_validate(_cm_validation_target) { - forward_variables_from(invoker, [ "testonly" ]) - manifest = manifest - deps = [] - if (defined(invoker.deps)) { - deps += invoker.deps - } - if (fuchsia_code_coverage) { - deps += [ ":${merged_manifest}" ] - } - } - - _manifest_source = manifest - } else if (_manifest_version == "v2") { - cmc_compile(_cm_validation_target) { - forward_variables_from(invoker, - [ - "deps", - "testonly", - ]) - manifest = rebase_path(manifest) - } - - _compiled_manifest_outputs = get_target_outputs(":$_cm_validation_target") - _manifest_source = _compiled_manifest_outputs[0] - } - - group(target_name) { - forward_variables_from(invoker, - [ - "data", - "deps", - "data_deps", - "resources", - "resources_in_json_files", - "testonly", - "visibility", - ]) - - # Data is used for adding files as runtime dependencies. Files used as - # sources in the resources parameter are added as data to make sure - # non-generated files listed are captured as dependencies. - if (!defined(data)) { - data = [] - } - - if (!defined(resources)) { - resources = [] - } - - # TODO(richkadel): Changed from the Fuchsia GN SDK to add - # `resources_in_json_files, so additional resources could be computed at - # compile time (in this case, compiled Dart libraries). - if (!defined(resources_in_json_files)) { - resources_in_json_files = [] - } - - if (!defined(deps)) { - deps = [] - } - deps += [ ":$_cm_validation_target" ] - - # Create the component metadata entries. These capture the manifest information and - # the resources parameter contents. The metadata is intended for the fuchsia_package rule. - component_contents = [ - { - type = "manifest" - source = rebase_path(get_path_info(_manifest_source, "abspath")) - output_name = manifest_output_name - manifest_version = _manifest_version - }, - ] - foreach(resource, resources) { - data += [ resource.path ] - component_contents += [ - { - type = "resource" - source = rebase_path(resource.path) - dest = resource.dest - }, - ] - } - foreach(file, resources_in_json_files) { - data += [ file ] - component_contents += [ - { - type = "json_of_resources" - source = file - }, - ] - } - - # The contents of the component are enumerated in the - # metadata. - metadata = { - contents = [ component_contents ] - } - } -} diff --git a/tools/fuchsia/gn-sdk/package.gni b/tools/fuchsia/gn-sdk/package.gni deleted file mode 100644 index 2b7ce3acf9e07..0000000000000 --- a/tools/fuchsia/gn-sdk/package.gni +++ /dev/null @@ -1,198 +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("config/config.gni") -import("pm_tool.gni") -import("symbol_index.gni") - -# Define a Fuchsia component package target. -# -# Parameters -# -# package_name: [Optional] -# Name of the package. Defaults to target_name. -# -# Type: string -# -# excluded_files: [Optional] -# List of files to exclude from the package. -# -# Type: list of file paths -# -# fidl_ref_out_dir: [Optional] -# Directory for writing out $package_name_all_fidl_refs.txt -# that contains the paths to the internal representation (IR) of every -# FIDL interface referenced in the package. Defaults to $root_build_dir/fidl_refs. -# -# ids_txt_output_path: [Optional] -# Path to write out the ids.txt file for the symbols in the binaries. -# Defaults to `${target_gen_dir}/${package_name}/ids.txt` -# -# Type: file path -# -# deps -# Required: List of fuchsia_component() targets that this -# package contains. -# -template("fuchsia_package") { - if (!defined(invoker.package_name)) { - package_name = target_name - } else { - package_name = invoker.package_name - } - if (!defined(invoker.excluded_files)) { - excluded_files = [] - } else { - excluded_files = invoker.excluded_files - } - if (!defined(invoker.fidl_ref_out_dir)) { - fidl_ref_out_dir = "$root_build_dir/fidl_refs" - } else { - fidl_ref_out_dir = invoker.fidl_ref_out_dir - } - - _depfile = "${target_gen_dir}/${target_name}_stamp.d" - - # target names - _manifest_target = "${target_name}__archive-manifest" - _metadata_target = "${target_name}__archive-metadata" - _packaged_components_metadata_target = - "${target_name}__packaged_components_metadata" - - # output values - _pkg_out_dir = "${target_gen_dir}/${package_name}" - _runtime_deps_file = "$_pkg_out_dir/${package_name}.runtime_deps" - _archive_manifest = "$_pkg_out_dir/${package_name}.manifest" - _build_ids_file = "$_pkg_out_dir/ids.txt" - if (defined(invoker.ids_txt_output_path)) { - _build_ids_file = invoker.ids_txt_output_path - } - _package_file = "$_pkg_out_dir/package" - _fidl_json_refs_file = "${fidl_ref_out_dir}/${package_name}_all_fidl_refs.txt" - - _packaged_components_metadata_file = - "${target_gen_dir}/${package_name}_packaged_components_metadata.json" - - _package_deps = [] - if (defined(invoker.deps)) { - _package_deps += invoker.deps - } - if (defined(invoker.data_deps)) { - _package_deps += invoker.data_deps - } - - # Generates a JSON file containing the contents of each of the - # components being included in this package. - generated_file(_packaged_components_metadata_target) { - forward_variables_from(invoker, [ "testonly" ]) - outputs = [ _packaged_components_metadata_file ] - data_keys = [ "contents" ] - output_conversion = "json" - deps = _package_deps - } - - # A generated file that lists all of the .fidl.json files - # used in this package. This is useful for tools that need - # to decode fidl. - generated_file("${package_name}_all_fidl_refs") { - testonly = true - deps = _package_deps - - outputs = [ _fidl_json_refs_file ] - data_keys = [ "fidl_json" ] - } - - action(_manifest_target) { - forward_variables_from(invoker, [ "testonly" ]) - script = "//flutter/tools/fuchsia/gn-sdk/prepare_package_inputs.py" - - inputs = [ - _runtime_deps_file, - _packaged_components_metadata_file, - ] - - outputs = [ - _archive_manifest, - _build_ids_file, - _package_file, - ] - - data_deps = _package_deps - - deps = _package_deps - deps += [ ":${_packaged_components_metadata_target}" ] - if (defined(invoker.deps)) { - deps += invoker.deps - } - - # Use a depfile to trigger package rebuilds if any of the files (static - # assets, shared libraries, etc.) included by the package have changed. - depfile = _depfile - - args = [ - "--root-dir", - rebase_path("//", root_build_dir), - "--out-dir", - rebase_path(root_out_dir, root_build_dir), - "--app-name", - package_name, - "--runtime-deps-file", - rebase_path(_runtime_deps_file, root_build_dir), - "--depfile-path", - rebase_path(_depfile, root_build_dir), - "--manifest-path", - rebase_path(_archive_manifest, root_build_dir), - "--build-ids-file", - rebase_path(_build_ids_file, root_build_dir), - "--json-file", - rebase_path(_packaged_components_metadata_file), - ] - - if (defined(excluded_files)) { - foreach(filename, excluded_files) { - args += [ - "--exclude-file", - filename, - ] - } - } - write_runtime_deps = _runtime_deps_file - - # Allows ids.txt paths to be collected by dependent targets. - metadata = { - ids_txt_paths = [ _build_ids_file ] - } - } - - # Creates a Fuchsia metadata package. - fuchsia_pm_tool(_metadata_target) { - forward_variables_from(invoker, [ "testonly" ]) - package_name = package_name - command = "build" - archive_manifest = _archive_manifest - public_deps = [ ":$_manifest_target" ] - } - - fuchsia_pm_tool(target_name) { - forward_variables_from(invoker, [ "testonly" ]) - package_name = package_name - command = "archive" - archive_manifest = _archive_manifest - public_deps = [ ":$_metadata_target" ] - if (!defined(deps)) { - deps = [] - } - if (defined(fuchsia_auto_index_symbols) && fuchsia_auto_index_symbols) { - deps += [ ":${target_name}_fuchsia_auto_index_symbols" ] - } - } - - if (defined(fuchsia_auto_index_symbols) && fuchsia_auto_index_symbols) { - fuchsia_symbol_index_tool("${target_name}_fuchsia_auto_index_symbols") { - forward_variables_from(invoker, [ "testonly" ]) - symbols = _build_ids_file - deps = [ ":$_metadata_target" ] - } - } -} diff --git a/tools/fuchsia/gn-sdk/pm_tool.gni b/tools/fuchsia/gn-sdk/pm_tool.gni deleted file mode 100644 index 73dabf0d6be02..0000000000000 --- a/tools/fuchsia/gn-sdk/pm_tool.gni +++ /dev/null @@ -1,104 +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("config/config.gni") - -# Template for running the pm tool for packaging fuchsia packages. -# -# Parameters -# package_name - defaults to target_name -# archive_manifest - required -# command - the packaging step to perform valid steps are build, archive -# -# Forwarded parameters -# testonly -# deps -# public_deps -# visibility -template("fuchsia_pm_tool") { - forward_variables_from(invoker, [ "*" ]) - action(target_name) { - forward_variables_from(invoker, - [ - "testonly", - "deps", - "public_deps", - "visibility", - ]) - _valid_commands = [ - "build", - "archive", - ] - assert(defined(invoker.archive_manifest), "archive_manifest is required.") - archive_manifest = invoker.archive_manifest - - assert(defined(invoker.command), "command is required") - assert(invoker.command == "build" || invoker.command == "archive", - "invalid command. valid commands are ${_valid_commands}") - command = invoker.command - - package_name = target_name - if (defined(invoker.package_name)) { - package_name = invoker.package_name - } - - # tool path - _pm_tool_path = "${fuchsia_tool_dir}/pm" - script = "//build/gn_run_binary.py" - - # output files - _pkg_out_dir = "${target_gen_dir}/${package_name}" - _meta_far_file = "${_pkg_out_dir}/meta.far" - - inputs = [ - # Depend on the SDK hash, to ensure rebuild if the SDK tools change. - fuchsia_sdk_manifest_file, - _pm_tool_path, - archive_manifest, - ] - - if (command == "build") { - _pkg_output_manifest = "${_pkg_out_dir}/package_manifest.json" - outputs = [ - _meta_far_file, - "${_pkg_out_dir}/meta/contents", - "${_meta_far_file}.merkle", - _pkg_output_manifest, - ] - depfile = "${_meta_far_file}.d" - } else { - inputs += [ _meta_far_file ] - - _final_far_file = "$_pkg_out_dir/${package_name}.far" - outputs = [ _final_far_file ] - } - - args = [ - rebase_path(_pm_tool_path, root_build_dir), - "-o", - rebase_path(_pkg_out_dir, root_build_dir), - "-m", - rebase_path(archive_manifest, root_build_dir), - "-n", - package_name, - ] - if (command == "build") { - assert(fuchsia_target_api_level != -1, - "Must set a target api level when creating an archive") - args += [ - "--api-level=${fuchsia_target_api_level}", - command, - "-output-package-manifest", - rebase_path(_pkg_output_manifest, root_build_dir), - "-depfile", - ] - } else if (command == "archive") { - args += [ - command, - "--output", - rebase_path("${_pkg_out_dir}/${package_name}"), - ] - } - } -} diff --git a/tools/fuchsia/gn-sdk/prepare_package_inputs.py b/tools/fuchsia/gn-sdk/prepare_package_inputs.py deleted file mode 100755 index aa9259330c86e..0000000000000 --- a/tools/fuchsia/gn-sdk/prepare_package_inputs.py +++ /dev/null @@ -1,373 +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. - -# -# Derivative work of https://chromium.googlesource.com/chromium/src/+/HEAD/build/config/fuchsia/prepare_package_inputs.py -# - -"""Creates a archive manifest used for Fuchsia package generation.""" - -import argparse -import json -import os -import shutil -import subprocess -import sys - -# File extension of a component manifest for each Component Framework version -MANIFEST_VERSION_EXTENSIONS = {"v1": ".cmx", "v2": ".cm"} - - -def make_package_path(file_path, roots): - """Computes a path for |file_path| relative to one of the |roots|. - - Args: - file_path: The file path to relativize. - roots: A list of directory paths which may serve as a relative root for - |file_path|. - - For example: - * make_package_path('/foo/bar.txt', ['/foo/']) 'bar.txt' - * make_package_path('/foo/dir/bar.txt', ['/foo/']) 'dir/bar.txt' - * make_package_path('/foo/out/Debug/bar.exe', ['/foo/', '/foo/out/Debug/']) 'bar.exe' - """ - - # Prevents greedily matching against a shallow path when a deeper, better - # matching path exists. - roots.sort(key=len, reverse=True) - - for next_root in roots: - if not next_root.endswith(os.sep): - next_root += os.sep - - if file_path.startswith(next_root): - relative_path = file_path[len(next_root):] - return relative_path - - return file_path - - -def _get_stripped_path(bin_path): - """Finds the stripped version of |bin_path| in the build output directory. - - returns |bin_path| if no stripped path is found. - """ - stripped_path = bin_path.replace('lib.unstripped/', 'lib/').replace('exe.unstripped/', '') - if os.path.exists(stripped_path): - return stripped_path - else: - return bin_path - - -def _is_binary(path): - """Checks if the file at |path| is an ELF executable. - - This is done by inspecting its FourCC header. - """ - - with open(path, 'rb') as f: - file_tag = f.read(4) - return file_tag == b'\x7fELF' - - -def _write_build_ids_txt(binary_paths, ids_txt_path): - """Writes an index text file mapping build IDs to unstripped binaries.""" - - READELF_FILE_PREFIX = 'File: ' - READELF_BUILD_ID_PREFIX = 'Build ID: ' - - # List of binaries whose build IDs are awaiting processing by readelf. - # Entries are removed as readelf's output is parsed. - unprocessed_binary_paths = set(binary_paths) - build_ids_map = {} - - # Sanity check that unstripped binaries do not also have their stripped - # counterpart listed. - for binary_path in binary_paths: - stripped_binary_path = _get_stripped_path(binary_path) - if stripped_binary_path != binary_path: - unprocessed_binary_paths.discard(stripped_binary_path) - - with open(ids_txt_path, 'w') as ids_file: - # TODO(richkadel): This script (originally from the Fuchsia GN SDK) was - # changed, adding this `if unprocessed_binary_paths` check, because for - # the Dart packages I tested (child-view and parent-view), this was - # empty. Update the Fuchsia GN SDK? (Or figure out if the Dart packages - # _should_ have at least one unprocessed_binary_path?) - if unprocessed_binary_paths: - # Create a set to dedupe stripped binary paths in case both the stripped and - # unstripped versions of a binary are specified. - readelf_stdout = subprocess.check_output(['readelf', '-n'] + - sorted(unprocessed_binary_paths)).decode('utf8') - - if len(binary_paths) == 1: - # Readelf won't report a binary's path if only one was provided to the - # tool. - binary_path = binary_paths[0] - else: - binary_path = None - - for line in readelf_stdout.split('\n'): - line = line.strip() - - if line.startswith(READELF_FILE_PREFIX): - binary_path = line[len(READELF_FILE_PREFIX):] - assert binary_path in unprocessed_binary_paths - - elif line.startswith(READELF_BUILD_ID_PREFIX): - # Paths to the unstripped executables listed in "ids.txt" are specified - # as relative paths to that file. - unstripped_rel_path = os.path.relpath( - os.path.abspath(binary_path), os.path.dirname(os.path.abspath(ids_txt_path)) - ) - - build_id = line[len(READELF_BUILD_ID_PREFIX):] - build_ids_map[build_id] = unstripped_rel_path - unprocessed_binary_paths.remove(binary_path) - - for id_and_path in sorted(build_ids_map.items()): - ids_file.write(id_and_path[0] + ' ' + id_and_path[1] + '\n') - - # Did readelf forget anything? Make sure that all binaries are accounted for. - assert not unprocessed_binary_paths - - -def _parse_component(component_info_file): - component_info = json.load(open(component_info_file, 'r')) - return component_info - - -def _get_component_manifests(component_info): - return [c for c in component_info if c.get('type') == 'manifest'] - - -# TODO(richkadel): Changed, from the Fuchsia GN SDK version to add this function -# and related code, to include support for a file of resources that aren't known -# until compile time. -def _get_resource_items_from_json_items(component_info): - nested_resources = [] - files = [c.get('source') for c in component_info if c.get('type') == 'json_of_resources'] - for json_file in files: - for resource in _parse_component(json_file): - nested_resources.append(resource) - return nested_resources - - -def _get_resource_items(component_info): - return ([c for c in component_info if c.get('type') == 'resource'] + - _get_resource_items_from_json_items(component_info)) - - -def _get_expanded_files(runtime_deps_file): - """ Process the runtime deps file for file paths, recursively walking - directories as needed. - - Returns a set of expanded files referenced by the runtime deps file. - """ - - # runtime_deps may contain duplicate paths, so use a set for - # de-duplication. - expanded_files = set() - for next_path in open(runtime_deps_file, 'r'): - next_path = next_path.strip() - if os.path.isdir(next_path): - for root, _, files in os.walk(next_path): - for current_file in files: - if current_file.startswith('.'): - continue - expanded_files.add(os.path.normpath(os.path.join(root, current_file))) - else: - expanded_files.add(os.path.normpath(next_path)) - return expanded_files - - -def _write_gn_deps_file( - depfile_path, package_manifest, component_manifests, out_dir, expanded_files -): - with open(depfile_path, 'w') as depfile: - deps_list = [os.path.relpath(f, out_dir) for f in expanded_files] - deps_list.extend(component_manifests) - - # The deps file is space-delimited, so filenames containing spaces - # must have them escaped. - deps_list = [f.replace(' ', '\\ ') for f in deps_list] - - deps_string = ' '.join(sorted(deps_list)) - depfile.write('%s: %s' % (package_manifest, deps_string)) - - -def _write_meta_package_manifest( - manifest_entries, manifest_path, app_name, out_dir, package_version -): - # Write meta/package manifest file and add to archive manifest. - meta_package = os.path.join(os.path.dirname(manifest_path), 'package') - with open(meta_package, 'w') as package_json: - json_payload = {'version': package_version, 'name': app_name} - json.dump(json_payload, package_json) - package_json_filepath = os.path.relpath(package_json.name, out_dir) - manifest_entries['meta/package'] = package_json_filepath - - -def _write_component_manifest(manifest_entries, component_info, archive_manifest_path, out_dir): - """Copy component manifest files and add to archive manifest. - - Raises an exception if a component uses a unknown manifest version. - """ - - for component_manifest in _get_component_manifests(component_info): - manifest_version = component_manifest.get('manifest_version') - - if manifest_version not in MANIFEST_VERSION_EXTENSIONS: - raise Exception('Unknown manifest_version: {}'.format(manifest_version)) - - # TODO(richkadel): Changed, from the Fuchsia GN SDK version, to assume - # the given `output_name` already includes its extension. This change - # has not been fully validate, in particular, it has not been tested - # with CF v2 `.cm` (from `.cml`) files. Original implementation was: - # - # extension = MANIFEST_VERSION_EXTENSIONS.get(manifest_version) - # manifest_dest_file_path = os.path.join( - # os.path.dirname(archive_manifest_path), - # component_manifest.get('output_name') + extension) - manifest_dest_file_path = os.path.join( - os.path.dirname(archive_manifest_path), component_manifest.get('output_name') - ) - # Add the 'meta/' subdir, for example, if `output_name` includes it - os.makedirs(os.path.dirname(manifest_dest_file_path), exist_ok=True) - shutil.copy(component_manifest.get('source'), manifest_dest_file_path) - - manifest_entries['meta/%s' % os.path.basename(manifest_dest_file_path) - ] = os.path.relpath(manifest_dest_file_path, out_dir) - return manifest_dest_file_path - - -def _write_package_manifest( - manifest_entries, expanded_files, out_dir, exclude_file, root_dir, component_info -): - """Writes the package manifest for a Fuchsia package - - Returns a list of binaries in the package. - - Raises an exception if excluded files are not found.""" - gen_dir = os.path.normpath(os.path.join(out_dir, 'gen')) - excluded_files_set = set(exclude_file) - roots = [gen_dir, root_dir, out_dir] - - # Filter out component manifests. These are written out elsewhere. - excluded_files_set.update([ - make_package_path(os.path.relpath(cf.get('source'), out_dir), roots) - for cf in _get_component_manifests(component_info) - if os.path.relpath(cf.get('source'), out_dir) in expanded_files - ]) - - # Filter out json_of_resources since only their contents are written, and we - # don't know the contained resources until late in the build cycle - excluded_files_set.update([ - make_package_path(os.path.relpath(cf.get('source'), out_dir), roots) - for cf in component_info - if cf.get('type') == 'json_of_resources' and - os.path.relpath(cf.get('source'), out_dir) in expanded_files - ]) - - # Write out resource files with specific package paths, and exclude them from - # the list of expanded files so they are not listed twice in the manifest. - for resource in _get_resource_items(component_info): - relative_src_file = os.path.relpath(resource.get('source'), out_dir) - resource_path = make_package_path(relative_src_file, roots) - manifest_entries[resource.get('dest')] = relative_src_file - if resource.get('type') == 'resource': - excluded_files_set.add(resource_path) - - for current_file in expanded_files: - current_file = _get_stripped_path(current_file) - # make_package_path() may relativize to either the source root or - # output directory. - in_package_path = make_package_path(current_file, roots) - - if in_package_path in excluded_files_set: - excluded_files_set.remove(in_package_path) - else: - manifest_entries[in_package_path] = current_file - - if excluded_files_set: - raise Exception( - 'Some files were excluded with --exclude-file but ' - 'not found in the deps list, or a resource (data) file ' - 'was added and not filtered out. Excluded files and resources: ' - '%s' % ', '.join(excluded_files_set) - ) - - -def _build_manifest(args): - # Use a sorted list to make sure the manifest order is deterministic. - expanded_files = sorted(_get_expanded_files(args.runtime_deps_file)) - component_info = _parse_component(args.json_file) - component_manifests = [] - - # Collect the manifest entries in a map since duplication happens - # because of runtime libraries. - manifest_entries = {} - _write_meta_package_manifest( - manifest_entries, args.manifest_path, args.app_name, args.out_dir, args.package_version - ) - for component_item in component_info: - _write_package_manifest( - manifest_entries, expanded_files, args.out_dir, args.exclude_file, args.root_dir, - component_item - ) - component_manifests.append( - _write_component_manifest( - manifest_entries, component_item, args.manifest_path, args.out_dir - ) - ) - - with open(args.manifest_path, 'w') as manifest: - for key in sorted(manifest_entries.keys()): - manifest.write('%s=%s\n' % (key, manifest_entries[key])) - - binaries = [f for f in expanded_files if _is_binary(f)] - _write_build_ids_txt(sorted(binaries), args.build_ids_file) - - # Omit any excluded_files from the expanded_files written to the depfile. - gen_dir = os.path.normpath(os.path.join(args.out_dir, 'gen')) - roots = [gen_dir, args.root_dir, args.out_dir] - excluded_files_set = set(args.exclude_file) - expanded_deps_files = [ - path for path in expanded_files if make_package_path(path, roots) not in excluded_files_set - ] - - _write_gn_deps_file( - args.depfile_path, args.manifest_path, component_manifests, args.out_dir, expanded_deps_files - ) - return 0 - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--root-dir', required=True, help='Build root directory') - parser.add_argument('--out-dir', required=True, help='Build output directory') - parser.add_argument('--app-name', required=True, help='Package name') - parser.add_argument( - '--runtime-deps-file', required=True, help='File with the list of runtime dependencies.' - ) - parser.add_argument('--depfile-path', required=True, help='Path to write GN deps file.') - parser.add_argument( - '--exclude-file', - action='append', - default=[], - help='Package-relative file path to exclude from the package.' - ) - parser.add_argument('--manifest-path', required=True, help='Manifest output path.') - parser.add_argument('--build-ids-file', required=True, help='Debug symbol index path.') - parser.add_argument('--json-file', required=True) - parser.add_argument('--package-version', default='0', help='Version of the package') - - args = parser.parse_args() - - return _build_manifest(args) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools/fuchsia/gn-sdk/symbol_index.gni b/tools/fuchsia/gn-sdk/symbol_index.gni deleted file mode 100644 index dd92770b8911b..0000000000000 --- a/tools/fuchsia/gn-sdk/symbol_index.gni +++ /dev/null @@ -1,63 +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("config/config.gni") - -# TODO(akbiggs): Delete this, symbol-index no longer exists, it has been -# replaced with ffx debug symbol-index. I don't think this build rule is being -# used because it would be failing if it was, so it can probably be removed -# safely. -# -# Template for running the symbol-index tool for registering symbols with the symbolizer. -# -# Parameters -# symbols - the build_id or ids.txt file to add to the index -# build_dir - optional, the root of the build id used to resolve -# relative source code paths found in the symbols. -# -# Forwarded parameters -# testonly -# deps -# public_deps -# visibility -template("fuchsia_symbol_index_tool") { - forward_variables_from(invoker, [ "*" ]) - action(target_name) { - forward_variables_from(invoker, - [ - "testonly", - "deps", - "public_deps", - "visibility", - ]) - assert(defined(invoker.symbols), "symbols is required.") - _symbol_file = invoker.symbols - - _build_root_dir = root_build_dir - if (defined(invoker.build_root_dir)) { - _build_root_dir = invoker.build_root_dir - } - - _stamp_file = "$target_gen_dir/$target_name.symbol_index.stamp" - outputs = [ _stamp_file ] - - # tool path - _tool_path = "${fuchsia_tool_dir}/symbol-index" - script = "//build/gn_run_binary.py" - - inputs = [ - # Depend on the SDK hash, to ensure rebuild if the SDK tools change. - _symbol_file, - _tool_path, - ] - args = [ - "--stamp", - rebase_path(_stamp_file, root_build_dir), - rebase_path(_tool_path, root_build_dir), - "add", - rebase_path(_symbol_file, root_build_dir), - rebase_path(_build_root_dir, root_build_dir), - ] - } -} From 211729fc225bd2ad8171d15919ec2a79e485507f Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Wed, 21 Feb 2024 15:21:32 -0800 Subject: [PATCH 02/24] double src --- .../tests/integration/mouse-input/mouse-input-view/BUILD.gn | 4 ++-- .../tests/integration/text-input/text-input-view/BUILD.gn | 4 ++-- .../integration/touch-input/embedding-flutter-view/BUILD.gn | 4 ++-- .../tests/integration/touch-input/touch-input-view/BUILD.gn | 4 ++-- tools/fuchsia/flutter/internal/flutter_dart_component.gni | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn index a0ca2b8005c23..0126dc2353607 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { package_name = "mouse-input-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn index fb6c43d0bb3e8..38d8760bdbd9a 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { testonly = true diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn index 0d026824ce0a3..6e86329531f9a 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { package_name = "embedding-flutter-view" diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn b/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn index 1a6e4eafd43b4..9ef6301ece171 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/BUILD.gn @@ -5,8 +5,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/tools/fuchsia/dart/dart_library.gni") import("//flutter/tools/fuchsia/flutter/flutter_component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/package.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") dart_library("lib") { package_name = "touch-input-view" diff --git a/tools/fuchsia/flutter/internal/flutter_dart_component.gni b/tools/fuchsia/flutter/internal/flutter_dart_component.gni index 07ed4671c3f2b..d43d6f753fbc8 100644 --- a/tools/fuchsia/flutter/internal/flutter_dart_component.gni +++ b/tools/fuchsia/flutter/internal/flutter_dart_component.gni @@ -7,8 +7,8 @@ import("//flutter/tools/fuchsia/dart/config.gni") import("//flutter/tools/fuchsia/dart/dart.gni") import("//flutter/tools/fuchsia/dart/dart_package_config.gni") import("//flutter/tools/fuchsia/dart/kernel/dart_kernel.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/cmc.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/src/component.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") # Defines a component which will run in a flutter_runner or dart_runner # From 06f5e277e78be2931adae5a816ebce3e124a156b Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Wed, 21 Feb 2024 22:54:53 -0800 Subject: [PATCH 03/24] gni --- build/config/fuchsia/gn_configs.gni | 11 +++++++++++ tools/fuchsia/fuchsia_archive.gni | 2 +- tools/gn | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/build/config/fuchsia/gn_configs.gni b/build/config/fuchsia/gn_configs.gni index cc6fa6287bafd..f6d1d493db936 100644 --- a/build/config/fuchsia/gn_configs.gni +++ b/build/config/fuchsia/gn_configs.gni @@ -53,3 +53,14 @@ if (fuchsia_sdk_id == "") { _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 = "" + } +} diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 0ac36e8cc8214..bb3f10fcb74e9 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -3,9 +3,9 @@ # found in the LICENSE file. import("//build/fuchsia/config.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/config/config.gni") # Compiles a CML file for a V2 component. # diff --git a/tools/gn b/tools/gn index c81f35fe6ff73..beec5ca6a9c50 100755 --- a/tools/gn +++ b/tools/gn @@ -618,6 +618,8 @@ def to_gn_args(args): if args.target_os in ['android'] and gn_args['target_cpu'] in ['x64', 'arm64']: gn_args['dart_use_compressed_pointers'] = True + if args.target_os == 'fuchsia': + gn_args['gn_configs_path'] = '//flutter/build/config/fuchsia/gn_configs.gni' if args.fuchsia_target_api_level is not None: gn_args['fuchsia_target_api_level'] = args.fuchsia_target_api_level elif args.target_os == 'fuchsia': From 8d07993215ebf010477ce9d032c0b7903b6285c6 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Wed, 21 Feb 2024 22:55:12 -0800 Subject: [PATCH 04/24] format --- tools/fuchsia/fuchsia_archive.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index bb3f10fcb74e9..f57bef0749826 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -3,9 +3,9 @@ # found in the LICENSE file. import("//build/fuchsia/config.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") # Compiles a CML file for a V2 component. # From 20bc71480c5b23390713f34bb28c9a66d6c6a512 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 13:17:32 -0800 Subject: [PATCH 05/24] cmc_compile --- tools/fuchsia/compile_cml.py | 46 -------------------------- tools/fuchsia/fuchsia_archive.gni | 54 ++++--------------------------- 2 files changed, 6 insertions(+), 94 deletions(-) delete mode 100755 tools/fuchsia/compile_cml.py diff --git a/tools/fuchsia/compile_cml.py b/tools/fuchsia/compile_cml.py deleted file mode 100755 index fb6d3f49460d4..0000000000000 --- a/tools/fuchsia/compile_cml.py +++ /dev/null @@ -1,46 +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. - -""" Compiles a cml manifest file. -""" - -import argparse -import os -import subprocess -import sys - - -def main(): - parser = argparse.ArgumentParser() - - parser.add_argument('--cmc-bin', dest='cmc_bin', action='store', required=True) - parser.add_argument('--output', dest='output', action='store', required=True) - parser.add_argument('--manifest-file', dest='manifest_file', action='store', required=True) - parser.add_argument( - '--includepath', - dest='includepath', - action='append', - required=True, - ) - - args = parser.parse_args() - - assert os.path.exists(args.cmc_bin) - assert os.path.exists(args.manifest_file) - - subprocess.check_output([ - args.cmc_bin, - 'compile', - '--output', - args.output, - args.manifest_file, - ] + (args.includepath and ['--includepath'] + args.includepath)) - - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index f57bef0749826..4c9cefb75e889 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -5,46 +5,10 @@ import("//build/fuchsia/config.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") -# Compiles a CML file for a V2 component. -# -# manifest (required): -# The path to the .cml file for the component. Should include the file extension. -# output (optional): -# The path for the output .cm file. Should include the file extension. -template("_compile_cml") { - assert(defined(invoker.manifest), "_compile_cml must define manifest") - - action(target_name) { - forward_variables_from(invoker, - [ - "deps", - "testonly", - "visibility", - ]) - script = "//flutter/tools/fuchsia/compile_cml.py" - - inputs = [ "$fuchsia_tool_dir/cmc" ] - sources = [ invoker.manifest ] - - args = [ - "--cmc-bin", - rebase_path("$fuchsia_tool_dir/cmc"), - "--manifest-file", - rebase_path(invoker.manifest), - "--output", - rebase_path(invoker.output, root_build_dir), - "--includepath", - rebase_path("$fuchsia_sdk/pkg/", root_build_dir), - "--includepath", - get_path_info(invoker.manifest, "dir"), - "--includepath", - rebase_path("//"), - ] - outputs = [ invoker.output ] - } -} +# TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. # Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK. # @@ -170,6 +134,7 @@ template("_fuchsia_archive") { inputs += invoker.inputs } + # TODO(zijiehe): pm is less preferred than ffx package. args = [ "--pm-bin", rebase_path("$fuchsia_tool_dir/pm"), @@ -229,15 +194,13 @@ template("fuchsia_archive") { } if (defined(invoker.cml_file)) { - _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - _compile_cml(_compile_cml_target) { + cmc_compile(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } @@ -282,15 +245,13 @@ template("fuchsia_test_archive") { } if (defined(invoker.cml_file)) { - _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - _compile_cml(_compile_cml_target) { + cmc_compile(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } else { @@ -313,16 +274,13 @@ template("fuchsia_test_archive") { outputs = [ generated_cml_file ] } - far_base_dir = "$root_out_dir/${target_name}_far" - # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" - _compile_cml(compile_test_suite_cml_target) { + cmc_compile(compile_test_suite_cml_target) { testonly = true deps = [ ":$interpolate_cml_target" ] manifest = generated_cml_file - output = "$far_base_dir/meta/${test_suite}.cm" } _deps += [ ":$compile_test_suite_cml_target" ] From bb508ed6889bf62b45826863041ccd3ffa647891 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 13:57:58 -0800 Subject: [PATCH 06/24] output_file --- tools/fuchsia/fuchsia_archive.gni | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 4c9cefb75e889..1a16c3201a217 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -201,6 +201,7 @@ template("fuchsia_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file + output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } @@ -252,6 +253,7 @@ template("fuchsia_test_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file + output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } else { @@ -274,6 +276,8 @@ template("fuchsia_test_archive") { outputs = [ generated_cml_file ] } + far_base_dir = "$root_out_dir/${target_name}_far" + # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" cmc_compile(compile_test_suite_cml_target) { @@ -281,6 +285,7 @@ template("fuchsia_test_archive") { deps = [ ":$interpolate_cml_target" ] manifest = generated_cml_file + output_file = "$far_base_dir/meta/${test_suite}.cm" } _deps += [ ":$compile_test_suite_cml_target" ] From 1536dfbf81b339262a27f1eb5f1cdcd563e55338 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 14:00:32 -0800 Subject: [PATCH 07/24] missing --- tools/fuchsia/fuchsia_archive.gni | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 1a16c3201a217..89ce7b0bdefca 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -194,6 +194,7 @@ template("fuchsia_archive") { } if (defined(invoker.cml_file)) { + _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" @@ -246,6 +247,7 @@ template("fuchsia_test_archive") { } if (defined(invoker.cml_file)) { + _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" From 66275b53df3edfd16229c779f9dd0963ec365d71 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 15:19:26 -0800 Subject: [PATCH 08/24] system_tests --- testing/fuchsia/run_tests.py | 16 ++++++++++++---- testing/fuchsia/run_tests_test.py | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/testing/fuchsia/run_tests.py b/testing/fuchsia/run_tests.py index f7155e5563cc0..cf1e3aa534fbd 100755 --- a/testing/fuchsia/run_tests.py +++ b/testing/fuchsia/run_tests.py @@ -52,6 +52,8 @@ class TestCase(NamedTuple): package: str args: str = '' + # If using legacy /core/testing:system-tests real, it's non-hermetic and should be replaced by a flutter test realm. + system_tests: bool = False class _BundledTestRunner(TestRunner): @@ -66,8 +68,12 @@ def run_test(self) -> CompletedProcess: returncode = 0 for test in self.tests: assert test.package.endswith('.cm') + if test.system_tests: + realm = '/core/testing:system-tests' + else: + realm = None test_runner = ExecutableTestRunner( - OUT_DIR, test.args.split(), test.package, self._target_id, None, self.logs_dir, [], None + OUT_DIR, test.args.split(), test.package, self._target_id, None, self.logs_dir, [], realm ) # pylint: disable=protected-access test_runner._package_deps = self._package_deps @@ -110,14 +116,16 @@ def resolve_packages(tests: Iterable[Mapping[str, Any]]) -> Set[str]: # Visible for testing def build_test_cases(tests: Iterable[Mapping[str, Any]]) -> List[TestCase]: test_cases = [] - for test in [t['test_command'] for t in tests]: + for test in tests: + system_tests = 'system_tests' in test and (test['system_tests'] == True or test['system_tests'] == 'true') + test = test['test_command'] assert test.startswith('test run ') test = test[len('test run '):] if ' -- ' in test: package, args = test.split(' -- ', 1) - test_cases.append(TestCase(package=package, args=args)) + test_cases.append(TestCase(package=package, args=args, system_tests=system_tests)) else: - test_cases.append(TestCase(package=test)) + test_cases.append(TestCase(package=test, system_tests=system_tests)) return test_cases diff --git a/testing/fuchsia/run_tests_test.py b/testing/fuchsia/run_tests_test.py index 82b5d5aae433e..1e4880cefc6d8 100755 --- a/testing/fuchsia/run_tests_test.py +++ b/testing/fuchsia/run_tests_test.py @@ -54,6 +54,23 @@ def test_build_test_cases_with_arguments(self): run_tests.TestCase(package='def', args='--args')] ) + def test_build_test_cases_with_system_tests(self): + test_cases = run_tests.build_test_cases([ + {'test_command': 'test run 1', 'system_tests': True}, + {'test_command': 'test run 2', 'system_tests': 'true'}, + {'test_command': 'test run 3', 'system_tests': False}, + {'test_command': 'test run 4', 'system_tests': 'false'}, + {'test_command': 'test run 5'}, + ]) + self.assertEqual( + test_cases, + [run_tests.TestCase(package='1', system_tests=True), + run_tests.TestCase(package='2', system_tests=True), + run_tests.TestCase(package='3', system_tests=False), + run_tests.TestCase(package='4', system_tests=False), + run_tests.TestCase(package='5', system_tests=False)] + ) + if __name__ == '__main__': try: From 684d7824bd150075fe9f6ad8a743b2ce16d267b9 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 15:19:42 -0800 Subject: [PATCH 09/24] format --- testing/fuchsia/run_tests.py | 4 +++- testing/fuchsia/run_tests_test.py | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/testing/fuchsia/run_tests.py b/testing/fuchsia/run_tests.py index cf1e3aa534fbd..c7aa4d2fdd710 100755 --- a/testing/fuchsia/run_tests.py +++ b/testing/fuchsia/run_tests.py @@ -117,7 +117,9 @@ def resolve_packages(tests: Iterable[Mapping[str, Any]]) -> Set[str]: def build_test_cases(tests: Iterable[Mapping[str, Any]]) -> List[TestCase]: test_cases = [] for test in tests: - system_tests = 'system_tests' in test and (test['system_tests'] == True or test['system_tests'] == 'true') + system_tests = 'system_tests' in test and ( + test['system_tests'] == True or test['system_tests'] == 'true' + ) test = test['test_command'] assert test.startswith('test run ') test = test[len('test run '):] diff --git a/testing/fuchsia/run_tests_test.py b/testing/fuchsia/run_tests_test.py index 1e4880cefc6d8..b123beae8be31 100755 --- a/testing/fuchsia/run_tests_test.py +++ b/testing/fuchsia/run_tests_test.py @@ -63,12 +63,13 @@ def test_build_test_cases_with_system_tests(self): {'test_command': 'test run 5'}, ]) self.assertEqual( - test_cases, - [run_tests.TestCase(package='1', system_tests=True), - run_tests.TestCase(package='2', system_tests=True), - run_tests.TestCase(package='3', system_tests=False), - run_tests.TestCase(package='4', system_tests=False), - run_tests.TestCase(package='5', system_tests=False)] + test_cases, [ + run_tests.TestCase(package='1', system_tests=True), + run_tests.TestCase(package='2', system_tests=True), + run_tests.TestCase(package='3', system_tests=False), + run_tests.TestCase(package='4', system_tests=False), + run_tests.TestCase(package='5', system_tests=False) + ] ) From 10f95a02ae551fd6550deceb8e600ecb3feed7b6 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 15:55:38 -0800 Subject: [PATCH 10/24] undo --- testing/fuchsia/run_tests.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/testing/fuchsia/run_tests.py b/testing/fuchsia/run_tests.py index c7aa4d2fdd710..f7155e5563cc0 100755 --- a/testing/fuchsia/run_tests.py +++ b/testing/fuchsia/run_tests.py @@ -52,8 +52,6 @@ class TestCase(NamedTuple): package: str args: str = '' - # If using legacy /core/testing:system-tests real, it's non-hermetic and should be replaced by a flutter test realm. - system_tests: bool = False class _BundledTestRunner(TestRunner): @@ -68,12 +66,8 @@ def run_test(self) -> CompletedProcess: returncode = 0 for test in self.tests: assert test.package.endswith('.cm') - if test.system_tests: - realm = '/core/testing:system-tests' - else: - realm = None test_runner = ExecutableTestRunner( - OUT_DIR, test.args.split(), test.package, self._target_id, None, self.logs_dir, [], realm + OUT_DIR, test.args.split(), test.package, self._target_id, None, self.logs_dir, [], None ) # pylint: disable=protected-access test_runner._package_deps = self._package_deps @@ -116,18 +110,14 @@ def resolve_packages(tests: Iterable[Mapping[str, Any]]) -> Set[str]: # Visible for testing def build_test_cases(tests: Iterable[Mapping[str, Any]]) -> List[TestCase]: test_cases = [] - for test in tests: - system_tests = 'system_tests' in test and ( - test['system_tests'] == True or test['system_tests'] == 'true' - ) - test = test['test_command'] + for test in [t['test_command'] for t in tests]: assert test.startswith('test run ') test = test[len('test run '):] if ' -- ' in test: package, args = test.split(' -- ', 1) - test_cases.append(TestCase(package=package, args=args, system_tests=system_tests)) + test_cases.append(TestCase(package=package, args=args)) else: - test_cases.append(TestCase(package=test, system_tests=system_tests)) + test_cases.append(TestCase(package=test)) return test_cases From 19906502a80b24abd660f59b18f33519f08247e5 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 22 Feb 2024 16:27:26 -0800 Subject: [PATCH 11/24] remove gtest_runner.shard --- .../meta/dart-aot-runner-integration-test.cml | 2 +- .../meta/gtest_runner.shard.cml | 18 ------------------ .../meta/dart-jit-runner-integration-test.cml | 2 +- .../meta/gtest_runner.shard.cml | 18 ------------------ .../embedder/meta/flutter-embedder-test.cml | 2 +- .../embedder/meta/gtest_runner.shard.cml | 17 ----------------- .../mouse-input/meta/gtest_runner.shard.cml | 17 ----------------- .../mouse-input/meta/mouse-input-test.cml | 2 +- .../text-input/meta/gtest_runner.shard.cml | 17 ----------------- .../text-input/meta/text-input-test.cml | 2 +- .../touch-input/meta/gtest_runner.shard.cml | 17 ----------------- .../touch-input/meta/touch-input-test.cml | 2 +- 12 files changed, 6 insertions(+), 110 deletions(-) delete mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/flutter/tests/integration/embedder/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/flutter/tests/integration/text-input/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/gtest_runner.shard.cml diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/dart-aot-runner-integration-test.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/dart-aot-runner-integration-test.cml index 272489d6c931b..25c64dd6859bd 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/dart-aot-runner-integration-test.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/dart-aot-runner-integration-test.cml @@ -4,7 +4,7 @@ { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/gtest_runner.shard.cml deleted file mode 100644 index f6cfe507747ad..0000000000000 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_aot_runner/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,18 +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. - -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml index d95f61ee8e578..5a7a6fc7c5587 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml @@ -4,7 +4,7 @@ { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml deleted file mode 100644 index f6cfe507747ad..0000000000000 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,18 +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. - -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/flutter-embedder-test.cml b/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/flutter-embedder-test.cml index 2db3c10762e6a..ada9c05048533 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/flutter-embedder-test.cml +++ b/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/flutter-embedder-test.cml @@ -3,7 +3,7 @@ // found in the LICENSE file. { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, diff --git a/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/gtest_runner.shard.cml deleted file mode 100644 index d9871b70f3022..0000000000000 --- a/shell/platform/fuchsia/flutter/tests/integration/embedder/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,17 +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. -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/gtest_runner.shard.cml deleted file mode 100644 index d9871b70f3022..0000000000000 --- a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,17 +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. -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/mouse-input-test.cml b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/mouse-input-test.cml index 367f4c81db3bf..1199c2cb024fe 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/mouse-input-test.cml +++ b/shell/platform/fuchsia/flutter/tests/integration/mouse-input/meta/mouse-input-test.cml @@ -3,7 +3,7 @@ // found in the LICENSE file. { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, diff --git a/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/gtest_runner.shard.cml deleted file mode 100644 index d9871b70f3022..0000000000000 --- a/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,17 +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. -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/text-input-test.cml b/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/text-input-test.cml index 48aa950c01898..38ce49b81ee5f 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/text-input-test.cml +++ b/shell/platform/fuchsia/flutter/tests/integration/text-input/meta/text-input-test.cml @@ -3,7 +3,7 @@ // found in the LICENSE file. { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/gtest_runner.shard.cml deleted file mode 100644 index d9871b70f3022..0000000000000 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/gtest_runner.shard.cml +++ /dev/null @@ -1,17 +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. -{ - program: { - runner: "gtest_runner", - }, - capabilities: [ - { protocol: "fuchsia.test.Suite" }, - ], - expose: [ - { - protocol: "fuchsia.test.Suite", - from: "self", - }, - ], -} diff --git a/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/touch-input-test.cml b/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/touch-input-test.cml index de1f89b080a0a..e02e3b7de72c6 100644 --- a/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/touch-input-test.cml +++ b/shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/touch-input-test.cml @@ -3,7 +3,7 @@ // found in the LICENSE file. { include: [ - "gtest_runner.shard.cml", + "sys/testing/gtest_runner.shard.cml", "sys/component/realm_builder_absolute.shard.cml", // This test needs both the vulkan facet and the hermetic-tier-2 facet, From 552bf9e2121484e65ee3023c8d22d1ef94069ba2 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 01:14:23 -0800 Subject: [PATCH 12/24] no output_file --- tools/fuchsia/fuchsia_archive.gni | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 89ce7b0bdefca..d2aa14354878d 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -194,7 +194,7 @@ template("fuchsia_archive") { } if (defined(invoker.cml_file)) { - _far_base_dir = "$root_out_dir/${target_name}_far" + # _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" @@ -202,7 +202,7 @@ template("fuchsia_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + # output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } @@ -247,7 +247,7 @@ template("fuchsia_test_archive") { } if (defined(invoker.cml_file)) { - _far_base_dir = "$root_out_dir/${target_name}_far" + # _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" @@ -255,7 +255,7 @@ template("fuchsia_test_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + # output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } else { @@ -278,7 +278,7 @@ template("fuchsia_test_archive") { outputs = [ generated_cml_file ] } - far_base_dir = "$root_out_dir/${target_name}_far" + # far_base_dir = "$root_out_dir/${target_name}_far" # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" @@ -287,7 +287,7 @@ template("fuchsia_test_archive") { deps = [ ":$interpolate_cml_target" ] manifest = generated_cml_file - output_file = "$far_base_dir/meta/${test_suite}.cm" + # output_file = "$far_base_dir/meta/${test_suite}.cm" } _deps += [ ":$compile_test_suite_cml_target" ] From cda22f8de05f7e28ca64cbb18aa4e46ccb94890f Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 01:14:29 -0800 Subject: [PATCH 13/24] Revert "no output_file" This reverts commit 552bf9e2121484e65ee3023c8d22d1ef94069ba2. --- tools/fuchsia/fuchsia_archive.gni | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index d2aa14354878d..89ce7b0bdefca 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -194,7 +194,7 @@ template("fuchsia_archive") { } if (defined(invoker.cml_file)) { - # _far_base_dir = "$root_out_dir/${target_name}_far" + _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" @@ -202,7 +202,7 @@ template("fuchsia_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - # output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } @@ -247,7 +247,7 @@ template("fuchsia_test_archive") { } if (defined(invoker.cml_file)) { - # _far_base_dir = "$root_out_dir/${target_name}_far" + _far_base_dir = "$root_out_dir/${target_name}_far" _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" @@ -255,7 +255,7 @@ template("fuchsia_test_archive") { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - # output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } else { @@ -278,7 +278,7 @@ template("fuchsia_test_archive") { outputs = [ generated_cml_file ] } - # far_base_dir = "$root_out_dir/${target_name}_far" + far_base_dir = "$root_out_dir/${target_name}_far" # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" @@ -287,7 +287,7 @@ template("fuchsia_test_archive") { deps = [ ":$interpolate_cml_target" ] manifest = generated_cml_file - # output_file = "$far_base_dir/meta/${test_suite}.cm" + output_file = "$far_base_dir/meta/${test_suite}.cm" } _deps += [ ":$compile_test_suite_cml_target" ] From aec271e67febd9e7b3820ee6e958f35c880b81b2 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 01:37:52 -0800 Subject: [PATCH 14/24] Restore run_tests_test --- testing/fuchsia/run_tests_test.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/testing/fuchsia/run_tests_test.py b/testing/fuchsia/run_tests_test.py index b123beae8be31..82b5d5aae433e 100755 --- a/testing/fuchsia/run_tests_test.py +++ b/testing/fuchsia/run_tests_test.py @@ -54,24 +54,6 @@ def test_build_test_cases_with_arguments(self): run_tests.TestCase(package='def', args='--args')] ) - def test_build_test_cases_with_system_tests(self): - test_cases = run_tests.build_test_cases([ - {'test_command': 'test run 1', 'system_tests': True}, - {'test_command': 'test run 2', 'system_tests': 'true'}, - {'test_command': 'test run 3', 'system_tests': False}, - {'test_command': 'test run 4', 'system_tests': 'false'}, - {'test_command': 'test run 5'}, - ]) - self.assertEqual( - test_cases, [ - run_tests.TestCase(package='1', system_tests=True), - run_tests.TestCase(package='2', system_tests=True), - run_tests.TestCase(package='3', system_tests=False), - run_tests.TestCase(package='4', system_tests=False), - run_tests.TestCase(package='5', system_tests=False) - ] - ) - if __name__ == '__main__': try: From f4d7ceefcf1d49022aed8168bbeb4eaaee2ce794 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 11:45:28 -0800 Subject: [PATCH 15/24] Update gn-sdk --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index b08e15091e0e5..b0934e0d37555 100644 --- a/DEPS +++ b/DEPS @@ -257,7 +257,7 @@ vars = { # The version / instance id of the cipd:chromium/fuchsia/gn-sdk which will be # used altogether with fuchsia-sdk to generate gn based build rules. - 'fuchsia_gn_sdk_version': 'GEILx3JhMHrLut6n15rcvfmdudN_txrEbV70XHeqmusC', + 'fuchsia_gn_sdk_version': 'BRsK4JIBtjKGmCJGsQfpomxyr51m_Ii9nyL_9H19ESYC', } gclient_gn_args_file = 'src/third_party/dart/build/config/gclient_args.gni' From 43cb29e0cdf2989bf4fddf7ded8fc26898ccb84c Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 13:42:44 -0800 Subject: [PATCH 16/24] prepare-package_inputs --- tools/fuchsia/fuchsia_archive.gni | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 89ce7b0bdefca..17d8dc3243d80 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -6,6 +6,7 @@ import("//build/fuchsia/config.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") # TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. @@ -120,10 +121,20 @@ template("_fuchsia_archive") { } manifest_json_file = "${root_out_dir}/${target_name}_package_manifest.json" + + prepare_package_inputs("${target_name}_package_inputs") { + deps = pkg.deps + archive_manifest = "${root_out_dir}/${target_name}.manifest" + testonly = pkg_testonly + pkg_out_dir = far_base_dir + package_name = pkg.package_name + } + action(target_name) { script = "//flutter/tools/fuchsia/gen_package.py" deps = pkg_dir_deps + [ ":${target_name}_dir", + ":${target_name}_package_inputs", ":${_dbg_symbols_target}", ] From e9b63337b7516a8db4e06e990191cb00fe4d3b7d Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 13:43:09 -0800 Subject: [PATCH 17/24] Revert "prepare-package_inputs" This reverts commit 43cb29e0cdf2989bf4fddf7ded8fc26898ccb84c. --- tools/fuchsia/fuchsia_archive.gni | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 17d8dc3243d80..89ce7b0bdefca 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -6,7 +6,6 @@ import("//build/fuchsia/config.gni") import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") -import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") # TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. @@ -121,20 +120,10 @@ template("_fuchsia_archive") { } manifest_json_file = "${root_out_dir}/${target_name}_package_manifest.json" - - prepare_package_inputs("${target_name}_package_inputs") { - deps = pkg.deps - archive_manifest = "${root_out_dir}/${target_name}.manifest" - testonly = pkg_testonly - pkg_out_dir = far_base_dir - package_name = pkg.package_name - } - action(target_name) { script = "//flutter/tools/fuchsia/gen_package.py" deps = pkg_dir_deps + [ ":${target_name}_dir", - ":${target_name}_package_inputs", ":${_dbg_symbols_target}", ] From da94851d879628d61cf41f740f664f8581f6bc56 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 14:04:44 -0800 Subject: [PATCH 18/24] fuchsia_ar --- tools/fuchsia/fuchsia_archive.gni | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 89ce7b0bdefca..5655eddbfdd89 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -198,6 +198,11 @@ template("fuchsia_archive") { _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" + write_file( + "${target_gen_dir}/${_compile_cml_target}/${_compile_cml_target}.d", + [], + "list lines") + cmc_compile(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) @@ -251,6 +256,11 @@ template("fuchsia_test_archive") { _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" + write_file( + "${target_gen_dir}/${_compile_cml_target}/${_compile_cml_target}.d", + [], + "list lines") + cmc_compile(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) @@ -282,6 +292,12 @@ template("fuchsia_test_archive") { # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" + + write_file( + "${target_gen_dir}/${compile_test_suite_cml_target}/${compile_test_suite_cml_target}.d", + [], + "list lines") + cmc_compile(compile_test_suite_cml_target) { testonly = true deps = [ ":$interpolate_cml_target" ] From 585e1eae3b7a3d7680572a1410c50ca4ba259967 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 14:15:34 -0800 Subject: [PATCH 19/24] cmc_compile --- tools/fuchsia/fuchsia_archive.gni | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 5655eddbfdd89..498ff1e481a9a 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -8,6 +8,22 @@ import("//flutter/tools/fuchsia/fuchsia_libs.gni") import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") +# Alias of cmc_compile in gn-sdk/src/cmc.gni +template("_compile_cml") { + assert(defined(invoker.manifest), "_compile_cml must define manifest") + + # Create an empty depfile, it's not used in flutter. + write_file( + "${target_gen_dir}/${target_name}/${target_name}.d", + [], + "list lines") + + cmc_compile(target_name) { + forward_variables_from(invoker, [ "deps", "manifest", "testonly" ]) + output_file = invoker.output + } +} + # TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. # Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK. @@ -134,7 +150,6 @@ template("_fuchsia_archive") { inputs += invoker.inputs } - # TODO(zijiehe): pm is less preferred than ffx package. args = [ "--pm-bin", rebase_path("$fuchsia_tool_dir/pm"), @@ -198,16 +213,11 @@ template("fuchsia_archive") { _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - write_file( - "${target_gen_dir}/${_compile_cml_target}/${_compile_cml_target}.d", - [], - "list lines") - - cmc_compile(_compile_cml_target) { + _compile_cml(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + output = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } @@ -256,16 +266,11 @@ template("fuchsia_test_archive") { _cml_file_name = get_path_info(invoker.cml_file, "name") _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - write_file( - "${target_gen_dir}/${_compile_cml_target}/${_compile_cml_target}.d", - [], - "list lines") - - cmc_compile(_compile_cml_target) { + _compile_cml(_compile_cml_target) { forward_variables_from(invoker, [ "testonly" ]) manifest = invoker.cml_file - output_file = "$_far_base_dir/meta/${_cml_file_name}.cm" + output = "$_far_base_dir/meta/${_cml_file_name}.cm" } _deps += [ ":$_compile_cml_target" ] } else { @@ -292,18 +297,12 @@ template("fuchsia_test_archive") { # Compile the resulting interpolated test suite's cml. compile_test_suite_cml_target = "${test_suite}_test_suite_compile_cml" - - write_file( - "${target_gen_dir}/${compile_test_suite_cml_target}/${compile_test_suite_cml_target}.d", - [], - "list lines") - - cmc_compile(compile_test_suite_cml_target) { + _compile_cml(compile_test_suite_cml_target) { testonly = true deps = [ ":$interpolate_cml_target" ] manifest = generated_cml_file - output_file = "$far_base_dir/meta/${test_suite}.cm" + output = "$far_base_dir/meta/${test_suite}.cm" } _deps += [ ":$compile_test_suite_cml_target" ] From 242be772069fcdd76d6ae2d6ab5370c4e0159773 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 14:16:05 -0800 Subject: [PATCH 20/24] format --- tools/fuchsia/fuchsia_archive.gni | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 498ff1e481a9a..729d29407a925 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -13,13 +13,17 @@ template("_compile_cml") { assert(defined(invoker.manifest), "_compile_cml must define manifest") # Create an empty depfile, it's not used in flutter. - write_file( - "${target_gen_dir}/${target_name}/${target_name}.d", - [], - "list lines") + write_file("${target_gen_dir}/${target_name}/${target_name}.d", + [], + "list lines") cmc_compile(target_name) { - forward_variables_from(invoker, [ "deps", "manifest", "testonly" ]) + forward_variables_from(invoker, + [ + "deps", + "manifest", + "testonly", + ]) output_file = invoker.output } } From f3e9eef939e4a317e48f8055fb2825a81b7188af Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 14:20:01 -0800 Subject: [PATCH 21/24] TODO --- tools/fuchsia/fuchsia_archive.gni | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 729d29407a925..0e857905d987b 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -29,6 +29,7 @@ template("_compile_cml") { } # TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. +# - https://issues.chromium.org/issues/40935282 # Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK. # From 0c0afa1041664e34651bd6a50736cdaaba148e2d Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 14:21:28 -0800 Subject: [PATCH 22/24] TODO --- tools/fuchsia/fidl/fidl_library.gni | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/fuchsia/fidl/fidl_library.gni b/tools/fuchsia/fidl/fidl_library.gni index 22236cedb7a19..54c69b4ab05e0 100644 --- a/tools/fuchsia/fidl/fidl_library.gni +++ b/tools/fuchsia/fidl/fidl_library.gni @@ -7,6 +7,9 @@ import("//flutter/tools/fuchsia/fidl/fidl.gni") import("//flutter/tools/fuchsia/fidl/toolchain.gni") import("//flutter/tools/fuchsia/gn-sdk/src/config/config.gni") +# TODO(zijiehe): May use fidl_library in gn-sdk if possible. +# - https://issues.chromium.org/issues/40935282 + # Generates some representation of a FIDL library that's consumable by Language # bindings generators. # From b100854b8f5fd6e853646a1da55038928b9411d5 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Fri, 23 Feb 2024 15:16:44 -0800 Subject: [PATCH 23/24] TODO --- tools/fuchsia/fidl/fidl_library.gni | 3 +-- tools/fuchsia/fuchsia_archive.gni | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/fuchsia/fidl/fidl_library.gni b/tools/fuchsia/fidl/fidl_library.gni index 54c69b4ab05e0..ae8299485a48a 100644 --- a/tools/fuchsia/fidl/fidl_library.gni +++ b/tools/fuchsia/fidl/fidl_library.gni @@ -7,8 +7,7 @@ import("//flutter/tools/fuchsia/fidl/fidl.gni") import("//flutter/tools/fuchsia/fidl/toolchain.gni") import("//flutter/tools/fuchsia/gn-sdk/src/config/config.gni") -# TODO(zijiehe): May use fidl_library in gn-sdk if possible. -# - https://issues.chromium.org/issues/40935282 +# TODO(zijiehe): May use fidl_library in gn-sdk if possible. - http://crbug.com/40935282 # Generates some representation of a FIDL library that's consumable by Language # bindings generators. diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index 0e857905d987b..41e51e09f1f60 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -28,8 +28,7 @@ template("_compile_cml") { } } -# TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. -# - https://issues.chromium.org/issues/40935282 +# TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. - http://crbug.com/40935282 # Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK. # From db0ef5b3073345b70cb560b3bfd160cbb4ee73fb Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Sat, 24 Feb 2024 01:09:16 -0800 Subject: [PATCH 24/24] update gn-sdk --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 5180ba837b5e9..e8942638bad92 100644 --- a/DEPS +++ b/DEPS @@ -257,7 +257,7 @@ vars = { # The version / instance id of the cipd:chromium/fuchsia/gn-sdk which will be # used altogether with fuchsia-sdk to generate gn based build rules. - 'fuchsia_gn_sdk_version': 'BRsK4JIBtjKGmCJGsQfpomxyr51m_Ii9nyL_9H19ESYC', + 'fuchsia_gn_sdk_version': 'l8zShEOXGGjtLYRulEX5CjT2RemKvUPOT6L-uXy41tMC', } gclient_gn_args_file = 'src/third_party/dart/build/config/gclient_args.gni'