# -*- bazel -*-

load("@drake//tools/skylark:cc.bzl", "cc_binary", "cc_library")
load(
    "@drake//tools/workspace:cmake_configure_file.bzl",
    "cmake_configure_file",
)
load("@drake//tools/workspace/openusd_internal:defs.bzl", "pxr_library")
load("@drake//tools/workspace/openusd_internal:lock/files.bzl", "FILES")

package(default_visibility = ["//visibility:private"])

filegroup(
    name = "cmakelists",
    srcs = glob(["**/CMakeLists.txt"]),
    visibility = ["//visibility:public"],
)

cmake_configure_file(
    name = "config_genrule",
    src = "pxr/pxr.h.in",
    out = "pxr/pxr.h",
    cmakelists = [
        "cmake/defaults/Version.cmake",
    ],
    defines = [
        # Match the upstream default.
        "PXR_PREFER_SAFETY_OVER_SPEED",
        # We don't need Python.
        "PXR_PYTHON_SUPPORT_ENABLED=0",
        # Use Drake-specific namespaces.
        "PXR_USE_NAMESPACES=1",
        "PXR_EXTERNAL_NAMESPACE=drake_vendor_pxr",
        "PXR_INTERNAL_NAMESPACE=drake_vendor_pxrInternal",
        # Re-implement the math from OpenUSD/cmake/Version.cmake.
        "PXR_VERSION=(@PXR_MAJOR_VERSION@ * 10000 + @PXR_MINOR_VERSION@ * 100 + @PXR_PATCH_VERSION@)",  # noqa
    ],
)

cc_library(name = "pxr_h", hdrs = [":pxr/pxr.h"])

[
    pxr_library(subdir = subdir)
    for subdir in FILES
]

cc_library(
    name = "openusd",
    deps = [
        ":ar",
        ":arch",
        ":gf",
        ":js",
        ":kind",
        ":ndr",
        ":pcp",
        ":plug",
        ":sdf",
        ":sdr",
        ":tf",
        ":trace",
        ":usd",
        ":usdGeom",
        ":usdShade",
        ":usdUtils",
        ":vt",
        ":work",
    ],
    alwayslink = True,
    linkstatic = True,
    visibility = ["//visibility:public"],
)
