Commit 39b4aa89 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Fuchsia: Break apart package & script gen into separate GN rules.

This is a prerequisite step toward supporting multi-package
deployments.

* Replaces all calls to fuchsia_executable_runner() with
package and script generation targets. The revised rules are
simple enough that fuchsia_executable_runner() is no longer a
major convenience.
* Delete test_runner_script() for the same reasons.
* Use sensible defaults for things like sandbox_policy to clean
up the parameters for most instances of the rules.

Bug: 	855242
Change-Id: I2f04e1baa9afaf24cfd5d979d33e9912a0475e55
Reviewed-on: https://chromium-review.googlesource.com/1110749Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569850}
parent 39c14237
......@@ -764,8 +764,14 @@ group("gn_all") {
if (is_fuchsia) {
# TODO(https://crbug.com/731217): This can't practically be in //v8 without
# duplicating all the Fuchsia running infrastructure there.
fuchsia_executable_runner("d8_fuchsia") {
exe_target = "//v8:d8"
fuchsia_package("d8_fuchsia_pkg") {
binary = "//v8:d8"
package_name_override = "d8"
}
fuchsia_package_runner("d8_fuchsia") {
package = ":d8_fuchsia_pkg"
package_name_override = "d8"
}
}
......
......@@ -8,15 +8,25 @@ import("//build/config/sysroot.gni")
# Creates a Fuchsia .far package file.
#
# Parameters are:
# package_name: The name of the package to build.
# binary: The name of the executable which should be launched by the package.
# Will be renamed as "bin/app" in the package contents.
# sandbox_policy: A path to the sandbox_policy applied to this package.
# deps: A list of targets whose output will be included in the package.
template("package") {
# package_name_override: Specifies the name of the package to generate,
# if different than |target_name|.
# binary: The executable target which should be launched.
# sandbox_policy: A path to the sandbox_policy that will be used.
# Defaults to //build/config/fuchsia/sandbox_policy.
# deps: Additional targets to build and include in the package (optional).
template("fuchsia_package") {
pkg = {
package_name = target_name
forward_variables_from(invoker, "*")
if (defined(package_name_override)) {
package_name = package_name_override
} else {
package_name = invoker.target_name
}
if (!defined(sandbox_policy)) {
sandbox_policy = "//build/config/fuchsia/sandbox_policy"
}
}
assert(defined(pkg.binary))
......@@ -44,7 +54,6 @@ template("package") {
forward_variables_from(invoker,
[
"deps",
"public_deps",
"testonly",
])
......@@ -52,7 +61,7 @@ template("package") {
inputs = [
_runtime_deps_file,
"//build/config/fuchsia/sandbox_policy",
pkg.sandbox_policy,
]
outputs = [
......@@ -60,7 +69,11 @@ template("package") {
_component_manifest,
]
data_deps = pkg.deps
if (!defined(deps)) {
deps = []
}
deps += [ pkg.binary ]
data_deps = deps
# Use a depfile to trigger package rebuilds if any of the files (static
# assets, shared libraries, etc.) included by the package have changed.
......@@ -70,7 +83,7 @@ template("package") {
rebase_path("//"),
rebase_path(root_out_dir),
pkg.package_name,
pkg.binary,
get_label_info(pkg.binary, "name"),
rebase_path(pkg.sandbox_policy),
rebase_path(_runtime_deps_file),
rebase_path(_depfile),
......
......@@ -11,15 +11,36 @@ import("//build/config/sysroot.gni")
blobstore_qcow_path = "$root_out_dir/fvm.blk.qcow2"
template("generate_runner_script") {
_pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package_name, "dir")
_manifest_path = "$_pkg_dir/${invoker.package_name}.archive_manifest"
_package_path = "$_pkg_dir/${invoker.package_name}.far"
# Generates a script which deploys and executes a package on a device.
#
# Parameters:
# package: The package() target which will be run.
# package_name_override: Specifies the name of the generated package, if its
# name is different than the |package| target name.
# runner_script: The runner script implementation to use, relative to
# "build/fuchsia". Defaults to "exe_runner.py".
template("fuchsia_package_runner") {
forward_variables_from(invoker, [ "runner_script" ])
if (defined(invoker.package_name_override)) {
_pkg_shortname = invoker.package_name_override
} else {
_pkg_shortname = get_label_info(invoker.package, "name")
}
_pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package, "dir") +
"/" + _pkg_shortname
_manifest_path = "$_pkg_dir/${_pkg_shortname}.archive_manifest"
_package_path = "$_pkg_dir/${_pkg_shortname}.far"
_generated_script_path = "$root_build_dir/bin/run_$_pkg_shortname"
if (!defined(runner_script)) {
runner_script = "//build/fuchsia/exe_runner.py"
}
action(target_name) {
forward_variables_from(invoker,
[
"runner_script",
"target",
"testonly",
])
......@@ -27,28 +48,31 @@ template("generate_runner_script") {
deps = [
"//build/config/fuchsia:blobstore_extended_qcow2",
"//testing/buildbot/filters:fuchsia_filters",
invoker.package,
]
_generated_script = "${invoker.generated_script}"
script = "//build/fuchsia/create_runner_script.py"
outputs = [
_generated_script,
_generated_script_path,
]
data = [
_generated_script,
_generated_script_path,
_manifest_path,
"//build/fuchsia/",
"//build/util/lib/",
"${fuchsia_sdk}/",
]
data_deps = [
invoker.package,
]
# Arguments used at build time by the runner script generator.
args = [
"--script-output-path",
rebase_path(_generated_script, root_build_dir, root_out_dir),
rebase_path(_generated_script_path, root_build_dir, root_out_dir),
]
if (defined(invoker.use_test_server) && invoker.use_test_server) {
......@@ -58,7 +82,7 @@ template("generate_runner_script") {
# Arguments used at runtime by the test runner.
args += [
"--runner-script",
runner_script,
rebase_path(runner_script, root_out_dir),
"--output-directory",
rebase_path(root_build_dir, root_build_dir),
"--target-cpu",
......@@ -66,73 +90,9 @@ template("generate_runner_script") {
"--package",
rebase_path(_package_path, root_out_dir, root_build_dir),
"--package-name",
invoker.package_name,
_pkg_shortname,
"--package-manifest",
rebase_path(_manifest_path),
]
}
}
# This template is used to generate a runner script for test binaries into the
# build dir for Fuchsia. It's generally used from the "test" template.
template("test_runner_script") {
generate_runner_script(target_name) {
testonly = true
runner_script = "test_runner.py"
generated_script =
"$root_build_dir/bin/run_" + get_label_info(invoker.test_name, "name")
forward_variables_from(invoker, "*")
}
}
# This template is used to generate a runner script for arbitrary executables
# into the build dir for Fuchsia. The executable is specified as a target
# pass to the "exe_target" attribute.
template("fuchsia_executable_runner") {
forward_variables_from(invoker, [ "exe_target" ])
_pkg_target = "${target_name}_pkg"
_gen_runner_target = "${target_name}_runner"
_archive_target = "${target_name}_archive"
_exe_name = get_label_info(exe_target, "name")
# Define the target dependencies as the union of the executable target
# and the invoker's deps.
if (defined(invoker.deps)) {
_combined_deps = invoker.deps + [ exe_target ]
} else {
_combined_deps = [ exe_target ]
}
package(_pkg_target) {
forward_variables_from(invoker, [ "testonly" ])
package_name = _exe_name
sandbox_policy = "//build/config/fuchsia/sandbox_policy"
binary = _exe_name
deps = _combined_deps
}
generate_runner_script(_gen_runner_target) {
forward_variables_from(invoker, [ "testonly" ])
runner_script = "exe_runner.py"
generated_script = "$root_build_dir/bin/run_${_exe_name}"
package_name = _exe_name
}
group(target_name) {
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${_archive_target}",
":${_gen_runner_target}",
":${_pkg_target}",
]
}
generate_runner_script(_archive_target) {
forward_variables_from(invoker, [ "testonly" ])
runner_script = "archive_builder.py"
generated_script =
"$root_build_dir/bin/archive_" + get_label_info(exe_target, "name")
package_name = _exe_name
}
}
......@@ -21,7 +21,14 @@ executable("layout_test_proxy") {
]
}
fuchsia_executable_runner("layout_test_proxy_runner") {
fuchsia_package("layout_test_proxy_pkg") {
testonly = true
exe_target = ":layout_test_proxy"
binary = ":layout_test_proxy"
package_name_override = "layout_test_proxy"
}
fuchsia_package_runner("layout_test_proxy_runner") {
testonly = true
package = ":layout_test_proxy_pkg"
package_name_override = "layout_test_proxy"
}
......@@ -457,8 +457,9 @@ cast_executable("cast_shell") {
}
if (is_fuchsia) {
fuchsia_executable_runner("cast_shell_fuchsia") {
exe_target = ":cast_shell"
fuchsia_package("cast_shell_pkg") {
binary = ":cast_shell"
package_name_override = "cast_shell"
if (chromecast_branding != "public") {
deps = [
......@@ -466,6 +467,11 @@ if (is_fuchsia) {
]
}
}
fuchsia_package_runner("cast_shell_fuchsia") {
package = ":cast_shell_pkg"
package_name_override = "cast_shell"
}
}
repack("cast_shell_pak") {
......
......@@ -604,9 +604,16 @@ if (is_android) {
}
if (is_fuchsia) {
fuchsia_executable_runner("content_shell_fuchsia") {
fuchsia_package("content_shell_pkg") {
testonly = true
exe_target = ":content_shell"
binary = ":content_shell"
package_name_override = "content_shell"
}
fuchsia_package_runner("content_shell_fuchsia") {
testonly = true
package = ":content_shell_pkg"
package_name_override = "content_shell"
}
}
}
......
......@@ -967,8 +967,14 @@ static_library("headless_shell_lib") {
}
if (is_fuchsia) {
fuchsia_executable_runner("headless_shell_fuchsia") {
exe_target = ":headless_shell"
fuchsia_package("headless_shell_pkg") {
binary = ":headless_shell"
package_name_override = "headless_shell"
}
fuchsia_package_runner("headless_shell_fuchsia") {
package = ":headless_shell_pkg"
package_name_override = "headless_shell"
}
}
......
......@@ -253,38 +253,27 @@ template("test") {
} else if (is_fuchsia) {
_output_name = invoker.target_name
_pkg_target = "${_output_name}_pkg"
_gen_runner_target = "${_output_name}_runner"
_exec_target = "${_output_name}__exec"
group(target_name) {
fuchsia_package_runner(target_name) {
testonly = true
deps = [
":$_gen_runner_target",
":$_pkg_target",
]
}
# Makes the script which invokes the executable.
test_runner_script(_gen_runner_target) {
forward_variables_from(invoker, [ "use_test_server" ])
test_name = _output_name
package_name = _output_name
runner_script = "//build/fuchsia/test_runner.py"
package = ":$_pkg_target"
package_name_override = _output_name
}
executable(_exec_target) {
testonly = true
forward_variables_from(invoker, "*")
testonly = true
output_name = _exec_target
}
package(_pkg_target) {
fuchsia_package(_pkg_target) {
testonly = true
package_name = _output_name
sandbox_policy = "//build/config/fuchsia/testing_sandbox_policy"
binary = get_label_info(_exec_target, "name")
deps = [
":$_exec_target",
]
binary = ":$_exec_target"
package_name_override = _output_name
}
} else if (is_ios) {
import("//build/config/ios/ios_sdk.gni")
......
......@@ -77,8 +77,14 @@ component("webrunner_lib") {
]
}
fuchsia_executable_runner("webrunner_runner") {
exe_target = ":webrunner"
fuchsia_package("webrunner_pkg") {
binary = ":webrunner"
package_name_override = "webrunner"
}
fuchsia_package_runner("webrunner_runner") {
package = ":webrunner_pkg"
package_name_override = "webrunner"
}
repack("webrunner_pak") {
......
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