blob: f227f23630fcf8ced53525c6fd3bfe9cbbe2bdb1 [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("$zx/public/gn/build_api_module.gni")
import("$zx/public/gn/config/standard.gni")
import("$zx/public/gn/copied_files_dir.gni")
import("$zx/public/gn/prebuilt.gni")
import("$zx/public/gn/test/zbi_test.gni")
import("$zx/public/gn/toolchain/c_utils.gni")
import("$zx/public/gn/toolchain/environment_redirect.gni")
import("$zx/public/gn/zbi.gni")
declare_args() {
# Defines the `//:default` target: what `ninja` with no arguments does.
# TODO(fxbug.dev/3156): This must be set by the controlling Fuchsia GN build.
default_deps = false
}
assert(default_deps != false,
"TODO(fxbug.dev/3156): Zircon build must be driven by Fuchsia build")
###
### Build API modules.
###
# This is the top-level build API module that just lists all the others.
# Each element of the list is the simple name of the API module; the
# module's contents are found at "$root_build_dir/$target_name.json".
#
# TODO(fxbug.dev/3156): Note this does not include build_api_module() uses meant
# just for legacy build integration. We don't consider those to be actual
# build API modules; using build_api_module() is just a convenience for
# creating them. Importantly, they are not part of the API contract with
# consumers of the overall build. They're purely implementation details of
# the temporary Frankenbuild arrangement.
#
# Type: list(string)
build_api_module("api") {
testonly = true
data_keys = [ "build_api_modules" ]
deps = [
":args",
":binaries",
":generated_sources",
]
}
# See //:args in the fuchsia build for a description.
build_api_module("args") {
contents = read_file("$root_build_dir/args.gn", "scope")
}
# See //:binaries for a description and schema definition.
# in file: "$root_build_dir/binaries.json"
#
build_api_module("binaries") {
testonly = true
deps = [ ":everything" ]
data_keys = [ "binaries" ]
}
# See //:generated_sources for a description and schema definition.
# in file: "$root_build_dir/generated_sources.json"
#
build_api_module("generated_sources") {
testonly = true
deps = [ ":everything" ]
data_keys = [ "generated_sources" ]
}
###
### Top-level targets.
###
# This is used in the top-level build_api_module() deps to reach "everything".
# Note that "all" is a magical target name to Ninja, hence this name instead.
group("everything") {
testonly = true
deps = default_deps
}
# This is the default target that Ninja builds when given no target arguments.
group("default") {
testonly = true
deps = default_deps
}
###
### TODO(fxbug.dev/3156): Temporary hacks for integrating with the legacy Fuchsia
### GN build.
###
if (current_toolchain == default_toolchain) {
build_api_module("legacy_dirs") {
testonly = true
data_keys = [ "legacy_dirs" ]
walk_keys = [ "legacy_barrier" ]
deps = []
foreach(cpu, standard_fuchsia_cpus) {
deps += [ ":legacy-$cpu" ]
}
}
foreach(cpu, standard_fuchsia_cpus) {
group("legacy-$cpu") {
testonly = true
deps = [ ":legacy-deps-$cpu" ]
}
}
}
foreach(cpu, standard_fuchsia_cpus) {
environment_redirect("legacy-deps-$cpu") {
visibility = [ ":*" ]
testonly = true
environment_label = "$zx/public/gn/toolchain:user"
cpu = cpu
deps = [ "$zx/kernel" ]
metadata = {
legacy_barrier = []
}
}
}
build_api_module("legacy_images") {
testonly = true
data_keys = [ "images" ]
deps = []
foreach(cpu, standard_fuchsia_cpus) {
deps += [ ":legacy-$cpu" ]
}
}
# This target complements legacy_images in that it lists the various elements
# that end up in images.
foreach(cpu, standard_fuchsia_cpus) {
build_api_module("legacy_unification-$cpu") {
testonly = true
data_keys = [ "zx_manifest" ]
deps = [ ":legacy-$cpu" ]
}
}