Generate dependency versions header from CMake

Merged
RO
1y ago
+268-212

Summary

This PR introduces a CMake-generated header file containing all dependency versions, eliminating the need for C++ code to depend on Zig-exported version constants.

Changes

  • New CMake script: cmake/tools/GenerateDependencyVersions.cmake that:

    • Reads versions from the existing generated_versions_list.zig file
    • Extracts semantic versions from header files where available (libdeflate, zlib)
    • Generates bun_dependency_versions.h with all dependency versions as compile-time constants
  • Updated BunProcess.cpp:

    • Now includes the CMake-generated bun_dependency_versions.h
    • Uses BUN_VERSION_* constants instead of Bun__versions_*
    • Removes dependency on Zig-exported version constants
  • Build system updates:

    • Added GenerateDependencyVersions to main CMakeLists.txt
    • Added build directory to include paths in BuildBun.cmake

Benefits

✅ Single source of truth for dependency versions
✅ Versions accessible from C++ without Zig exports
✅ Automatic regeneration during CMake configuration
✅ Semantic versions shown where available (e.g., zlib 1.2.8 instead of commit hash)
✅ Debug output file for verification

Test Results

Verified that process.versions correctly shows all dependency versions:

$ bun -e "console.log(JSON.stringify(process.versions, null, 2))"
{
  "node": "24.3.0",
  "bun": "1.2.22-debug",
  "boringssl": "29a2cd359458c9384694b75456026e4b57e3e567",
  "libarchive": "898dc8319355b7e985f68a9819f182aaed61b53a",
  "mimalloc": "4c283af60cdae205df5a872530c77e2a6a307d43",
  "webkit": "0ddf6f47af0a9782a354f61e06d7f83d097d9f84",
  "zlib": "1.2.8",
  "libdeflate": "1.24",
  // ... all versions present and correct
}

Generated Files

  • build/debug/bun_dependency_versions.h - Header file with version constants
  • build/debug/bun_dependency_versions_debug.txt - Human-readable version list

🤖 Generated with Claude Code