From 5066808a4e8a97d953115c574f080002c7db3412 Mon Sep 17 00:00:00 2001 From: 0xbeefd1ed Date: Thu, 2 Jul 2026 12:21:11 -0700 Subject: [PATCH] Expose a :slang library target from the generated SDK repo The SDK bundles the slang compiler as a shared library, but consumers that link against it (e.g. shader-slang bindings) currently have to reach into sdk/lib with a hardcoded filename. On macOS that filename embeds the slang version (`libslang-compiler.0.2026.1.dylib`), which means every SDK bump breaks downstream BUILD files -- and downstream repos cannot glob files that live inside the SDK repository. Add a `:slang` target to the generated BUILD, mirroring the existing `:vulkan` loader target: - Windows: a cc_import pairing sdk/Lib/slang.lib with sdk/Bin/slang.dll. - Linux/macOS: the bazelbuild/bazel#4748 cc_library workaround, globbing the shared library. The macOS glob intentionally matches the versioned dylib rather than the `libslang-compiler.dylib` symlink: the library's install name (LC_ID_DYLIB) is `@rpath/libslang-compiler..dylib`, so the file must be staged under its versioned name for dyld to resolve it at runtime. Since the glob runs inside the generated repo, consumers can now just depend on `@vulkan_sdk_//:slang` regardless of which slang version the SDK bundles. Co-Authored-By: Claude Opus 4.8 --- vulkan/private/template.BUILD | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/vulkan/private/template.BUILD b/vulkan/private/template.BUILD index 939e1b0..6460f2c 100644 --- a/vulkan/private/template.BUILD +++ b/vulkan/private/template.BUILD @@ -75,6 +75,37 @@ cc_library( }), ) +# +# Slang compiler library +# + +cc_import( + name = "slang_dll", + interface_library = "sdk/Lib/slang.lib", + shared_library = "sdk/Bin/slang.dll", + target_compatible_with = [ + "@platforms//os:windows", + ], +) + +cc_library( + name = "slang", + # buildifier: disable=constant-glob + srcs = glob( + [ + # Linux + "sdk/lib/libslang.so", + # macOS + "sdk/lib/libslang-compiler.*.dylib", + ], + allow_empty = True, + ), + deps = select({ + "@platforms//os:windows": [":slang_dll"], + "//conditions:default": [], + }), +) + # # SDK compilers and tools #