blob: 0d0995ccba4f7f47a68353b9270f0f6f1b09d4ac [file] [log] [blame]
# Copyright 2016 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/compiled_action.gni")
import("//build/config/fuchsia/zircon.gni")
import("//build/gn/packages.gni")
import("//build/package.gni")
import("//build/toolchain/goma.gni")
# Permit dependencies on testonly targets from packages.
testonly = true
group("default") {
deps = [
":copy_host_tests",
"//build/images:packages",
]
if (preinstall_package_labels != [] || monolith_package_labels != []) {
deps += [ "//build/images" ]
}
if (available_package_labels != []) {
deps += [ "//build/images:updates" ]
}
}
group("host_tests") {
visibility = [
":*",
"//:host_tests",
]
public_deps = []
foreach(label, package_host_tests) {
public_deps += [ "$label($host_toolchain)" ]
}
deps = [
# Currently host tests dependencies wind up as dependencies of the packages.
# TODO: We should more cleanly separate host targets (including tests) from
# packages.
"//build/images:packages",
]
}
# TODO(joshuaseaton|mcgrathr): Make this a formal build_api_module.
#
# Aggregates metadata about all tests within the build graph to create a
# top-level manifest.
generated_file("tests") {
outputs = [
"$root_build_dir/tests.json",
]
data_keys = [ "test_spec" ]
output_conversion = "json"
deps = [
":host_tests",
"//build/images:packages",
]
}
# TODO(IN-819): Provides supplementary metadata for tests no yet contributing
# test spec metadata (e.g., flutter_test).
generated_file("pseudo_tests") {
outputs = [
"$root_build_dir/pseudo_tests.json",
]
data_keys = [ "pseudo_test_spec" ]
output_conversion = "json"
deps = [
":host_tests",
]
}
# Copy host test binaries to $root_build_dir/host_tests.
# TODO(IN-819): Delete this copy target once host tests are no longer run out
# of a single directory.
action("copy_host_tests") {
script = "copy_host_tests.py"
inputs = [
"$root_build_dir/tests.json",
"$root_build_dir/pseudo_tests.json",
]
outputs = [
"$target_gen_dir/copy_host_tests.stamp",
]
depfile = "$target_gen_dir/copy_host_tests.d"
args = [
"--json",
rebase_path(inputs[0]),
"--json",
rebase_path(inputs[1]),
"--dest-dir",
rebase_path("$root_build_dir/host_tests"),
"--stamp",
rebase_path(outputs[0]),
"--depfile",
rebase_path(depfile),
]
deps = [
":host_tests",
":pseudo_tests",
":tests",
"//build/images:packages",
]
}
# Generates breakpad symbol data for unstripped binaries.
#
# This symbol data is consumed by infrastructure tools and uploaded to Crash
# servers to enable crash reporting. These files are uniquely important for
# release builds and this step may take a few minutes to complete, so it is
# not recommended that this be included in the default build.
action("breakpad_symbols") {
testonly = true
script = "//buildtools/${host_platform}/dump_breakpad_symbols"
deps = [
"//build/images:ids.txt",
]
inputs = [
"//buildtools/${host_platform}/dump_syms/dump_syms",
]
sources = [
"$root_out_dir/ids.txt",
]
# This action generates a single xxx.sym file for each binary in the ids file
# and produces an archived output of them all.
outputs = [
"$root_out_dir/breakpad_symbols/breakpad_symbols.tar.gz",
]
depfile = "${outputs[0]}.d"
args = [
"-out-dir",
rebase_path("$root_out_dir/breakpad_symbols"),
"-dump-syms-path",
rebase_path("//buildtools/${host_platform}/dump_syms/dump_syms"),
"-depfile",
rebase_path(depfile, root_build_dir),
"-tar-file",
rebase_path(outputs[0], root_build_dir),
] + rebase_path(sources, root_build_dir)
}
# Generates an archive of package metadata.
amber_files = rebase_path("$root_build_dir/amber-files")
host_out_dir = get_label_info("//anything($host_toolchain)", "root_out_dir")
pm_tool = rebase_path("$host_out_dir/pm")
pkg_archive_contents = [
"amber-files/repository=$amber_files/repository",
# TODO(IN-915): this should never contain the root key. In the future, this
# should contain no keys, once infra is managing key material itself.
# These keys are consumed by the infra train promote scripts.
"amber-files/keys=$amber_files/keys",
"pm=$pm_tool",
]
pkg_archive_manifest = "$target_gen_dir/package_archive_manifest"
write_file(pkg_archive_manifest, pkg_archive_contents)
pkg_archive = "$root_build_dir/packages.tar.gz"
compiled_action("package_archive") {
testonly = true
tool = "//build/tools/tar_maker"
inputs = [
pkg_archive_manifest,
]
outputs = [
pkg_archive,
]
args = [
"-manifest",
rebase_path(pkg_archive_manifest),
"-output",
rebase_path(pkg_archive),
]
deps = [
"//build/images:updates",
]
}