Skip to content

Commit 3be4801

Browse files
authored
Merge pull request #66 from dcarp/main
Select LDC compiler for macos-latest (aarch64)
2 parents 5429157 + 3e06f8a commit 3be4801

File tree

6 files changed

+27
-170
lines changed

6 files changed

+27
-170
lines changed

.github/workflows/bazel-v7.2.2-patched.yaml

Lines changed: 0 additions & 163 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
cancel-in-progress: ${{ github.ref_name != 'main' }}
1616
jobs:
1717
test:
18-
uses: ./.github/workflows/bazel-v7.2.2-patched.yaml
18+
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v7.2.2
1919
with:
2020
folders: |
2121
[

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
1919
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True)
2020

2121
d = use_extension("//d:extensions.bzl", "d")
22-
d.toolchain(d_version = "dmd-2.111.0")
22+
d.toolchain(d_version = "auto")
2323
use_repo(d, "d_toolchains")
2424

2525
register_toolchains("@d_toolchains//:all")

d/extensions.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ d_toolchain = tag_class(attrs = {
1919
Base name for generated repositories, allowing more than one d toolchain to be registered.
2020
Overriding the default is only permitted in the root module.
2121
""", default = _DEFAULT_NAME),
22-
"d_version": attr.string(doc = "Explicit version of d.", mandatory = True),
22+
"d_version": attr.string(doc = """\
23+
Version of the compiler. "auto" will select latest known dmd or ldc compiler available for
24+
the current platform. "dmd" or "ldc" will select the latest known version of the respective
25+
compiler. If a specific version is desired, it can be specified as "dmd-2.100.0" or
26+
"ldc-1.30.0".
27+
""", mandatory = True),
2328
})
2429

2530
def _toolchain_extension(module_ctx):

d/repositories.bzl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def rules_d_dependencies():
4141
########
4242
_DOC = "Fetch external tools needed for d toolchain"
4343
_ATTRS = {
44-
"d_version": attr.string(mandatory = True, values = SDK_VERSIONS.keys()),
44+
"d_version": attr.string(mandatory = True, values = ["auto", "dmd", "ldc"] + SDK_VERSIONS.keys()),
4545
"platform": attr.string(mandatory = True, values = PLATFORMS.keys()),
4646
}
4747

@@ -60,10 +60,25 @@ def _archive_prefix(url):
6060
def _d_repo_impl(repository_ctx):
6161
d_version = repository_ctx.attr.d_version
6262
platform = repository_ctx.attr.platform
63+
64+
if d_version == "auto":
65+
for compiler in ["dmd", "ldc"]:
66+
for version, platforms in SDK_VERSIONS.items():
67+
if version.startswith(compiler) and platform in platforms:
68+
d_version = compiler
69+
break
70+
if d_version != "auto":
71+
break
72+
73+
if d_version in ["dmd", "ldc"]:
74+
sdks = [version for version, platforms in SDK_VERSIONS.items() if version.startswith(d_version) and platform in platforms]
75+
sdks = sorted(sdks, key = lambda x: [int(v) if v.isdigit() else v for v in x[4:].split(".")], reverse = True)
76+
d_version = sdks[0] if sdks else d_version
77+
6378
if d_version not in SDK_VERSIONS:
64-
repository_ctx.fail("Unknown d_version: %s" % d_version)
79+
fail("Unknown d_version: %s" % d_version)
6580
if platform not in SDK_VERSIONS[d_version]:
66-
repository_ctx.fail("Unsupported platform: %s for %s" % (platform, d_version))
81+
fail("Unsupported platform: %s for %s" % (platform, d_version))
6782
sdk = SDK_VERSIONS[d_version][platform]
6883
repository_ctx.download_and_extract(
6984
url = sdk["url"],

e2e/smoke/WORKSPACE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ rules_d_dependencies()
4646

4747
d_register_toolchains(
4848
"d_toolchain",
49-
d_version = "dmd-2.110.0",
49+
d_version = "auto",
5050
)

0 commit comments

Comments
 (0)