blob: 5fc5e300464dae5e756916730b4eded19a0e73a7 [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/toolchain/c_utils.gni")
import("$zx/vdso/vdso.gni")
import("$zx_build/public/gn/migrated_targets.gni")
config("kazoo_config") {
visibility = [ ":*" ]
include_dirs = [ rebase_path("../..") ]
}
zx_library("kazoo_lib") {
host = true
if (zx != "/") {
# NOTE: The unification zx_library() template requires an sdk field.
sdk = "source"
sdk_migrated = true
}
configs += [ ":kazoo_config" ]
sources = [
"alias_workaround.cc",
"alias_workaround.h",
"c_ulib_header_output.cc",
"category_output.cc",
"cdecl_output.cc",
"go_syscalls_output.cc",
"go_vdso_output.cc",
"json_output.cc",
"kernel_wrappers_output.cc",
"ktrace_output.cc",
"output_util.cc",
"output_util.h",
"outputs.h",
"rust_output.cc",
"string_util.cc",
"string_util.h",
"syscall_library.cc",
"syscall_library.h",
"syscall_numbers_output.cc",
"writer.cc",
"writer.h",
]
deps = [ "$zx/system/public" ]
public_deps = [ "$zx/third_party/rapidjson" ]
# TODO(fxbug.dev/58162): delete the below and fix compiler warnings
configs += [ "$zx_build_config:Wno-conversion" ]
}
zx_host_tool("kazoo") {
configs += [ ":kazoo_config" ]
sdk_migrated = true
sources = [ "main.cc" ]
deps = [ ":kazoo_lib" ]
deps += [ "$zx/system/ulib/cmdline" ]
}
group("tests") {
testonly = true
deps = [
":kazoo-syscall-golden-test",
":kazoo-unittests",
]
}
zx_test("kazoo-unittests") {
configs += [ ":kazoo_config" ]
output_name = "kazoo-test"
sdk_migrated = true
deps = [
":generate_test_files",
":kazoo_lib",
]
# The "../.." is so that the generated files can be included with a
# "tools/kazoo/" prefix.
include_dirs = [ "$target_gen_dir/../.." ]
sources = [
"alias_workaround_test.cc",
"c_ulib_header_output_test.cc",
"category_output_test.cc",
"cdecl_output_test.cc",
"go_syscalls_output_test.cc",
"go_vdso_output_test.cc",
"json_output_test.cc",
"kernel_wrappers_output_test.cc",
"ktrace_output_test.cc",
"output_util_test.cc",
"rust_output_test.cc",
"string_util_test.cc",
"syscall_library_test.cc",
"syscall_numbers_output_test.cc",
"test_main.cc",
"writer_test.cc",
]
# TODO(fxbug.dev/58162): delete the below and fix compiler warnings
configs += [ "$zx_build_config:Wno-conversion" ]
}
zx_host_tool_action_foreach("test_files_fidl_to_json") {
tool = "$zx/tools/fidl:fidlc"
args = [
"--json",
rebase_path("$target_gen_dir") + "/{{source_name_part}}.json",
"--files",
"{{source}}",
rebase_path("$zx/vdso/zx_common.fidl"),
rebase_path("$zx/vdso/zx_syscall.fidl"),
]
inputs = [
"$zx/vdso/zx_common.fidl",
"$zx/vdso/zx_syscall.fidl",
]
outputs = [ "$target_gen_dir/{{source_name_part}}.json" ]
sources = [
"test_aliases.test.fidl",
"test_go_nonblocking.test.fidl",
"test_go_reserved_words.test.fidl",
"test_kernel_cases.test.fidl",
"test_kernelwrappers.test.fidl",
"test_no_methods.test.fidl",
"test_one_protocol_one_method.test.fidl",
"test_one_protocol_two_methods.test.fidl",
"test_one_protocol_two_methods_with_internal.test.fidl",
"test_out_voidptr.test.fidl",
"test_ownership_annotations.test.fidl",
"test_pointers_and_vectors.test.fidl",
"test_rights_specs.test.fidl",
"test_rust_selection.test.fidl",
"test_selection.test.fidl",
"test_various_categories.test.fidl",
"test_vdsowrappers.test.fidl",
]
}
zx_host_tool_action_foreach("test_files_fidl_to_json_zxio") {
tool = "$zx/tools/fidl:fidlc"
args = [
"--json",
rebase_path("$target_gen_dir") + "/{{source_name_part}}.json",
"--experimental",
"disallow_old_handle_syntax",
"--files",
"{{source}}",
# No zx fidls here compared with above.
]
outputs = [ "$target_gen_dir/{{source_name_part}}.json" ]
sources = [
"test_ulib_bits.test.fidl",
"test_ulib_enums.test.fidl",
"test_ulib_tables.test.fidl",
"test_ulib_type_aliases.test.fidl",
]
}
action_foreach("generate_test_files") {
script = "fidl_to_h.py"
deps = [
":test_files_fidl_to_json",
":test_files_fidl_to_json_zxio",
]
args = [
"{{source}}",
rebase_path("$target_gen_dir") + "/test_ir_{{source_name_part}}.h",
"{{source_name_part}}",
]
outputs = [ "$target_gen_dir/test_ir_{{source_name_part}}.h" ]
sources = get_target_outputs(":test_files_fidl_to_json") +
get_target_outputs(":test_files_fidl_to_json_zxio")
}
fidlc_rspfile = "$target_gen_dir/fidlc.rspfile"
link_output_rspfile("fidlc.rspfile") {
visibility = [ ":*" ]
outputs = [ fidlc_rspfile ]
deps = [ "$zx/tools/fidl:fidlc" ]
}
kazoo_rspfile = "$target_gen_dir/kazoo.rspfile"
link_output_rspfile("kazoo.rspfile") {
visibility = [ ":*" ]
outputs = [ kazoo_rspfile ]
deps = [ ":kazoo" ]
}
action("kazoo-syscall-golden-test") {
deps = [
":fidlc.rspfile",
":kazoo.rspfile",
]
fidlc = get_target_outputs(deps[0])
assert(fidlc == [ fidlc[0] ])
fidlc = fidlc[0]
kazoo = get_target_outputs(deps[1])
assert(kazoo == [ kazoo[0] ])
kazoo = kazoo[0]
script = "golden-test"
sources = [
"golden.txt",
fidlc,
kazoo,
]
foreach(fidl, all_syscall_fidl_files) {
sources += [ "../../vdso/" + fidl ]
}
outputs = [ "$target_gen_dir/kazoo-golden-test" ]
args = [
"--builddir",
rebase_path(root_build_dir),
"--fidlc",
rebase_path(fidlc, root_build_dir),
"--kazoo",
rebase_path(kazoo, root_build_dir),
"--syscalls",
rebase_path("../../vdso"),
"--output-touch",
rebase_path(outputs[0], root_build_dir),
"--tmp-base",
rebase_path(target_gen_dir, root_build_dir),
]
}