blob: 14485d9d75c262c060d2a9e266a0d0d3f3c5d1ee [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/gn/packages.gni")
import("//build/package.gni")
import("//build/toolchain/goma.gni")
# Permit dependencies on testonly targets from packages.
testonly = true
group("packages") {
deps = package_targets
data_deps = package_data_deps
}
group("default") {
deps = [
":host_tests",
":packages",
]
if (package_targets != []) {
deps += [
"//build/images",
"//build/images:updates",
]
}
}
# Instantiate the packages synthesized from the build argument.
foreach(pkg, synthesize_packages) {
package(pkg.name) {
forward_variables_from(pkg, "*", [ "name" ])
}
}
# Copy host test binaries to $root_build_dir/host_tests.
if (package_host_tests != []) {
copy("host_tests") {
deps = []
sources = []
bindir = get_label_info("//anything($host_toolchain)", "root_out_dir")
foreach(label, package_host_tests) {
deps += [ "$label($host_toolchain)" ]
binary = get_label_info(label, "name")
sources += [ "$bindir/$binary" ]
}
outputs = [
"$root_build_dir/host_tests/{{source_file_part}}",
]
}
} else {
group("host_tests") {
}
}
# TODO(BLD-31): This Zircon->GN magic needs some comments.
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"),
"--staging",
rebase_path("$root_out_dir/zircon-gn"),
"--zircon-user-build",
rebase_path("//out/build-zircon/build-\${target_cpu}"),
"--zircon-tool-build",
rebase_path("//out/build-zircon"),
],
"",
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}'",
]
if (use_goma) {
_fx_config_lines += [
"# This will affect Zircon's make via //scripts/build-zircon.sh.",
"export GOMACC='${goma_dir}/gomacc'",
]
}
write_file("$root_build_dir/fx.config", _fx_config_lines)