load("//cc:cc_library.bzl", "cc_library")
load("//cc:cc_shared_library.bzl", "cc_shared_library")
load("//cc:cc_test.bzl", "cc_test")

package(default_visibility = ["//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library:__subpackages__"])

licenses(["notice"])

cc_library(
    name = "bar",
    srcs = ["bar.cc"],
    linkopts = select({
        "@platforms//os:macos": [
            "-framework",
            "Security",
            "-framework",
            "IOKit",
        ],
        ":macos_arm64": [
            "-framework",
            "Security",
        ],  # Seems there is no IOKit framework on arm64.
        "//conditions:default": [],
    }),
    alwayslink = 1,
)

cc_shared_library(
    name = "bar_so",
    deps = [":bar"],
)

# This is not an actual test, we're just ensuring that this target builds.
# And it needs to be cc_test rather than cc_binary because of the blaze test
# command in src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh:65
cc_test(
    name = "cc_test",
    srcs = ["main.cc"],
    dynamic_deps = [":bar_so"],
)

config_setting(
    name = "macos_arm64",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:macos",
    ],
)
