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(":toolchain.bzl", "bun_toolchain")
load(":version.bzl", "BUN_VERSION")
toolchain_type(name = "toolchain_type") toolchain_type(name = "toolchain_type")
bun_toolchain( bun_toolchain(
name = "linux_x64_toolchain_impl", name = "linux_x64_toolchain_impl",
bun = "@bun_linux_x64//:bun", bun = "@bun_linux_x64//:bun",
version = "1.1.38", version = BUN_VERSION,
) )
bun_toolchain( bun_toolchain(
name = "linux_aarch64_toolchain_impl", name = "linux_aarch64_toolchain_impl",
bun = "@bun_linux_aarch64//:bun", bun = "@bun_linux_aarch64//:bun",
version = "1.1.38", version = BUN_VERSION,
) )
bun_toolchain( bun_toolchain(
name = "darwin_x64_toolchain_impl", name = "darwin_x64_toolchain_impl",
bun = "@bun_darwin_x64//:bun", bun = "@bun_darwin_x64//:bun",
version = "1.1.38", version = BUN_VERSION,
) )
bun_toolchain( bun_toolchain(
name = "darwin_aarch64_toolchain_impl", name = "darwin_aarch64_toolchain_impl",
bun = "@bun_darwin_aarch64//:bun", bun = "@bun_darwin_aarch64//:bun",
version = "1.1.38", version = BUN_VERSION,
) )
bun_toolchain( bun_toolchain(
name = "windows_x64_toolchain_impl", name = "windows_x64_toolchain_impl",
bun = "@bun_windows_x64//:bun", bun = "@bun_windows_x64//:bun",
version = "1.1.38", version = BUN_VERSION,
) )
toolchain( toolchain(

View File

@@ -1,6 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(":version.bzl", "BUN_VERSION")
_BUN_VERSION = "1.1.38"
_BUN_ARCHIVES = { _BUN_ARCHIVES = {
"bun_linux_x64": { "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): def _declare_bun_repo(name, asset, sha256, binary, version):
if native.existing_rule(name): if native.existing_rule(name):
@@ -37,7 +38,7 @@ def _declare_bun_repo(name, asset, sha256, binary, version):
http_archive( http_archive(
name = name, 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, sha256 = sha256,
build_file_content = """ build_file_content = """
exports_files(["{binary}"]) 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(): for name, metadata in _BUN_ARCHIVES.items():
_declare_bun_repo( _declare_bun_repo(
name = name, 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) bun_repositories(version = version)
native.register_toolchains( native.register_toolchains(
"//bun:darwin_aarch64_toolchain", "//bun:darwin_aarch64_toolchain",

1
bun/version.bzl Normal file
View File

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