blob: f74845a0863d725cf861695a4cffdd35eb313b53 [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")
# 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/boards.mako",
"//build/zircon/header.mako",
"//build/zircon/host_tool.mako",
"//build/zircon/main.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)
# 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 = [ ":*" ]
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"
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 = "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")