blob: 9b2f7acf3edcf5dae95db2411649a81495b49a16 [file]
# Copyright 2026 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.
load("//build/bazel/rules/cc:fx_cc_library.bzl", "fx_cc_library")
load("//build/bazel/rules/cc:fx_cc_library_headers.bzl", "fx_cc_library_headers")
package(default_applicable_licenses = ["//:license"])
alias(
name = "testing",
testonly = True,
actual = ":elfldltl-testing",
visibility = [
"//sdk/lib:__subpackages__",
"//src:__subpackages__",
],
)
# Header-only grouping of `headers.common` and GoogleTest. `bazel2gn` has no
# CcInfo-forwarding equivalent of GN `group()`, so use an empty
# `fx_cc_library_headers()`, which bazel2gn emits as a source-less
# `library_headers()` (a source_set with no outputs) rather than an empty
# `static_library()` archive.
fx_cc_library_headers(
name = "headers",
testonly = True,
hdrs = [],
visibility = [
"//sdk/lib:__subpackages__",
"//src:__subpackages__",
],
deps = [
":headers.common",
"@com_google_googletest//:gtest",
],
)
fx_cc_library_headers(
name = "headers.common",
testonly = True,
hdrs = [
"include/lib/elfldltl/testing/diagnostics.h",
"include/lib/elfldltl/testing/ehdr.h",
"include/lib/elfldltl/testing/fuzzer.h",
"include/lib/elfldltl/testing/fuzzer/diagnostics.h",
"include/lib/elfldltl/testing/fuzzer/ehdr.h",
"include/lib/elfldltl/testing/fuzzer/file.h",
"include/lib/elfldltl/testing/fuzzer/machine.h",
"include/lib/elfldltl/testing/fuzzer/mmapper.h",
"include/lib/elfldltl/testing/fuzzer/symbol.h",
"include/lib/elfldltl/testing/get-test-data.h",
"include/lib/elfldltl/testing/loader.h",
"include/lib/elfldltl/testing/note.h",
"include/lib/elfldltl/testing/test-pipe-reader.h",
"include/lib/elfldltl/testing/typed-test.h",
],
# Kept for bazel2gn so the generated GN target stays package-private.
visibility = [":__pkg__"],
deps = [
"//sdk/lib/fit",
"//sdk/lib/zircon-assert",
"//src/lib/elfldltl",
"//zircon/system/ulib/fbl",
],
)
fx_cc_library(
name = "elfldltl-testing",
testonly = True,
srcs = [
"get-test-data-path.cc",
"test-pipe-reader.cc",
] + select({
"@platforms//os:fuchsia": [
"get-test-lib.cc",
"get-test-lib-vmo.cc",
],
"//conditions:default": [],
}),
implementation_deps = [
"@com_google_googletest//:gtest",
] + select({
"@platforms//os:fuchsia": [
"//sdk/fidl/fuchsia.ldsvc:fuchsia.ldsvc_cpp",
"//sdk/lib/fdio",
"//zircon/system/ulib/zx",
],
"//conditions:default": [],
}),
visibility = [
"//sdk/lib:__subpackages__",
"//src:__subpackages__",
],
deps = [":headers"],
)
# This is a subset built for use with zxtest in a standalone test.
fx_cc_library(
name = "elfldltl-zxtest",
testonly = True,
srcs = select({
"@platforms//os:fuchsia": ["get-test-lib-vmo.cc"],
"//conditions:default": [],
}),
implementation_deps = select({
"@platforms//os:fuchsia": [
"//sdk/fidl/fuchsia.ldsvc:fuchsia.ldsvc_cpp",
"//zircon/system/ulib/zx",
],
"//conditions:default": [],
}),
visibility = [
"//src/bringup/lib/restricted-machine:__pkg__",
"//zircon/system/utest/core/standalone-elf-load:__pkg__",
],
deps = [":headers.zxtest"],
)
# Like `headers`, but for zxtest. An empty `fx_cc_library_headers()` replaces
# the former GN `group()` plus hand-written `config("use-zxtest.config")`:
# `defines` propagates `USE_ZXTEST` to dependents in Bazel, and in GN via the
# public config that `library_headers()` generates.
fx_cc_library_headers(
name = "headers.zxtest",
testonly = True,
hdrs = [],
defines = ["USE_ZXTEST"],
# Kept for bazel2gn so the generated GN target stays package-private.
visibility = [":__pkg__"],
deps = [
":headers.common",
"//zircon/system/ulib/zxtest:zxtest-streams",
],
)