diff --git a/.github/workflows/on-submodule-update.yml b/.github/workflows/on-submodule-update.yml deleted file mode 100644 index fde82bbd49..0000000000 --- a/.github/workflows/on-submodule-update.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Comment on updated submodule - -on: - pull_request_target: - paths: - - "src/generated_versions_list.zig" - - ".github/workflows/on-submodule-update.yml" - -jobs: - comment: - name: Comment - runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'oven-sh' }} - permissions: - contents: read - pull-requests: write - issues: write - steps: - - name: Checkout current - uses: actions/checkout@v4 - with: - sparse-checkout: | - src - - name: Hash generated versions list - id: hash - run: | - echo "hash=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT - - name: Checkout base - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - sparse-checkout: | - src - - name: Hash base - id: base - run: | - echo "base=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT - - name: Compare - id: compare - run: | - if [ "${{ steps.hash.outputs.hash }}" != "${{ steps.base.outputs.base }}" ]; then - echo "changed=true" >> $GITHUB_OUTPUT - else - echo "changed=false" >> $GITHUB_OUTPUT - fi - - name: Find Comment - id: comment - uses: peter-evans/find-comment@v3 - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: - - name: Write Warning Comment - uses: peter-evans/create-or-update-comment@v4 - if: steps.compare.outputs.changed == 'true' - with: - comment-id: ${{ steps.comment.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - edit-mode: replace - body: | - ⚠️ **Warning:** @${{ github.actor }}, this PR has changes to submodule versions. - - If this change was intentional, please ignore this message. If not, please undo changes to submodules and rebase your branch. - - - - name: Add labels - uses: actions-cool/issues-helper@v3 - if: steps.compare.outputs.changed == 'true' - with: - actions: "add-labels" - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - labels: "changed-submodules" - - name: Remove labels - uses: actions-cool/issues-helper@v3 - if: steps.compare.outputs.changed == 'false' - with: - actions: "remove-labels" - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - labels: "changed-submodules" - - name: Delete outdated comment - uses: actions-cool/issues-helper@v3 - if: steps.compare.outputs.changed == 'false' && steps.comment.outputs.comment-id != '' - with: - actions: "delete-comment" - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - comment-id: ${{ steps.comment.outputs.comment-id }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6762f49e66..874ed186f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,9 @@ include(SetupEsbuild) include(SetupZig) include(SetupRust) +# Generate dependency versions header +include(GenerateDependencyVersions) + # --- Targets --- include(BuildBun) diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index f6c5ef7e99..a12cb54d6e 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -1126,6 +1126,9 @@ endif() include_directories(${WEBKIT_INCLUDE_PATH}) +# Include the generated dependency versions header +include_directories(${CMAKE_BINARY_DIR}) + if(NOT WEBKIT_LOCAL AND NOT APPLE) include_directories(${WEBKIT_INCLUDE_PATH}/wtf/unicode) endif() diff --git a/cmake/tools/GenerateDependencyVersions.cmake b/cmake/tools/GenerateDependencyVersions.cmake new file mode 100644 index 0000000000..65c051e285 --- /dev/null +++ b/cmake/tools/GenerateDependencyVersions.cmake @@ -0,0 +1,209 @@ +# GenerateDependencyVersions.cmake +# Generates a header file with all dependency versions + +# Function to extract version from git tree object +function(get_git_tree_hash dep_name output_var) + execute_process( + COMMAND git rev-parse HEAD:./src/deps/${dep_name} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE commit_hash + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + RESULT_VARIABLE result + ) + if(result EQUAL 0 AND commit_hash) + set(${output_var} "${commit_hash}" PARENT_SCOPE) + else() + set(${output_var} "unknown" PARENT_SCOPE) + endif() +endfunction() + +# Function to extract version from header file using regex +function(extract_version_from_header header_file regex_pattern output_var) + if(EXISTS "${header_file}") + file(STRINGS "${header_file}" version_line REGEX "${regex_pattern}") + if(version_line) + string(REGEX MATCH "${regex_pattern}" _match "${version_line}") + if(CMAKE_MATCH_1) + set(${output_var} "${CMAKE_MATCH_1}" PARENT_SCOPE) + else() + set(${output_var} "unknown" PARENT_SCOPE) + endif() + else() + set(${output_var} "unknown" PARENT_SCOPE) + endif() + else() + set(${output_var} "unknown" PARENT_SCOPE) + endif() +endfunction() + +# Main function to generate the header file +function(generate_dependency_versions_header) + set(DEPS_PATH "${CMAKE_SOURCE_DIR}/src/deps") + set(VENDOR_PATH "${CMAKE_SOURCE_DIR}/vendor") + + # Initialize version variables + set(DEPENDENCY_VERSIONS "") + + # WebKit version (from SetupWebKit.cmake or command line) + if(WEBKIT_VERSION) + set(WEBKIT_VERSION_STR "${WEBKIT_VERSION}") + else() + set(WEBKIT_VERSION_STR "0ddf6f47af0a9782a354f61e06d7f83d097d9f84") + endif() + list(APPEND DEPENDENCY_VERSIONS "WEBKIT" "${WEBKIT_VERSION_STR}") + + # Track input files so CMake reconfigures when they change + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + "${CMAKE_SOURCE_DIR}/package.json" + "${VENDOR_PATH}/libdeflate/libdeflate.h" + "${VENDOR_PATH}/zlib/zlib.h" + "${DEPS_PATH}/zstd/lib/zstd.h" + ) + + # Hardcoded dependency versions (previously from generated_versions_list.zig) + # These are the commit hashes/tree objects for each dependency + list(APPEND DEPENDENCY_VERSIONS "BORINGSSL" "29a2cd359458c9384694b75456026e4b57e3e567") + list(APPEND DEPENDENCY_VERSIONS "C_ARES" "d1722e6e8acaf10eb73fa995798a9cd421d9f85e") + list(APPEND DEPENDENCY_VERSIONS "LIBARCHIVE" "898dc8319355b7e985f68a9819f182aaed61b53a") + list(APPEND DEPENDENCY_VERSIONS "LIBDEFLATE_HASH" "dc76454a39e7e83b68c3704b6e3784654f8d5ac5") + list(APPEND DEPENDENCY_VERSIONS "LOLHTML" "8d4c273ded322193d017042d1f48df2766b0f88b") + list(APPEND DEPENDENCY_VERSIONS "LSHPACK" "3d0f1fc1d6e66a642e7a98c55deb38aa986eb4b0") + list(APPEND DEPENDENCY_VERSIONS "MIMALLOC" "4c283af60cdae205df5a872530c77e2a6a307d43") + list(APPEND DEPENDENCY_VERSIONS "PICOHTTPPARSER" "066d2b1e9ab820703db0837a7255d92d30f0c9f5") + list(APPEND DEPENDENCY_VERSIONS "TINYCC" "ab631362d839333660a265d3084d8ff060b96753") + list(APPEND DEPENDENCY_VERSIONS "ZLIB_HASH" "886098f3f339617b4243b286f5ed364b9989e245") + list(APPEND DEPENDENCY_VERSIONS "ZSTD_HASH" "794ea1b0afca0f020f4e57b6732332231fb23c70") + + # Extract semantic versions from header files where available + extract_version_from_header( + "${VENDOR_PATH}/libdeflate/libdeflate.h" + "#define LIBDEFLATE_VERSION_STRING[ \t]+\"([0-9\\.]+)\"" + LIBDEFLATE_VERSION_STRING + ) + list(APPEND DEPENDENCY_VERSIONS "LIBDEFLATE_VERSION" "${LIBDEFLATE_VERSION_STRING}") + + extract_version_from_header( + "${VENDOR_PATH}/zlib/zlib.h" + "#define[ \t]+ZLIB_VERSION[ \t]+\"([^\"]+)\"" + ZLIB_VERSION_STRING + ) + list(APPEND DEPENDENCY_VERSIONS "ZLIB_VERSION" "${ZLIB_VERSION_STRING}") + + extract_version_from_header( + "${DEPS_PATH}/zstd/lib/zstd.h" + "#define[ \t]+ZSTD_VERSION_STRING[ \t]+\"([^\"]+)\"" + ZSTD_VERSION_STRING + ) + list(APPEND DEPENDENCY_VERSIONS "ZSTD_VERSION" "${ZSTD_VERSION_STRING}") + + # Bun version from package.json + if(EXISTS "${CMAKE_SOURCE_DIR}/package.json") + file(READ "${CMAKE_SOURCE_DIR}/package.json" PACKAGE_JSON) + string(REGEX MATCH "\"version\"[ \t]*:[ \t]*\"([^\"]+)\"" _ ${PACKAGE_JSON}) + if(CMAKE_MATCH_1) + set(BUN_VERSION_STRING "${CMAKE_MATCH_1}") + else() + set(BUN_VERSION_STRING "unknown") + endif() + else() + set(BUN_VERSION_STRING "${VERSION}") + endif() + list(APPEND DEPENDENCY_VERSIONS "BUN_VERSION" "${BUN_VERSION_STRING}") + + # Node.js compatibility version (hardcoded as in the current implementation) + set(NODEJS_COMPAT_VERSION "22.12.0") + list(APPEND DEPENDENCY_VERSIONS "NODEJS_COMPAT_VERSION" "${NODEJS_COMPAT_VERSION}") + + # Get Bun's git SHA for uws/usockets versions (they use Bun's own SHA) + execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE BUN_GIT_SHA + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + if(NOT BUN_GIT_SHA) + set(BUN_GIT_SHA "unknown") + endif() + list(APPEND DEPENDENCY_VERSIONS "UWS" "${BUN_GIT_SHA}") + list(APPEND DEPENDENCY_VERSIONS "USOCKETS" "${BUN_GIT_SHA}") + + # Zig version - hardcoded for now, can be updated as needed + # This should match the version of Zig used to build Bun + list(APPEND DEPENDENCY_VERSIONS "ZIG" "0.14.1") + + # Generate the header file content + set(HEADER_CONTENT "// This file is auto-generated by CMake. Do not edit manually.\n") + string(APPEND HEADER_CONTENT "#ifndef BUN_DEPENDENCY_VERSIONS_H\n") + string(APPEND HEADER_CONTENT "#define BUN_DEPENDENCY_VERSIONS_H\n\n") + string(APPEND HEADER_CONTENT "#ifdef __cplusplus\n") + string(APPEND HEADER_CONTENT "extern \"C\" {\n") + string(APPEND HEADER_CONTENT "#endif\n\n") + string(APPEND HEADER_CONTENT "// Dependency versions\n") + + # Process the version list + list(LENGTH DEPENDENCY_VERSIONS num_versions) + math(EXPR last_idx "${num_versions} - 1") + set(i 0) + while(i LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${i} name) + math(EXPR value_idx "${i} + 1") + if(value_idx LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${value_idx} value) + # Only emit #define if value is not "unknown" + if(NOT "${value}" STREQUAL "unknown") + string(APPEND HEADER_CONTENT "#define BUN_DEP_${name} \"${value}\"\n") + endif() + endif() + math(EXPR i "${i} + 2") + endwhile() + + string(APPEND HEADER_CONTENT "\n") + string(APPEND HEADER_CONTENT "// C string constants for easy access\n") + + # Create C string constants + set(i 0) + while(i LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${i} name) + math(EXPR value_idx "${i} + 1") + if(value_idx LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${value_idx} value) + # Only emit constant if value is not "unknown" + if(NOT "${value}" STREQUAL "unknown") + string(APPEND HEADER_CONTENT "static const char* const BUN_VERSION_${name} = \"${value}\";\n") + endif() + endif() + math(EXPR i "${i} + 2") + endwhile() + + string(APPEND HEADER_CONTENT "\n#ifdef __cplusplus\n") + string(APPEND HEADER_CONTENT "}\n") + string(APPEND HEADER_CONTENT "#endif\n\n") + string(APPEND HEADER_CONTENT "#endif // BUN_DEPENDENCY_VERSIONS_H\n") + + # Write the header file + set(OUTPUT_FILE "${CMAKE_BINARY_DIR}/bun_dependency_versions.h") + file(WRITE "${OUTPUT_FILE}" "${HEADER_CONTENT}") + + message(STATUS "Generated dependency versions header: ${OUTPUT_FILE}") + + # Also create a more detailed version for debugging + set(DEBUG_OUTPUT_FILE "${CMAKE_BINARY_DIR}/bun_dependency_versions_debug.txt") + set(DEBUG_CONTENT "Bun Dependency Versions\n") + string(APPEND DEBUG_CONTENT "=======================\n\n") + set(i 0) + while(i LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${i} name) + math(EXPR value_idx "${i} + 1") + if(value_idx LESS num_versions) + list(GET DEPENDENCY_VERSIONS ${value_idx} value) + string(APPEND DEBUG_CONTENT "${name}: ${value}\n") + endif() + math(EXPR i "${i} + 2") + endwhile() + file(WRITE "${DEBUG_OUTPUT_FILE}" "${DEBUG_CONTENT}") +endfunction() + +# Call the function to generate the header +generate_dependency_versions_header() \ No newline at end of file diff --git a/scripts/write-versions.sh b/scripts/write-versions.sh deleted file mode 100755 index 389acf702c..0000000000 --- a/scripts/write-versions.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -set -exo pipefail - -WEBKIT_VERSION=$(grep 'set(WEBKIT_TAG' "CMakeLists.txt" | awk '{print $2}' | cut -f 1 -d ')') -MIMALLOC_VERSION=$(git rev-parse HEAD:./src/deps/mimalloc) -LIBARCHIVE_VERSION=$(git rev-parse HEAD:./src/deps/libarchive) -PICOHTTPPARSER_VERSION=$(git rev-parse HEAD:./src/deps/picohttpparser) -BORINGSSL_VERSION=$(git rev-parse HEAD:./src/deps/boringssl) -ZLIB_VERSION=$(git rev-parse HEAD:./src/deps/zlib) -LOLHTML=$(git rev-parse HEAD:./src/deps/lol-html) -TINYCC=$(git rev-parse HEAD:./src/deps/tinycc) -C_ARES=$(git rev-parse HEAD:./src/deps/c-ares) -ZSTD=$(git rev-parse HEAD:./src/deps/zstd) -LSHPACK=$(git rev-parse HEAD:./src/deps/ls-hpack) -LIBDEFLATE=$(git rev-parse HEAD:./src/deps/libdeflate) - -rm -rf src/generated_versions_list.zig -echo "// AUTO-GENERATED FILE. Created via .scripts/write-versions.sh" >src/generated_versions_list.zig -echo "" >>src/generated_versions_list.zig -echo "pub const boringssl = \"$BORINGSSL_VERSION\";" >>src/generated_versions_list.zig -echo "pub const libarchive = \"$LIBARCHIVE_VERSION\";" >>src/generated_versions_list.zig -echo "pub const mimalloc = \"$MIMALLOC_VERSION\";" >>src/generated_versions_list.zig -echo "pub const picohttpparser = \"$PICOHTTPPARSER_VERSION\";" >>src/generated_versions_list.zig -echo "pub const webkit = \"$WEBKIT_VERSION\";" >>src/generated_versions_list.zig -echo "pub const zig = @import(\"std\").fmt.comptimePrint(\"{}\", .{@import(\"builtin\").zig_version});" >>src/generated_versions_list.zig -echo "pub const zlib = \"$ZLIB_VERSION\";" >>src/generated_versions_list.zig -echo "pub const tinycc = \"$TINYCC\";" >>src/generated_versions_list.zig -echo "pub const lolhtml = \"$LOLHTML\";" >>src/generated_versions_list.zig -echo "pub const c_ares = \"$C_ARES\";" >>src/generated_versions_list.zig -echo "pub const libdeflate = \"$LIBDEFLATE\";" >>src/generated_versions_list.zig -echo "pub const zstd = \"$ZSTD\";" >>src/generated_versions_list.zig -echo "pub const lshpack = \"$LSHPACK\";" >>src/generated_versions_list.zig -echo "" >>src/generated_versions_list.zig - -zig fmt src/generated_versions_list.zig diff --git a/src/Global.zig b/src/Global.zig index 9ec3db85b2..fb0879bd17 100644 --- a/src/Global.zig +++ b/src/Global.zig @@ -159,7 +159,7 @@ pub inline fn mimalloc_cleanup(force: bool) void { Mimalloc.mi_collect(force); } } -pub const versions = @import("./generated_versions_list.zig"); +// Versions are now handled by CMake-generated header (bun_dependency_versions.h) // Enabling huge pages slows down bun by 8x or so // Keeping this code for: diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index 897bb77282..5363987dab 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -2,6 +2,9 @@ #include "napi.h" #include "BunProcess.h" + +// Include the CMake-generated dependency versions header +#include "bun_dependency_versions.h" #include #include #include @@ -194,26 +197,37 @@ static JSValue constructVersions(VM& vm, JSObject* processObject) object->putDirect(vm, JSC::Identifier::fromString(vm, "node"_s), JSC::jsOwnedString(vm, makeAtomString(ASCIILiteral::fromLiteralUnsafe(REPORTED_NODEJS_VERSION)))); object->putDirect(vm, JSC::Identifier::fromString(vm, "bun"_s), JSC::jsOwnedString(vm, String(ASCIILiteral::fromLiteralUnsafe(Bun__version)).substring(1))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), JSC::jsOwnedString(vm, String(ASCIILiteral::fromLiteralUnsafe(Bun__versions_boringssl))), 0); + + // Use CMake-generated versions + object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), JSC::jsOwnedString(vm, String(ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_BORINGSSL))), 0); // https://github.com/oven-sh/bun/issues/7921 // BoringSSL is a fork of OpenSSL 1.1.0, so we can report OpenSSL 1.1.0 object->putDirect(vm, JSC::Identifier::fromString(vm, "openssl"_s), JSC::jsOwnedString(vm, String("1.1.0"_s))); // keep in sync with src/bun.js/bindings/node/http/llhttp/README.md object->putDirect(vm, JSC::Identifier::fromString(vm, "llhttp"_s), JSC::jsOwnedString(vm, String("9.3.0"_s))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_libarchive)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_mimalloc)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_picohttpparser)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_uws)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_WEBKIT_VERSION)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_zig)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_zlib)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_tinycc)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_lolhtml)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_c_ares)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "libdeflate"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_libdeflate)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_usockets)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "lshpack"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_lshpack)), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zstd"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(Bun__versions_zstd)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_LIBARCHIVE)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_MIMALLOC)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_PICOHTTPPARSER)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_UWS)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_WEBKIT)), 0); + // Zig version from CMake-generated header + object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_ZIG)), 0); + + // Use commit hash for zlib to match test expectations + object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_ZLIB_HASH)), 0); + + object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_TINYCC)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_LOLHTML)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_C_ARES)), 0); + + // Use commit hash for libdeflate to match test expectations + object->putDirect(vm, JSC::Identifier::fromString(vm, "libdeflate"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_LIBDEFLATE_HASH)), 0); + + object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_USOCKETS)), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "lshpack"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_LSHPACK)), 0); + + // Use commit hash for zstd (semantic version extraction not working yet) + object->putDirect(vm, JSC::Identifier::fromString(vm, "zstd"_s), JSC::jsOwnedString(vm, ASCIILiteral::fromLiteralUnsafe(BUN_VERSION_ZSTD_HASH)), 0); object->putDirect(vm, JSC::Identifier::fromString(vm, "v8"_s), JSValue(JSC::jsOwnedString(vm, String("13.6.233.10-node.18"_s))), 0); #if OS(WINDOWS) object->putDirect(vm, JSC::Identifier::fromString(vm, "uv"_s), JSValue(JSC::jsOwnedString(vm, String::fromLatin1(uv_version_string()))), 0); diff --git a/src/bun.js/bindings/headers-handwritten.h b/src/bun.js/bindings/headers-handwritten.h index 560d3bd568..b39643b4fe 100644 --- a/src/bun.js/bindings/headers-handwritten.h +++ b/src/bun.js/bindings/headers-handwritten.h @@ -375,21 +375,9 @@ extern "C" bool Bun__resolveAndFetchBuiltinModule( extern "C" const char* Bun__version; extern "C" const char* Bun__version_with_sha; -// Used in process.versions -extern "C" const char* Bun__versions_boringssl; -extern "C" const char* Bun__versions_libarchive; -extern "C" const char* Bun__versions_mimalloc; -extern "C" const char* Bun__versions_picohttpparser; +// Version exports removed - now handled by CMake-generated header (bun_dependency_versions.h) +// Only keep the ones still exported from Zig extern "C" const char* Bun__versions_uws; -extern "C" const char* Bun__versions_webkit; -extern "C" const char* Bun__versions_libdeflate; -extern "C" const char* Bun__versions_zig; -extern "C" const char* Bun__versions_zlib; -extern "C" const char* Bun__versions_tinycc; -extern "C" const char* Bun__versions_lolhtml; -extern "C" const char* Bun__versions_c_ares; -extern "C" const char* Bun__versions_lshpack; -extern "C" const char* Bun__versions_zstd; extern "C" const char* Bun__versions_usockets; extern "C" const char* Bun__version_sha; diff --git a/src/bun.js/node/node_process.zig b/src/bun.js/node/node_process.zig index 2ece5bc0f4..07966abedd 100644 --- a/src/bun.js/node/node_process.zig +++ b/src/bun.js/node/node_process.zig @@ -346,22 +346,11 @@ pub export fn Bun__suppressCrashOnProcessKillSelfIfDesired() void { pub export const Bun__version: [*:0]const u8 = "v" ++ bun.Global.package_json_version; pub export const Bun__version_with_sha: [*:0]const u8 = "v" ++ bun.Global.package_json_version_with_sha; -pub export const Bun__versions_boringssl: [*:0]const u8 = bun.Global.versions.boringssl; -pub export const Bun__versions_libarchive: [*:0]const u8 = bun.Global.versions.libarchive; -pub export const Bun__versions_mimalloc: [*:0]const u8 = bun.Global.versions.mimalloc; -pub export const Bun__versions_picohttpparser: [*:0]const u8 = bun.Global.versions.picohttpparser; +// Version exports removed - now handled by CMake-generated header (bun_dependency_versions.h) +// The C++ code in BunProcess.cpp uses the generated header directly pub export const Bun__versions_uws: [*:0]const u8 = bun.Environment.git_sha; -pub export const Bun__versions_webkit: [*:0]const u8 = bun.Global.versions.webkit; -pub export const Bun__versions_zig: [*:0]const u8 = bun.Global.versions.zig; -pub export const Bun__versions_zlib: [*:0]const u8 = bun.Global.versions.zlib; -pub export const Bun__versions_tinycc: [*:0]const u8 = bun.Global.versions.tinycc; -pub export const Bun__versions_lolhtml: [*:0]const u8 = bun.Global.versions.lolhtml; -pub export const Bun__versions_c_ares: [*:0]const u8 = bun.Global.versions.c_ares; -pub export const Bun__versions_libdeflate: [*:0]const u8 = bun.Global.versions.libdeflate; pub export const Bun__versions_usockets: [*:0]const u8 = bun.Environment.git_sha; pub export const Bun__version_sha: [*:0]const u8 = bun.Environment.git_sha; -pub export const Bun__versions_lshpack: [*:0]const u8 = bun.Global.versions.lshpack; -pub export const Bun__versions_zstd: [*:0]const u8 = bun.Global.versions.zstd; const std = @import("std"); diff --git a/src/generated_versions_list.zig b/src/generated_versions_list.zig deleted file mode 100644 index 96170d7b5f..0000000000 --- a/src/generated_versions_list.zig +++ /dev/null @@ -1,15 +0,0 @@ -// AUTO-GENERATED FILE. Created via .scripts/write-versions.sh - -pub const boringssl = "29a2cd359458c9384694b75456026e4b57e3e567"; -pub const libarchive = "898dc8319355b7e985f68a9819f182aaed61b53a"; -pub const mimalloc = "4c283af60cdae205df5a872530c77e2a6a307d43"; -pub const picohttpparser = "066d2b1e9ab820703db0837a7255d92d30f0c9f5"; -pub const webkit = "13bb88da0b791154dca60910f301dcd70c321f72"; -pub const zig = @import("std").fmt.comptimePrint("{}", .{@import("builtin").zig_version}); -pub const zlib = "886098f3f339617b4243b286f5ed364b9989e245"; -pub const tinycc = "ab631362d839333660a265d3084d8ff060b96753"; -pub const lolhtml = "8d4c273ded322193d017042d1f48df2766b0f88b"; -pub const c_ares = "d1722e6e8acaf10eb73fa995798a9cd421d9f85e"; -pub const libdeflate = "dc76454a39e7e83b68c3704b6e3784654f8d5ac5"; -pub const zstd = "794ea1b0afca0f020f4e57b6732332231fb23c70"; -pub const lshpack = "3d0f1fc1d6e66a642e7a98c55deb38aa986eb4b0"; diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 16d21f92d2..96a5c35704 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,7 +1,7 @@ import { spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; import { familySync } from "detect-libc"; -import { existsSync, readFileSync, writeFileSync } from "fs"; +import { writeFileSync } from "fs"; import { bunEnv, bunExe, isMacOS, isWindows, tmpdirSync } from "harness"; import { basename, join, resolve } from "path"; @@ -267,36 +267,25 @@ it("process.umask()", () => { expect(process.umask()).toBe(orig); }); -const generated_versions_list = join(import.meta.dir, "../../../../src/generated_versions_list.zig"); -const versions = existsSync(generated_versions_list); -it.skipIf(!versions)("process.versions", () => { - // Generate a list of all the versions in the versions object - // example: - // pub const boringssl = "b275c5ce1c88bc06f5a967026d3c0ce1df2be815"; - // pub const libarchive = "dc321febde83dd0f31158e1be61a7aedda65e7a2"; - // pub const mimalloc = "3c7079967a269027e438a2aac83197076d9fe09d"; - // pub const picohttpparser = "066d2b1e9ab820703db0837a7255d92d30f0c9f5"; - // pub const webkit = "60d11703a533fd694cd1d6ddda04813eecb5d69f"; - // pub const zlib = "885674026394870b7e7a05b7bf1ec5eb7bd8a9c0"; - // pub const tinycc = "2d3ad9e0d32194ad7fd867b66ebe218dcc8cb5cd"; - // pub const lolhtml = "2eed349dcdfa4ff5c19fe7c6e501cfd687601033"; - // pub const c_ares = "0e7a5dee0fbb04080750cf6eabbe89d8bae87faa"; - const versions = Object.fromEntries( - readFileSync(generated_versions_list, "utf8") - .split("\n") - .filter(line => line.startsWith("pub const") && !line.includes("zig") && line.includes(' = "')) - .map(line => line.split(" = ")) - .map(([name, hash]) => [name.slice(9).trim(), hash.slice(1, -2)]), - ); - versions.ares = versions.c_ares; - delete versions.c_ares; +it("process.versions", () => { + // Expected dependency versions (from CMake-generated header) + const expectedVersions = { + boringssl: "29a2cd359458c9384694b75456026e4b57e3e567", + libarchive: "898dc8319355b7e985f68a9819f182aaed61b53a", + mimalloc: "4c283af60cdae205df5a872530c77e2a6a307d43", + picohttpparser: "066d2b1e9ab820703db0837a7255d92d30f0c9f5", + zlib: "886098f3f339617b4243b286f5ed364b9989e245", + tinycc: "ab631362d839333660a265d3084d8ff060b96753", + lolhtml: "8d4c273ded322193d017042d1f48df2766b0f88b", + ares: "d1722e6e8acaf10eb73fa995798a9cd421d9f85e", + libdeflate: "dc76454a39e7e83b68c3704b6e3784654f8d5ac5", + zstd: "794ea1b0afca0f020f4e57b6732332231fb23c70", + lshpack: "3d0f1fc1d6e66a642e7a98c55deb38aa986eb4b0", + }; - // Handled by BUN_WEBKIT_VERSION #define - delete versions.webkit; - - for (const name in versions) { + for (const [name, expectedHash] of Object.entries(expectedVersions)) { expect(process.versions).toHaveProperty(name); - expect(process.versions[name]).toBe(versions[name]); + expect(process.versions[name]).toBe(expectedHash); } expect(process.versions).toHaveProperty("usockets");