mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add step in CI to upload link metadata (#25448)
### What does this PR do? ### How did you verify your code works? --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1200,6 +1200,28 @@ set_target_properties(${bun} PROPERTIES LINK_DEPENDS ${BUN_SYMBOLS_PATH})
|
|||||||
|
|
||||||
include(SetupWebKit)
|
include(SetupWebKit)
|
||||||
|
|
||||||
|
if(BUN_LINK_ONLY)
|
||||||
|
register_command(
|
||||||
|
TARGET
|
||||||
|
${bun}
|
||||||
|
TARGET_PHASE
|
||||||
|
POST_BUILD
|
||||||
|
COMMENT
|
||||||
|
"Uploading link metadata"
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND} -E env
|
||||||
|
WEBKIT_DOWNLOAD_URL=${WEBKIT_DOWNLOAD_URL}
|
||||||
|
WEBKIT_VERSION=${WEBKIT_VERSION}
|
||||||
|
ZIG_COMMIT=${ZIG_COMMIT}
|
||||||
|
${BUN_EXECUTABLE} ${CWD}/scripts/create-link-metadata.mjs ${BUILD_PATH} ${bun}
|
||||||
|
SOURCES
|
||||||
|
${BUN_ZIG_OUTPUT}
|
||||||
|
${BUN_CPP_OUTPUT}
|
||||||
|
ARTIFACTS
|
||||||
|
${BUILD_PATH}/link-metadata.json
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
target_link_libraries(${bun} PRIVATE
|
target_link_libraries(${bun} PRIVATE
|
||||||
|
|||||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly-2025-12-10"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Version: 21
|
# Version: 24
|
||||||
|
|
||||||
# A script that installs the dependencies needed to build and test Bun.
|
# A script that installs the dependencies needed to build and test Bun.
|
||||||
# This should work on macOS and Linux with a POSIX shell.
|
# This should work on macOS and Linux with a POSIX shell.
|
||||||
@@ -1155,23 +1155,22 @@ llvm_version() {
|
|||||||
install_llvm() {
|
install_llvm() {
|
||||||
case "$pm" in
|
case "$pm" in
|
||||||
apt)
|
apt)
|
||||||
bash="$(require bash)"
|
# Debian 13 (Trixie) has LLVM 19 natively, and apt.llvm.org doesn't have a trixie repo
|
||||||
llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")"
|
|
||||||
|
|
||||||
# Debian trixie and newer don't have their own LLVM apt repo, use unstable
|
|
||||||
llvm_codename_arg=""
|
|
||||||
if [ "$distro" = "debian" ]; then
|
if [ "$distro" = "debian" ]; then
|
||||||
case "$VERSION_CODENAME" in
|
install_packages \
|
||||||
trixie|forky)
|
"llvm-$(llvm_version)" \
|
||||||
llvm_codename_arg="-n=unstable"
|
"clang-$(llvm_version)" \
|
||||||
;;
|
"lld-$(llvm_version)" \
|
||||||
esac
|
"llvm-$(llvm_version)-dev" \
|
||||||
|
"llvm-$(llvm_version)-tools"
|
||||||
|
else
|
||||||
|
bash="$(require bash)"
|
||||||
|
llvm_script="$(download_file "https://apt.llvm.org/llvm.sh")"
|
||||||
|
execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all
|
||||||
|
|
||||||
|
# Install llvm-symbolizer explicitly to ensure it's available for ASAN
|
||||||
|
install_packages "llvm-$(llvm_version)-tools"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute_sudo "$bash" "$llvm_script" "$(llvm_version)" all $llvm_codename_arg
|
|
||||||
|
|
||||||
# Install llvm-symbolizer explicitly to ensure it's available for ASAN
|
|
||||||
install_packages "llvm-$(llvm_version)-tools"
|
|
||||||
;;
|
;;
|
||||||
brew)
|
brew)
|
||||||
install_packages "llvm@$(llvm_version)"
|
install_packages "llvm@$(llvm_version)"
|
||||||
@@ -1308,11 +1307,6 @@ install_sccache() {
|
|||||||
|
|
||||||
install_rust() {
|
install_rust() {
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
alpine)
|
|
||||||
install_packages \
|
|
||||||
rust \
|
|
||||||
cargo
|
|
||||||
;;
|
|
||||||
freebsd)
|
freebsd)
|
||||||
install_packages lang/rust
|
install_packages lang/rust
|
||||||
create_directory "$HOME/.cargo/bin"
|
create_directory "$HOME/.cargo/bin"
|
||||||
@@ -1328,6 +1322,9 @@ install_rust() {
|
|||||||
rustup_script=$(download_file "https://sh.rustup.rs")
|
rustup_script=$(download_file "https://sh.rustup.rs")
|
||||||
execute "$sh" -lc "$rustup_script -y --no-modify-path"
|
execute "$sh" -lc "$rustup_script -y --no-modify-path"
|
||||||
append_to_path "$rust_home/bin"
|
append_to_path "$rust_home/bin"
|
||||||
|
|
||||||
|
# Ensure all rustup files are accessible (for CI builds where different users run builds)
|
||||||
|
grant_to_user "$rust_home"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
49
scripts/create-link-metadata.mjs
Normal file
49
scripts/create-link-metadata.mjs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bun
|
||||||
|
/**
|
||||||
|
* Creates link-metadata.json with link command and build metadata
|
||||||
|
*
|
||||||
|
* Usage: bun scripts/create-link-metadata.mjs <build-path> <bun-target>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { $ } from "bun";
|
||||||
|
import { dirname, join } from "path";
|
||||||
|
|
||||||
|
const [buildPath, bunTarget] = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (!buildPath || !bunTarget) {
|
||||||
|
console.error("Usage: bun scripts/create-link-metadata.mjs <build-path> <bun-target>");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the repo root (parent of scripts directory)
|
||||||
|
const repoRoot = dirname(import.meta.dir);
|
||||||
|
|
||||||
|
// Extract link command using ninja
|
||||||
|
console.log("Extracting link command...");
|
||||||
|
const linkCommandResult = await $`ninja -C ${buildPath} -t commands ${bunTarget}`.quiet();
|
||||||
|
const linkCommand = linkCommandResult.stdout.toString().trim();
|
||||||
|
|
||||||
|
// Read linker-related files from src/
|
||||||
|
console.log("Reading linker files...");
|
||||||
|
const linkerLds = await Bun.file(join(repoRoot, "src", "linker.lds")).text();
|
||||||
|
const symbolsDyn = await Bun.file(join(repoRoot, "src", "symbols.dyn")).text();
|
||||||
|
const symbolsTxt = await Bun.file(join(repoRoot, "src", "symbols.txt")).text();
|
||||||
|
|
||||||
|
// Create metadata JSON with link command included
|
||||||
|
const metadata = {
|
||||||
|
webkit_url: process.env.WEBKIT_DOWNLOAD_URL || "",
|
||||||
|
webkit_version: process.env.WEBKIT_VERSION || "",
|
||||||
|
zig_commit: process.env.ZIG_COMMIT || "",
|
||||||
|
target: bunTarget,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
link_command: linkCommand,
|
||||||
|
linker_lds: linkerLds,
|
||||||
|
symbols_dyn: symbolsDyn,
|
||||||
|
symbols_txt: symbolsTxt,
|
||||||
|
};
|
||||||
|
|
||||||
|
const metadataPath = join(buildPath, "link-metadata.json");
|
||||||
|
await Bun.write(metadataPath, JSON.stringify(metadata, null, 2));
|
||||||
|
console.log(`Written to ${metadataPath}`);
|
||||||
|
|
||||||
|
console.log("Done");
|
||||||
Reference in New Issue
Block a user