Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions libexec/build-macos-x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#/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

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
ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec
bundle install
bundle exec rake compile
bundle exec rake test
6 changes: 6 additions & 0 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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 $<$<PLATFORM_ID:Darwin>:${CoreFoundation}>)

include(GoogleTest)
gtest_discover_tests(c_v8_tests)
Loading