chore: centralize bun version and release URL constants

This commit is contained in:
Eric
2026-03-04 02:56:27 +00:00
parent 020785bd59
commit 453d7dd3cf
3 changed files with 13 additions and 10 deletions

View File

@@ -1,35 +1,36 @@
load(":toolchain.bzl", "bun_toolchain")
load(":version.bzl", "BUN_VERSION")
toolchain_type(name = "toolchain_type")
bun_toolchain(
name = "linux_x64_toolchain_impl",
bun = "@bun_linux_x64//:bun",
version = "1.1.38",
version = BUN_VERSION,
)
bun_toolchain(
name = "linux_aarch64_toolchain_impl",
bun = "@bun_linux_aarch64//:bun",
version = "1.1.38",
version = BUN_VERSION,
)
bun_toolchain(
name = "darwin_x64_toolchain_impl",
bun = "@bun_darwin_x64//:bun",
version = "1.1.38",
version = BUN_VERSION,
)
bun_toolchain(
name = "darwin_aarch64_toolchain_impl",
bun = "@bun_darwin_aarch64//:bun",
version = "1.1.38",
version = BUN_VERSION,
)
bun_toolchain(
name = "windows_x64_toolchain_impl",
bun = "@bun_windows_x64//:bun",
version = "1.1.38",
version = BUN_VERSION,
)
toolchain(

View File

@@ -1,6 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
_BUN_VERSION = "1.1.38"
load(":version.bzl", "BUN_VERSION")
_BUN_ARCHIVES = {
"bun_linux_x64": {
@@ -30,6 +29,8 @@ _BUN_ARCHIVES = {
},
}
_BUN_GITHUB_RELEASE_URL_TEMPLATE = "https://github.com/oven-sh/bun/releases/download/bun-v{}/{}"
def _declare_bun_repo(name, asset, sha256, binary, version):
if native.existing_rule(name):
@@ -37,7 +38,7 @@ def _declare_bun_repo(name, asset, sha256, binary, version):
http_archive(
name = name,
urls = ["https://github.com/oven-sh/bun/releases/download/bun-v{}/{}".format(version, asset)],
urls = [_BUN_GITHUB_RELEASE_URL_TEMPLATE.format(version, asset)],
sha256 = sha256,
build_file_content = """
exports_files(["{binary}"])
@@ -51,7 +52,7 @@ filegroup(
)
def bun_repositories(version = _BUN_VERSION):
def bun_repositories(version = BUN_VERSION):
for name, metadata in _BUN_ARCHIVES.items():
_declare_bun_repo(
name = name,
@@ -62,7 +63,7 @@ def bun_repositories(version = _BUN_VERSION):
)
def bun_register_toolchains(version = _BUN_VERSION):
def bun_register_toolchains(version = BUN_VERSION):
bun_repositories(version = version)
native.register_toolchains(
"//bun:darwin_aarch64_toolchain",

1
bun/version.bzl Normal file
View File

@@ -0,0 +1 @@
BUN_VERSION = "1.1.38"