rules_d
rules_d copied to clipboard
Refactor to use toolchains (hence enabling LDC support)
The Toolchain refactor is mostly done, but I'm a bit stuck on how to implement an idiomatic rules_d_toolchain()
macro to use in WORKSPACE
or as a bzlmod
extension. Basically, I want users to be able to do something like this:
# Some BUILD file
d_library(
name = "hello",
srcs = ["source/hello.d"],
dopts = select({
"@rules_d//compiler:dmd": ["-shared"],
"@rules_d//compiler:ldc": ["--shared"],
}),
)
but in the WORKSPACE
file they'll do something like this to register the toolchain:
# WORKSPACE
rules_d_toolchain(
compiler = "dmd" # or "ldc", or maybe even "gdc" in the future
version = "102.2.1" # optionally specify version
)
It'd be awesome if someone could provide some input on how this may be possible. If this is too much of a hassle, then I guess I'll drop LDC support for now and just leave the toolchain stuff in this PR.
Toolchain support has been tested and works well on Linux machines. Haven't got the chance to test on Windows or MacOS yet (as you can see DMD.bzl
and LDC.bzl
only have placeholder file locations for MacOS and Windows). Additionally, it seems like Windows build is broken even before this PR anyway.