Skip to content

Commit 1d08308

Browse files
authored
Merge pull request #67 from pento/pento/dev-macos-build-script
DEV: Add a script for building on macos-x86_64
2 parents 6101402 + 1d7bab3 commit 1d08308

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

libexec/build-macos-x86_64

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#/bin/sh
2+
3+
set -e
4+
set -u
5+
6+
BASEDIR="${PWD}"
7+
8+
TARGET_PLATFORM=x86_64-darwin
9+
RUBY_TARGET_PLATFORM=x86_64-darwin
10+
11+
bundle install
12+
13+
RUBY_PLATFORM=$(./libexec/metadata ruby_platform)
14+
GEM_PLATFORM=$(./libexec/metadata gem_platform)
15+
GEM_VERSION=$(./libexec/metadata gem_version)
16+
NODE_VERSION=$(./libexec/metadata node_version)
17+
LIBV8_VERSION=$(./libexec/metadata libv8_version)
18+
19+
./libexec/download-node $NODE_VERSION
20+
./libexec/extract-node $NODE_VERSION
21+
22+
# Validate that we have the correct V8 version.
23+
libv8_version_h=$(./libexec/metadata libv8_version_h)
24+
if [ "$libv8_version_h" != "$LIBV8_VERSION" ]; then
25+
echo "LIBV8 version mismatch: expected $LIBV8_VERSION but found $libv8_version_h"
26+
exit 1
27+
fi
28+
29+
# Build the package.
30+
./libexec/build-libv8 $NODE_VERSION
31+
./libexec/build-monolith $NODE_VERSION
32+
./libexec/inject-libv8 $NODE_VERSION
33+
34+
# Run V8 tests.
35+
cd test/gtest
36+
cmake -S . -B build
37+
cd build
38+
cmake --build .
39+
./c_v8_tests
40+
41+
if [ $? -ne 0 ]; then
42+
echo "Tests failed."
43+
exit 1
44+
fi
45+
46+
# Build the gem.
47+
cd "${BASEDIR}"
48+
bundle exec rake binary
49+
50+
# Test that the gem can be installed and used.
51+
gem install pkg/libv8-node-$GEM_VERSION-$GEM_PLATFORM.gem
52+
53+
rm -rf test/mini_racer
54+
git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
55+
cd test/mini_racer
56+
ruby -i -ne "\$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(\" LIBV8_NODE_VERSION = \\\"$GEM_VERSION\\\"\\n\") : print" lib/mini_racer/version.rb
57+
ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec
58+
bundle install
59+
bundle exec rake compile
60+
bundle exec rake test

test/gtest/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ if(${system_name} STREQUAL "linux")
3939
endif()
4040
endif()
4141

42+
if(APPLE)
43+
find_library(CoreFoundation CoreFoundation)
44+
endif()
45+
4246
message(STATUS "Detected vendor architecture directory: ${vendor_arch}")
4347

4448
# TODO?: Detect and support ruby-arch builds?
@@ -47,5 +51,7 @@ target_link_libraries(c_v8_tests ${CMAKE_SOURCE_DIR}/../../vendor/v8/${vendor_ar
4751
# This has to be after the v8 monolith for some build setups.
4852
target_link_libraries(c_v8_tests dl)
4953

54+
target_link_libraries(c_v8_tests $<$<PLATFORM_ID:Darwin>:${CoreFoundation}>)
55+
5056
include(GoogleTest)
5157
gtest_discover_tests(c_v8_tests)

0 commit comments

Comments
 (0)