blob: 8768819b889c7abbacd97112cc61bf3591c73537 [file] [log] [blame]
# Copyright 2018 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/config/standard.gni")
import("$zx/public/gn/host_tool_action.gni")
import("$zx/public/gn/toolchain/select_toolchain.gni")
# Build the native host tools intended for developer use.
foreach(host, standard_build_hosts) {
select_toolchain("tools-${host.os}-${host.cpu}") {
testonly = true
environment_label = "$zx/public/gn/toolchain:host"
cpu = host.cpu
os = host.os
deps = [
"$zx/system/host:tools",
]
}
}
group("tools") {
testonly = true
deps = [
":tools-${host_os}-${host_cpu}",
]
if (false) { # TODO(get_metadata): later copy("tools")
# Install the host developer tools for the running host platform in the
# "$root_build_dir/tools/" directory.
sources = [
get_metadata(deps, [ "tool_executables" ]),
]
outputs = [
"$root_build_dir/tools/{{source_file_part}}",
]
}
}
public_targets = [
"bootloader",
"kernel",
"core",
]
testonly_public_targets = [
"bin",
"drivers",
]
# Each cpu is a target name for all the public targets for that CPU.
foreach(cpu, standard_fuchsia_cpus) {
group(cpu) {
testonly = true
deps = []
foreach(target, public_targets + testonly_public_targets) {
deps += [ "$zx/public/$target:$cpu" ]
}
# TODO(get_metadata): dismal kludge
#deps += [ ":$cpu.zbi" ]
}
}
# Each public target is a target name for all the CPUs for that target.
foreach(target, public_targets + testonly_public_targets) {
group(target) {
testonly = public_targets + [ target ] - [ target ] == public_targets
deps = []
foreach(cpu, standard_fuchsia_cpus) {
deps += [ "$zx/public/$target:$cpu" ]
}
}
}
group("all-cpu") {
testonly = true
deps = []
foreach(cpu, standard_fuchsia_cpus) {
deps += [ ":$cpu.zbi" ]
}
# TODO(get_metadata): dismal kludge, used below
write_runtime_deps = "$root_build_dir/runtime_deps"
}
group("default") {
testonly = true
deps = [
":all-cpu",
":tools",
]
}
# TODO(get_metadata): dismal kludge
foreach(cpu, standard_fuchsia_cpus) {
if (false) {
action("bootfs-$cpu.manifest") {
testonly = true
script = "munge-manifest.sh"
deps = [
":fmh",
]
outputs = [
"$root_build_dir/$target_name",
]
sources = [
"$root_build_dir/runtime_deps",
]
depfile = "${outputs[0]}.d"
args = rebase_path(outputs + sources + [ depfile ], root_build_dir) +
[ "bootfs-$cpu" ]
}
} else {
write_data("bootfs-$cpu.manifest") {
testonly = true
deps = [
":$cpu",
]
outputs = [
"$root_build_dir/$target_name",
]
output_conversion = "list lines"
data_keys = [ "manifest_lines" ]
}
}
host_tool_action("$cpu.zbi") {
testonly = true
tool = "$zx/system/host/zbi"
outputs = [
"$root_build_dir/$target_name",
]
depfile = "${outputs[0]}.d"
args = [
"--complete=$cpu",
"--output=" + rebase_path(outputs[0], root_build_dir),
"--depfile=" + rebase_path(depfile, root_build_dir),
]
deps = [
":bootfs-$cpu.manifest",
]
sources = [
"$root_build_dir/bootfs-$cpu.manifest",
]
#sources = get_target_outputs(deps[0])
foreach(target, public_targets + testonly_public_targets) {
deps += [ "$zx/public/$target:$cpu" ]
}
sources += [ get_label_info("$zx/kernel($zx/kernel:kernel-$cpu-clang)",
"root_out_dir") + "/kernel.zbi" ]
args += rebase_path(sources, root_build_dir)
}
}
# TODO(get_metadata): oy
action("fmh") {
visibility = [ ":*" ]
outputs = [
"$root_build_dir/runtime_deps",
]
script = "/usr/bin/touch"
args = rebase_path(outputs, root_build_dir)
}