feat: new bun_build and bun_compile, extend bun_install

This commit is contained in:
eric
2026-03-15 00:11:55 +01:00
parent c446f23a35
commit a0bc998bd2
58 changed files with 1845 additions and 191 deletions

View File

@@ -71,3 +71,25 @@ sh_test(
args = ["$(location :env_parent_cwd_bin)"],
data = [":env_parent_cwd_bin"],
)
bun_binary(
name = "runtime_flag_bin",
entry_point = "flag_probe.ts",
args = ["one", "two"],
preload = ["preload.ts"],
env_files = ["runtime.env"],
)
sh_test(
name = "bun_binary_runtime_flags_test",
srcs = ["run_flag_binary.sh"],
args = ["$(location :runtime_flag_bin)"],
data = [":runtime_flag_bin"],
)
sh_test(
name = "bun_binary_runtime_flags_shape_test",
srcs = ["verify_runtime_flags_shape.sh"],
args = ["$(location :runtime_flag_bin)"],
data = [":runtime_flag_bin"],
)

View File

@@ -0,0 +1,7 @@
const state = globalThis as typeof globalThis & { __rules_bun_preloaded?: string };
console.log(JSON.stringify({
preloaded: state.__rules_bun_preloaded ?? null,
env: process.env.RUNTIME_FLAG_TEST ?? null,
argv: process.argv.slice(2),
}));

View File

@@ -0,0 +1 @@
(globalThis as typeof globalThis & { __rules_bun_preloaded?: string }).__rules_bun_preloaded = "yes";

View File

@@ -5,7 +5,7 @@ binary="$1"
expected="$2"
output="$(${binary})"
if [[ "${output}" != "${expected}" ]]; then
if [[ ${output} != "${expected}" ]]; then
echo "Unexpected output from ${binary}: ${output}" >&2
exit 1
fi

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
binary="$1"
output="$(${binary})"
expected='{"preloaded":"yes","env":"from-env-file","argv":["one","two"]}'
if [[ ${output} != "${expected}" ]]; then
echo "Unexpected output from ${binary}: ${output}" >&2
exit 1
fi

View File

@@ -0,0 +1 @@
RUNTIME_FLAG_TEST=from-env-file

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
binary="$1"
grep -Fq -- '--no-install' "${binary}"
grep -Fq -- '--preload' "${binary}"
grep -Fq -- '--env-file' "${binary}"