From 0676e83c703a7ec64469e27221149334f701575f Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 18 Jul 2025 16:16:56 +1000 Subject: [PATCH 1/4] DEV: Add a script for building on macos-x86_64 --- libexec/build-macos-x86_64 | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 libexec/build-macos-x86_64 diff --git a/libexec/build-macos-x86_64 b/libexec/build-macos-x86_64 new file mode 100755 index 0000000..6e55787 --- /dev/null +++ b/libexec/build-macos-x86_64 @@ -0,0 +1,59 @@ +#/bin/sh + +set -e +set -u + +BASEDIR="${PWD}" + +TARGET_PLATFORM=x86_64-darwin +RUBY_TARGET_PLATFORM=x86_64-darwin + +bundle install + +RUBY_PLATFORM=$(./libexec/metadata ruby_platform) +GEM_PLATFORM=$(./libexec/metadata gem_platform) +GEM_VERSION=$(./libexec/metadata gem_version) +NODE_VERSION=$(./libexec/metadata node_version) +LIBV8_VERSION=$(./libexec/metadata libv8_version) + +./libexec/download-node $NODE_VERSION +./libexec/extract-node $NODE_VERSION + +# Validate that we have the correct V8 version. +libv8_version_h=$(./libexec/metadata libv8_version_h) +if [ "$libv8_version_h" != "$LIBV8_VERSION" ]; then + echo "LIBV8 version mismatch: expected $LIBV8_VERSION but found $libv8_version_h" + exit 1 +fi + +# Build the package. +./libexec/build-libv8 $NODE_VERSION +./libexec/build-monolith $NODE_VERSION +./libexec/inject-libv8 $NODE_VERSION + +# Run V8 tests. +cd test/gtest +cmake -S . -B build +cd build +cmake --build . +./c_v8_tests + +if [ $? -ne 0 ]; then + echo "Tests failed." + exit 1 +fi + +# Build the gem. +cd "${BASEDIR}" +bundle exec rake binary + +# Test that the gem can be installed and used. +gem install pkg/libv8-node-$GEM_VERSION-$GEM_PLATFORM.gem + +git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 +cd test/mini_racer +ruby -i -ne "\$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(\" LIBV8_NODE_VERSION = \\\"$GEM_VERSION\\\"\\n\") : print" lib/mini_racer/version.rb +ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec +bundle install +bundle exec rake compile +bundle exec rake test \ No newline at end of file From 6dcb0dc06aa7805c846c824f58fd03b24010498b Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 18 Jul 2025 16:17:52 +1000 Subject: [PATCH 2/4] FIX: V8 tests need linking against CoreFoundation. --- test/gtest/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index d2360c5..65f160b 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -39,6 +39,10 @@ if(${system_name} STREQUAL "linux") endif() endif() +if(APPLE) + find_library(CoreFoundation CoreFoundation) +endif() + message(STATUS "Detected vendor architecture directory: ${vendor_arch}") # TODO?: Detect and support ruby-arch builds? @@ -47,5 +51,7 @@ target_link_libraries(c_v8_tests ${CMAKE_SOURCE_DIR}/../../vendor/v8/${vendor_ar # This has to be after the v8 monolith for some build setups. target_link_libraries(c_v8_tests dl) +target_link_libraries(c_v8_tests $<$:${CoreFoundation}>) + include(GoogleTest) gtest_discover_tests(c_v8_tests) From ebdbf8e0f5107e11353fcbc83ac4c89302b1f51a Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 18 Jul 2025 16:19:25 +1000 Subject: [PATCH 3/4] FIX: Linting. --- libexec/build-macos-x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/build-macos-x86_64 b/libexec/build-macos-x86_64 index 6e55787..2146662 100755 --- a/libexec/build-macos-x86_64 +++ b/libexec/build-macos-x86_64 @@ -56,4 +56,4 @@ ruby -i -ne "\$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(\" LIBV8_NODE_VERSION = \\ ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec bundle install bundle exec rake compile -bundle exec rake test \ No newline at end of file +bundle exec rake test From 1d7bab38dcdfd3cf1d44cde416804dd382dd3223 Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 18 Jul 2025 16:27:24 +1000 Subject: [PATCH 4/4] FIX: Remove old copies of mini_racer before trying to clone it. --- libexec/build-macos-x86_64 | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/build-macos-x86_64 b/libexec/build-macos-x86_64 index 2146662..c1cecee 100755 --- a/libexec/build-macos-x86_64 +++ b/libexec/build-macos-x86_64 @@ -50,6 +50,7 @@ bundle exec rake binary # Test that the gem can be installed and used. gem install pkg/libv8-node-$GEM_VERSION-$GEM_PLATFORM.gem +rm -rf test/mini_racer git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 cd test/mini_racer ruby -i -ne "\$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(\" LIBV8_NODE_VERSION = \\\"$GEM_VERSION\\\"\\n\") : print" lib/mini_racer/version.rb