blob: 3dee313437f11dd11bc10f2f6e3c9cab4b6388b7 [file] [log] [blame]
# Copyright 2019 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/config/fuchsia/zircon.gni")
import("//build/gn/packages.gni")
import("//build/testing/platforms.gni")
declare_args() {
# If you add package labels to this variable, the packages will be included in
# the 'base' package set, which represents the set of packages that are part
# of an OTA. These pacakages are updated as an atomic unit during an OTA
# process and are immutable and are a superset of the TCB (Trusted Computing
# Base) for a product. These packages are never evicted by the system.
base_package_labels = []
# If you add package labels to this variable, the packages will be included
# in the 'cache' package set, which represents an additional set of software
# that is made available on disk immediately after paving and in factory
# flows. These packages are not updated with an OTA, but instead are updated
# ephemerally. This cache of software can be evicted by the system if storage
# pressure arises or other policies indicate.
cache_package_labels = []
# If you add package labels to this variable, the packages will be included
# in the 'universe' package set, which represents all software that is
# produced that is to be published to a package repository or to the SDK by
# the build. The build system ensures that the universe package set includes
# the base and cache package sets, which means you do not need to redundantly
# include those labels in this variable.
universe_package_labels = []
}
# Collect the source files that are dependencies of the create_gn_rules.py
# script, below. Unfortunately, exec_script cannot use a depfile produced
# by the script and only supports a separately computed list of dependencies.
zircon_files =
exec_script("//build/zircon/list_source_files.py", [], "list lines")
supporting_templates = [
"//build/zircon/header.mako",
"//build/zircon/shared_library.mako",
"//build/zircon/source_library.mako",
"//build/zircon/static_library.mako",
"//build/zircon/sysroot.mako",
]
# The following script generates GN build files for Zircon objects. It is
# placed before everything else so that //zircon targets are available in
# due time. See //build/zircon/README.md for more details.
exec_script("//build/zircon/create_gn_rules.py",
[
"--out",
rebase_path("//zircon/public"),
"--zircon-build",
rebase_path(zircon_root_build_dir),
"--zircon-manifest",
rebase_path("$zircon_root_build_dir/export/manifest-$target_cpu"),
],
"",
zircon_files + supporting_templates)
# Write a file that can be sourced by `fx`. This file is produced
# by `gn gen` and is not known to Ninja at all, so it has nothing to
# do with the build itself. Its sole purpose is to leave bread
# crumbs about the settings `gn gen` used for `fx` to use later.
_relative_build_dir = rebase_path(root_build_dir, "//", "//")
_fx_config_lines = [
"# Generated by `gn gen`.",
"FUCHSIA_BUILD_DIR='${_relative_build_dir}'",
"FUCHSIA_ARCH='${target_cpu}'",
]
write_file("$root_build_dir/fx.config", _fx_config_lines)
# This file indicates what Ninja invocation must be done to build Zircon
# prerequisites before *any* Ninja invocation for this build.
write_file("$root_build_dir/zircon.json",
{
dir = rebase_path(zircon_root_build_dir, root_build_dir)
targets = [ "legacy-$target_cpu" ]
},
"json")
# 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("recovery_image") {
deps = [
"build/images/recovery",
]
}
group("host_tests") {
visibility = [ ":*" ]
public_deps = [
"//build/gn:host_tests",
]
}
# 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"
# TODO(joshuaseaton|jinwoo): have this depend on a top-level //tests target,
# when such a target exists.
deps = [
":host_tests",
"//build/images:packages",
]
}
# Aggregates metadata about all fuzz targets within the build graph to create a
# top-level manifest.
generated_file("fuzzers") {
outputs = [
"$root_build_dir/fuzzers.json",
]
data_keys = [ "fuzz_spec" ]
output_conversion = "json"
deps = [
"//build/images:packages",
]
}
# 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 = "build/gn/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",
]
}
group("breakpad_symbols") {
public_deps = [
"//build/gn:breakpad_symbols",
]
}
group("package_archive") {
public_deps = [
"//build/gn:package_archive",
]
}
# Generates a JSON manifest of the platforms available for testing, along with
# their properties.
target_platforms = []
foreach(platform, test_platforms) {
if (!defined(platform.cpu) || platform.cpu == current_cpu) {
target_platforms += [ platform ]
}
}
write_file("$root_build_dir/platforms.json", target_platforms, "json")
# These groups exist at the root of the build so relative labels specified
# through GN args are interpreted as if they were absolute.
group("additional_base_packages") {
testonly = true
visibility = [ "//build/images:monolith_packages" ]
public_deps = base_package_labels
}
group("additional_cache_packages") {
testonly = true
visibility = [ "//build/images:preinstall_packages" ]
public_deps = cache_package_labels
}
group("additional_universe_packages") {
testonly = true
visibility = [ "//build/images:available_packages" ]
public_deps = universe_package_labels
}