Commit 81e217be authored by Wez's avatar Wez Committed by Commit Bot

[fuchsia] Migrate cr_package_fuchsia() to use SDK-provided rules.

Migrate the cr_package_fuchsia() rule to use the SDK-provided
fuchsia_component() and fuchsia_package() rules internally.

TBR=jbudorick

Bug: 1050703
Change-Id: I1ba54308f2f2f6fc0f0b305dab2b9c927a38b21e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094989
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756250}
parent e1619011
...@@ -81,12 +81,17 @@ template("fuchsia_package_runner") { ...@@ -81,12 +81,17 @@ template("fuchsia_package_runner") {
} }
wrapper_script = generated_run_pkg_script_path wrapper_script = generated_run_pkg_script_path
deps = [ invoker.package ] data_deps = [
if (defined(invoker.deps)) { invoker.package,
deps += invoker.deps
}
data_deps = [ invoker.package ] # Runner scripts require access to "ids.txt" for symbolization, and to
# the "package" from which to get the name & version to deploy, which
# are outputs of the archive manifest generation action.
invoker.package + "__archive-manifest",
]
if (defined(invoker.data_deps)) {
data_deps += invoker.data_deps
}
# Declares the files that are needed for test execution on the # Declares the files that are needed for test execution on the
# swarming test client. # swarming test client.
...@@ -133,7 +138,10 @@ template("fuchsia_package_runner") { ...@@ -133,7 +138,10 @@ template("fuchsia_package_runner") {
package_dep_target = package_dep[0] package_dep_target = package_dep[0]
package_dep_name = package_dep[1] package_dep_name = package_dep[1]
deps += [ package_dep_target ] data_deps += [
package_dep_target,
package_dep_target + "__archive-manifest",
]
package_dep_path = rebase_path( package_dep_path = rebase_path(
get_label_info(package_dep_target, "target_gen_dir") + "/" + get_label_info(package_dep_target, "target_gen_dir") + "/" +
package_dep_name + "/" + package_dep_name + ".far", package_dep_name + "/" + package_dep_name + ".far",
...@@ -178,9 +186,9 @@ template("fuchsia_package_runner") { ...@@ -178,9 +186,9 @@ template("fuchsia_package_runner") {
executable = rebase_path("//build/fuchsia/deploy_to_amber_repo.py") executable = rebase_path("//build/fuchsia/deploy_to_amber_repo.py")
wrapper_script = generated_install_pkg_script_path wrapper_script = generated_install_pkg_script_path
deps = [ invoker.package ] data_deps = [ invoker.package ]
if (defined(invoker.deps)) { if (defined(invoker.data_deps)) {
deps += invoker.deps data_deps += invoker.data_deps
} }
# Build a list of all packages to install, and pass the list to the runner # Build a list of all packages to install, and pass the list to the runner
...@@ -191,7 +199,7 @@ template("fuchsia_package_runner") { ...@@ -191,7 +199,7 @@ template("fuchsia_package_runner") {
package_dep_target = package_dep[0] package_dep_target = package_dep[0]
package_dep_name = package_dep[1] package_dep_name = package_dep[1]
deps += [ package_dep_target ] data_deps += [ package_dep_target ]
package_dep_path = rebase_path( package_dep_path = rebase_path(
get_label_info(package_dep_target, "target_gen_dir") + "/" + get_label_info(package_dep_target, "target_gen_dir") + "/" +
package_dep_name + "/" + package_dep_name + ".far", package_dep_name + "/" + package_dep_name + ".far",
......
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/sysroot.gni") import("//third_party/fuchsia-sdk/sdk/build/component.gni")
import("//third_party/fuchsia-sdk/sdk/build/package.gni")
# DEPRECATED: Use the Fuchsia SDK's fuchsia_component() and fuchsia_package()
# templates directly, in new code.
#
# Creates a Fuchsia .far package file containing a Fuchsia component. # Creates a Fuchsia .far package file containing a Fuchsia component.
# #
# Parameters are: # Parameters are:
...@@ -28,210 +32,97 @@ import("//build/config/sysroot.gni") ...@@ -28,210 +32,97 @@ import("//build/config/sysroot.gni")
# #
# TODO(https://crbug.com/1050703): Migrate consumers to GN SDK equivalents. # TODO(https://crbug.com/1050703): Migrate consumers to GN SDK equivalents.
template("cr_fuchsia_package") { template("cr_fuchsia_package") {
pkg = { assert(defined(invoker.binary))
forward_variables_from(invoker, "*")
if (defined(package_name_override)) {
package_name = package_name_override
} else {
package_name = invoker.target_name
}
if (defined(archive_name_override)) { if (defined(invoker.package_name_override)) {
archive_filename = archive_name_override _package_name = invoker.package_name_override
} else { } else {
archive_filename = package_name _package_name = invoker.target_name
}
if (!defined(manifest)) {
assert(testonly == true)
# TODO(1019938): switch the default to tests.cmx which doesn't request
# the deprecated-ambient-replace-as-executable feature.
manifest = "//build/config/fuchsia/tests-with-exec.cmx"
}
} }
assert(defined(pkg.binary))
_pm_tool_path = "//third_party/fuchsia-sdk/sdk/tools/pm" _package_contents = [ invoker.binary ]
if (defined(invoker.deps)) {
_pkg_out_dir = "${target_gen_dir}/${pkg.archive_filename}" _package_contents += invoker.deps
_runtime_deps_file = "$_pkg_out_dir/${pkg.archive_filename}.runtime_deps"
_archive_manifest = "$_pkg_out_dir/${pkg.archive_filename}.archive_manifest"
_build_ids_file = "$_pkg_out_dir/ids.txt"
_meta_far_file = "$_pkg_out_dir/meta.far"
_combined_far_file = "$_pkg_out_dir/${pkg.package_name}-0.far"
_final_far_file = "$_pkg_out_dir/${pkg.archive_filename}.far"
_package_info_path = "$_pkg_out_dir/package"
if (defined(pkg.component_name_override)) {
_generated_cmx = "$_pkg_out_dir/${pkg.component_name_override}.cmx"
} else {
_generated_cmx = "$_pkg_out_dir/${pkg.package_name}.cmx"
} }
_write_manifest_target = "${pkg.package_name}__write_manifest" _component_target = target_name + "__cr-component"
_package_target = "${pkg.package_name}__pkg" _package_components = [ ":${_component_target}" ]
_bundle_target = "${pkg.package_name}__bundle"
# Generates a manifest file based on the GN runtime deps
# suitable for "pm" tool consumption.
action(_write_manifest_target) {
_depfile = "${target_gen_dir}/${target_name}_stamp.d"
# Declare the primary component for this package.
fuchsia_component(_component_target) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"data", #"data",
"deps",
"testonly", "testonly",
]) ])
script = "//build/config/fuchsia/prepare_package_inputs.py" if (!defined(invoker.manifest)) {
assert(testonly == true)
inputs = [
_runtime_deps_file,
pkg.manifest,
]
outputs = [
_archive_manifest,
_build_ids_file,
_generated_cmx,
]
if (!defined(deps)) { # TODO(1019938): switch the default to tests.cmx which doesn't request
deps = [] # the deprecated-ambient-replace-as-executable feature.
manifest_fragment = "//build/config/fuchsia/tests-with-exec.cmx"
} else {
manifest_fragment = invoker.manifest
} }
deps += [ pkg.binary ]
data_deps = deps manifest_fragment_data = read_file(manifest_fragment, "json")
if (!defined(manifest_fragment_data.program)) {
# Use a depfile to trigger package rebuilds if any of the files (static manifest_fragment_data.program = {
# assets, shared libraries, etc.) included by the package have changed. binary = get_label_info(invoker.binary, "name")
depfile = _depfile
args = [
"--root-dir",
rebase_path("//", root_build_dir),
"--out-dir",
rebase_path(root_out_dir, root_build_dir),
"--app-name",
pkg.package_name,
"--app-filename",
get_label_info(pkg.binary, "name"),
"--manifest-input-path",
rebase_path(pkg.manifest, root_build_dir),
"--runtime-deps-file",
rebase_path(_runtime_deps_file, root_build_dir),
"--depfile-path",
rebase_path(_depfile, root_build_dir),
"--package-manifest-path",
rebase_path(_archive_manifest, root_build_dir),
"--component-manifest-path",
rebase_path(_generated_cmx, root_build_dir),
"--build-ids-file",
rebase_path(_build_ids_file, root_build_dir),
]
if (defined(pkg.excluded_files)) {
foreach(filename, pkg.excluded_files) {
args += [
"--exclude-file",
filename,
]
} }
} }
manifest = "$target_out_dir/" + target_name + "__component-manifest.cmx"
write_file(manifest, manifest_fragment_data, "json")
if (defined(pkg.additional_manifests)) { if (defined(invoker.component_name_override)) {
foreach(filename, pkg.additional_manifests) { manifest_output_name = "${invoker.component_name_override}"
args += [ } else {
"--additional-manifest", manifest_output_name = "${_package_name}"
rebase_path(filename),
]
}
} }
write_runtime_deps = _runtime_deps_file data_deps = _package_contents
} }
# Creates a signed Fuchsia metadata package. # Bundle manifests providing additional entrypoints into the package.
action(_package_target) { if (defined(invoker.additional_manifests)) {
foreach(filename, invoker.additional_manifests) {
_additional_component_target = target_name + "_" + filename
_package_components += [ ":${_additional_component_target}" ]
fuchsia_component(_additional_component_target) {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
data_deps = _package_contents
script = "//build/gn_run_binary.py" manifest = filename
}
deps = [ ":$_write_manifest_target" ] }
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
"//third_party/fuchsia-sdk/sdk/.hash",
]
if (defined(pkg.additional_manifests)) {
inputs += pkg.additional_manifests
} }
outputs = [ _meta_far_file ] # Generate a Fuchsia ARchive (FAR) of the requested name.
if (defined(invoker.archive_name_override)) {
args = [ _archive_name = invoker.archive_name_override
rebase_path(_pm_tool_path, root_build_dir), } else {
"-o", _archive_name = _package_name
rebase_path(_pkg_out_dir, root_build_dir),
"-m",
rebase_path(_archive_manifest, root_build_dir),
"build",
]
} }
# Creates a package containing the metadata archive and blob data. if (_archive_name != _package_name) {
action(_bundle_target) { _archive_target = target_name + "__cr-archive"
forward_variables_from(invoker, [ "testonly" ])
script = "//build/gn_run_binary.py" copy(target_name) {
deps = [ ":${_archive_target}" ]
deps = [ _pkg_out_dir = "${target_gen_dir}/${_package_name}"
":$_package_target", sources = [ "${_pkg_out_dir}/${_package_name}.far" ]
":$_write_manifest_target", outputs = [ "${_pkg_out_dir}/${_archive_name}.far" ]
] }
} else {
inputs = [ _archive_target = target_name
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
"//third_party/fuchsia-sdk/sdk/.hash",
_meta_far_file,
_archive_manifest,
]
outputs = [ _combined_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),
"archive",
]
} }
# Copies the archive to a well-known path. fuchsia_package(_archive_target) {
# TODO(kmarshall): Use a 'pm' output flag to write directly to the desired
# file path instead.
copy(target_name) {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
package_name = _package_name
# Allows dependent targets to make use of "ids.txt". if (defined(invoker.excluded_files)) {
public_deps = [ ":$_write_manifest_target" ] excluded_files = invoker.excluded_files
}
deps = [ ":$_bundle_target" ] deps = _package_components
data = [
_final_far_file,
# Files specified here so that they can be read by isolated testbots.
_package_info_path,
_build_ids_file,
]
sources = [ _combined_far_file ]
outputs = [ _final_far_file ]
} }
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
"features": [ "features": [
"config-data" "config-data"
], ],
"$comment": "Not all services are passed to WebEngine, see cast_runner.cc",
"services": [ "services": [
"chromium.cast.ApplicationConfigManager", "chromium.cast.ApplicationConfigManager",
"fuchsia.accessibility.semantics.SemanticsManager", "fuchsia.accessibility.semantics.SemanticsManager",
......
...@@ -217,7 +217,7 @@ template("test") { ...@@ -217,7 +217,7 @@ template("test") {
package = ":$_pkg_target" package = ":$_pkg_target"
package_name_override = _output_name package_name_override = _output_name
deps = [ "//testing/buildbot/filters:fuchsia_filters" ] data_deps = [ "//testing/buildbot/filters:fuchsia_filters" ]
} }
cr_fuchsia_package(_pkg_target) { cr_fuchsia_package(_pkg_target) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment