blob: abbe0bc7c72ecd15682a5e89183239acd2477b04 [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/host_tool_action.gni")
_abigen_label =
"$zx/kernel/syscalls:generate_syscalls.abigen($default_toolchain)"
_abigen_dir = get_label_info(_abigen_label, "root_gen_dir")
abigen_source_file = "$_abigen_dir/syscalls.abigen"
# Generate syscall bindings/information from `syscalls.banjo`.
#
# Parameters
#
# gen
# Required: List of scopes describing `abigen` output files.
# Type: scope as follows
# outputs
# Required: As for action().
# Type: list(file)
# args
# Required: Output-related arguments to `abigen`.
# This should contain switches and the $root_build_dir-relative
# form of the files named in $outputs.
# Type: list(string)
#
# TODO(ZX-3882): This is temporarily a two-step process. First, run banjo to
# generate a .abigen file (done by
# $zx/kernel/syscalls:generate_syscalls.abigen), then run the existing abigen
# tool on the generated file. This is an intermediate situation until banjo
# directly generates all outputs.
template("abigen") {
host_tool_action(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
tool = "$zx/tools/abigen"
deps = [
_abigen_label,
]
sources = [
abigen_source_file,
]
outputs = []
args = []
foreach(gen, invoker.gen) {
outputs += gen.outputs
args += gen.args + rebase_path(gen.outputs, root_build_dir)
}
args += rebase_path(sources, root_build_dir)
metadata = {
generated_sources = rebase_path(outputs, root_build_dir)
}
}
}