blob: 24db885c58e410aad84a523946a6f41ac4e9bcb8 [file] [log] [blame]
# Copyright 2022 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/components.gni")
import("//build/test.gni")
import("//build/zircon/migrated_targets.gni")
zx_library("zxdump") {
sdk = "source"
sdk_headers = [
"lib/zxdump/dump.h",
"lib/zxdump/fd-writer.h",
"lib/zxdump/types.h",
]
public_deps = [
# <lib/zxdump/types.h> has #include <zircon/types.h>.
"//zircon/system/public",
# <lib/zxdump/fd-writer.h> has #include <lib/fitx/result.h>.
"//zircon/system/ulib/zxc",
# <lib/zxdump/dump.h> has #include <lib/fit/function.h>.
"//sdk/lib/fit",
# <lib/zxdump/fd-writer.h> has #include <fbl/unique_fd.h>.
"//zircon/system/ulib/fbl",
]
if (is_fuchsia) {
public_deps += [
# <lib/zxdump/dump.h> has #include <lib/zx/process.h>.
"//zircon/system/ulib/zx",
]
}
sources = [
"core.h",
"error.cc",
"fd-writer.cc",
]
deps = [ "//src/lib/elfldltl" ]
if (is_fuchsia) {
sources += [ "dump.cc" ]
deps += [
"//sdk/lib/stdcompat",
"//src/zircon/lib/zircon",
"//zircon/system/ulib/zx",
]
}
}
source_set("piped-command") {
visibility = [ ":*" ]
public = [ "piped-command.h" ]
public_deps = [
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/zxc",
]
sources = [ "piped-command.cc" ]
if (is_fuchsia) {
sources += [ "piped-command-fuchsia.cc" ]
public_deps += [ "//sdk/lib/fdio" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zx",
]
} else {
sources += [ "piped-command-posix.cc" ]
}
}
source_set("test-tool-process") {
visibility = [ ":*" ]
testonly = true
public = [ "test-tool-process.h" ]
public_deps = [ "//zircon/system/ulib/fbl" ]
sources = [ "test-tool-process.cc" ]
deps = [
":piped-command",
"//third_party/googletest:gtest",
]
if (is_fuchsia) {
public_deps += [ "//zircon/system/ulib/zx" ]
deps += [
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_llcpp",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
"//zircon/system/ulib/service:service-llcpp",
]
}
}
test("zxdump-unittests") {
sources = [
"error-tests.cc",
"fd-writer-tests.cc",
"piped-command-tests.cc",
]
deps = [
":piped-command",
":test-tool-process",
":zxdump",
"//sdk/lib/fit",
"//src/lib/elfldltl",
"//src/lib/fxl/test:gtest_main",
"//zircon/system/ulib/fbl",
]
# Depend on the base toolchain in case both the child and this target use
# the same variant, so that the copy under the expected name can be found
# at runtime.
data_deps = [ ":zxdump-test-child(${toolchain_variant.base})" ]
if (is_fuchsia) {
sources += [
"dump-tests.h",
"gcore-tests.cc",
]
data_deps += [ ":gcore(${toolchain_variant.base})" ]
}
}
executable("zxdump-test-child") {
testonly = true
sources = [ "test-child.cc" ]
deps = [
"//sdk/lib/stdcompat",
"//zircon/system/ulib/fbl",
]
if (is_fuchsia) {
deps += [
"//sdk/lib/fdio",
"//src/zircon/lib/zircon",
"//zircon/system/ulib/zx",
]
}
if (is_host) {
base_out_dir = get_label_info(":$target_name(${toolchain_variant.base})",
"root_out_dir")
metadata = {
test_runtime_deps = [ "$base_out_dir/$target_name" ]
}
}
}
fuchsia_unittest_package("zxdump-tests") {
deps = [ ":zxdump-unittests" ]
manifest = "meta/zxdump-unittests.cml"
}
group("tests") {
testonly = true
deps = [
":zxdump-tests",
":zxdump-unittests($host_toolchain)",
# TODO(mcgrathr): just to get them built for now
":zxdump-tools",
]
}
executable("gcore") {
sources = [ "gcore.cc" ]
deps = [
":zxdump",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/task-utils",
]
}
group("tools") {
deps = [ ":gcore" ]
}
fuchsia_shell_package("zxdump-tools") {
deps = [ ":tools" ]
}