summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni')
-rw-r--r--third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni284
1 files changed, 284 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni b/third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni
new file mode 100644
index 0000000000..3349b2b869
--- /dev/null
+++ b/third_party/libwebrtc/build/config/fuchsia/generate_runner_scripts.gni
@@ -0,0 +1,284 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+assert(is_fuchsia)
+
+import("//build/config/chromecast_build.gni")
+import("//build/config/fuchsia/config.gni")
+import("//build/config/fuchsia/package.gni")
+import("//build/config/gclient_args.gni")
+import("//build/config/sysroot.gni")
+import("//build/util/generate_wrapper.gni")
+
+declare_args() {
+ # Sets the Fuchsia Amber repository which will be used by default by the
+ # generated installation scripts. If not specified, then no default directory
+ # will be used.
+ default_fuchsia_build_dir_for_installation = ""
+
+ # Sets the Fuchsia device node name which will be used by default by the
+ # generated runner scripts. If not specficed, then no default node name will
+ # be used.
+ default_fuchsia_device_node_name = ""
+
+ # CPU architecture of the host used to run the tests.
+ test_host_cpu = host_cpu
+
+ # Sets whether emulators need to be included in the test isolates
+ test_isolate_uses_emulator = true
+
+ # A list of additional Fuchsia boot images to include in the test isolates.
+ fuchsia_additional_boot_images = []
+}
+
+# Generates a script which deploys and optionally 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. This value must match
+# package_name_override in the |package| target.
+# package_deps: An array of [package, package_name_override] array pairs
+# which specify additional dependency packages to be installed
+# prior to execution.
+# runner_script: The runner script implementation to use, relative to
+# "build/fuchsia". Defaults to "test_runner.py".
+# install_only: If true, executing the script will only install the package
+# on the device, but not run it.
+# is_test_exe: If true, the generated script will run the command under
+# test_env.py and add arguments expected to be passed to test exes.
+template("fuchsia_package_runner") {
+ forward_variables_from(invoker, TESTONLY_AND_VISIBILITY + [ "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
+ _package_path = "$_pkg_dir/${_pkg_shortname}.far"
+
+ generated_run_pkg_script_path = "$root_build_dir/bin/run_${_pkg_shortname}"
+ generated_install_pkg_script_path =
+ "$root_build_dir/bin/install_$_pkg_shortname"
+
+ _generate_runner_target = "${target_name}__generate_runner"
+ _generate_installer_target = "${target_name}__generate_installer"
+
+ # Generates a script which installs and runs a test.
+ generate_wrapper(_generate_runner_target) {
+ forward_variables_from(invoker, [ "target" ])
+
+ _is_test_exe = defined(invoker.is_test_exe) && invoker.is_test_exe
+
+ if (defined(runner_script)) {
+ _runner_script = runner_script
+ } else {
+ _runner_script = "//build/fuchsia/test_runner.py"
+ }
+
+ if (_is_test_exe) {
+ executable = "//testing/test_env.py"
+ executable_args =
+ [ "@WrappedPath(" + rebase_path(_runner_script, root_out_dir) + ")" ]
+ data = [
+ _runner_script,
+ "//.vpython",
+ ]
+ data_deps = [ "//testing:test_scripts_shared" ]
+ } else {
+ executable = rebase_path(_runner_script)
+ executable_args = []
+ data = []
+ data_deps = []
+ }
+
+ if (defined(invoker.data)) {
+ data += invoker.data
+ }
+
+ wrapper_script = generated_run_pkg_script_path
+
+ 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",
+
+ # Runner scripts require access to "meta.far" from which to calculate the
+ # expected Merkle root for the package, to verify it has been cached.
+ "${invoker.package}__archive-metadata",
+ ]
+ if (defined(invoker.data_deps)) {
+ data_deps += invoker.data_deps
+ }
+
+ # Declares the files that are needed for test execution on the
+ # swarming test client.
+ data += [
+ "//build/fuchsia/",
+ "//build/util/lib/",
+ "//third_party/fuchsia-sdk/sdk/.build-id/",
+ "//third_party/fuchsia-sdk/sdk/bin/fpave.sh",
+ "//third_party/fuchsia-sdk/sdk/bin/fuchsia-common.sh",
+ "//third_party/fuchsia-sdk/sdk/meta/manifest.json",
+ ]
+
+ # TODO(crbug.com/1137662): Remove checkout_fuchsia_for_arm64_host from
+ # gclient_gn_args in //DEPS as well as this condition when builders have
+ # test_host_cpu set correctly.
+ if (checkout_fuchsia_for_arm64_host) {
+ test_host_cpu = "arm64"
+ }
+
+ if (test_host_cpu == "x64") {
+ data_deps +=
+ [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
+ }
+
+ data += [
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/device-finder",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/fvm",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/merkleroot",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/pm",
+
+ # TODO(crbug.com/1162314) Remove "symbolize" when transition to
+ # "symbolizer" is complete.
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/symbolize",
+
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/symbolizer",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/zbi",
+ ]
+
+ if (test_isolate_uses_emulator) {
+ data += [
+ "${boot_image_root}/qemu/qemu-kernel.kernel",
+ "${boot_image_root}/qemu/storage-full.blk",
+ "${boot_image_root}/qemu/zircon-a.zbi",
+ "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/fvdl",
+ "//third_party/qemu-${host_os}-${test_host_cpu}/",
+ "${aemu_root}/",
+ ]
+ }
+
+ foreach(fuchsia_additional_boot_image, fuchsia_additional_boot_images) {
+ data += [ "${fuchsia_additional_boot_image}/" ]
+ }
+
+ package_paths = [ rebase_path(_package_path, root_build_dir) ]
+ if (defined(invoker.package_deps)) {
+ foreach(package_dep, invoker.package_deps) {
+ package_dep_target = package_dep[0]
+ package_dep_name = package_dep[1]
+
+ data_deps += [
+ package_dep_target,
+ package_dep_target + "__archive-manifest",
+ package_dep_target + "__archive-metadata",
+ ]
+ package_dep_path = rebase_path(
+ get_label_info(package_dep_target, "target_gen_dir") + "/" +
+ package_dep_name + "/" + package_dep_name + ".far",
+ root_build_dir)
+ package_paths += [ package_dep_path ]
+ }
+ }
+
+ foreach(package_path, package_paths) {
+ executable_args += [
+ "--package",
+ "@WrappedPath(${package_path})",
+ ]
+ }
+
+ executable_args += [
+ "--out-dir",
+ "@WrappedPath(.)",
+ "--target-cpu",
+ target_cpu,
+ "--package-name",
+ _pkg_shortname,
+ ]
+
+ if (defined(invoker.use_run_test_component) &&
+ invoker.use_run_test_component) {
+ executable_args += [ "--use-run-test-component" ]
+ }
+
+ if (defined(invoker.use_test_server) && invoker.use_test_server) {
+ executable_args += [ "--enable-test-server" ]
+ }
+
+ if (default_fuchsia_build_dir_for_installation != "") {
+ executable_args += [
+ "--fuchsia-out-dir",
+ default_fuchsia_build_dir_for_installation,
+ ]
+ }
+
+ if (default_fuchsia_device_node_name != "") {
+ executable_args += [
+ "--node-name",
+ default_fuchsia_device_node_name,
+ ]
+ }
+ }
+
+ # Produces a script which installs a package and its dependencies into the
+ # package repository of a pre-existing Fuchsia build directory.
+ generate_wrapper(_generate_installer_target) {
+ executable = rebase_path("//build/fuchsia/deploy_to_pkg_repo.py")
+ wrapper_script = generated_install_pkg_script_path
+
+ data_deps = [ invoker.package ]
+ if (defined(invoker.data_deps)) {
+ data_deps += invoker.data_deps
+ }
+
+ # Build a list of all packages to install, and pass the list to the runner
+ # script.
+ package_paths = [ rebase_path(_package_path, root_build_dir) ]
+ if (defined(invoker.package_deps)) {
+ foreach(package_dep, invoker.package_deps) {
+ package_dep_target = package_dep[0]
+ package_dep_name = package_dep[1]
+
+ data_deps += [ package_dep_target ]
+ package_dep_path = rebase_path(
+ get_label_info(package_dep_target, "target_gen_dir") + "/" +
+ package_dep_name + "/" + package_dep_name + ".far",
+ root_build_dir)
+ package_paths += [ package_dep_path ]
+ }
+ }
+ executable_args = []
+ foreach(package_path, package_paths) {
+ executable_args += [
+ "--package",
+ "@WrappedPath(${package_path})",
+ ]
+
+ if (default_fuchsia_build_dir_for_installation != "") {
+ executable_args += [
+ "--fuchsia-out-dir",
+ default_fuchsia_build_dir_for_installation,
+ ]
+ }
+ }
+ }
+
+ group(target_name) {
+ deps = [ ":${_generate_installer_target}" ]
+
+ if (!defined(invoker.install_only) || invoker.install_only == false) {
+ deps += [ ":${_generate_runner_target}" ]
+ }
+ }
+}