Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6663720
Cleanup in openssl compilation step
mislav Oct 13, 2023
47eda17
Remove implicit LDFLAGS, CPPFLAGS, and "ldflags_dirs" build step
mislav Oct 13, 2023
04ba857
Remove "ldflags_dirs" step from build definitions
mislav Oct 13, 2023
9b87491
Avoid compiling OpenSSL if the user supplied `--with-openssl-dir` on …
mislav Oct 13, 2023
7773f82
Cleanup in truffleruby+graalvm installation
mislav Oct 13, 2023
1d9b4e2
Merge pull request #2274 from rbenv/ruby-configure-opts
mislav Oct 14, 2023
7a741cf
Merge pull request #2270 from rbenv/openssl-clean
mislav Oct 16, 2023
aada31a
Avoiding excessive cd when fetching git repos (#2273)
mislav Oct 16, 2023
fe933ab
Merge pull request #2271 from rbenv/ldflags-clean
mislav Oct 16, 2023
a559b30
Improve `cached_tarball` test helper
mislav Oct 16, 2023
08b1cfa
Add `needs_openssl` test
mislav Oct 17, 2023
1dc3628
Merge pull request #2276 from rbenv/openssl-test
mislav Oct 17, 2023
0be9ae1
Add JRuby 9.4.4.0
headius Oct 18, 2023
0e4c61d
Merge pull request #2277 from headius/jruby-9.4.4.0
hsbt Oct 18, 2023
db600cc
TruffleRuby: remove explicit `openssl@1.1` requirement on macOS
mislav Oct 20, 2023
99fda28
JRuby: remove `openssl@1.1` requirement from `jruby-dev`
mislav Oct 20, 2023
c3bae8b
Fix fixing JRuby shebangs on macOS
mislav Oct 23, 2023
39f77ff
Skip ri/rdoc when installing jruby-launcher
eregon Oct 23, 2023
fbcb6bd
Bump up OpenSSL 3.1.4
hsbt Oct 25, 2023
4905179
Merge pull request #2283 from rbenv/openssl-3-1-4
hsbt Oct 25, 2023
4996d18
Add TruffleRuby and TruffleRuby GraalVM 23.1.1
eregon Oct 25, 2023
8afc6e1
ruby-build 20231025
eregon Oct 25, 2023
6f5fac5
Merge commit 'refs/rbtags/v20231025' into pull-ruby-build
jasonkarns Feb 22, 2026
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
74 changes: 22 additions & 52 deletions bin/node-build
Original file line number Diff line number Diff line change
Expand Up @@ -605,37 +605,27 @@ fetch_git() {

echo "Cloning ${git_url}..." >&2

if type git &>/dev/null; then
if [ -n "$NODE_BUILD_CACHE_PATH" ]; then
# shellcheck disable=SC2164
pushd "$NODE_BUILD_CACHE_PATH" >&4
local clone_name
clone_name="$(sanitize "$git_url")"
if [ -e "$clone_name" ]; then
{ # shellcheck disable=SC2164
cd "$clone_name"
git fetch --force "$git_url" "+${git_ref}:${git_ref}"
} >&4 2>&1
else
git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1
fi
git_url="$NODE_BUILD_CACHE_PATH/${clone_name}"
# shellcheck disable=SC2164
popd >&4
fi
if ! type git &>/dev/null; then
echo "error: please install \`git\` and try again" >&2
exit 1
fi

if [ -e "${package_name}" ]; then
( # shellcheck disable=SC2164
cd "${package_name}"
git fetch --depth 1 origin "+${git_ref}"
git checkout -q -B "$git_ref" "origin/${git_ref}"
) >&4 2>&1
if [ -n "$NODE_BUILD_CACHE_PATH" ]; then
local cache_dir
cache_dir="$NODE_BUILD_CACHE_PATH/$(sanitize "$git_url")"
if [ -e "$cache_dir" ]; then
git -C "$cache_dir" fetch --force "$git_url" "+${git_ref}:${git_ref}" >&4 2>&1
else
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1
git clone --bare --branch "$git_ref" "$git_url" "$cache_dir" >&4 2>&1
fi
git_url="$cache_dir"
fi

if [ -e "${package_name}" ]; then
git -C "$package_name" fetch --depth 1 origin "+${git_ref}" >&4 2>&1
git -C "$package_name" checkout -q -B "$git_ref" "origin/${git_ref}" >&4 2>&1
else
echo "error: please install \`git\` and try again" >&2
exit 1
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1
fi
}

Expand Down Expand Up @@ -750,14 +740,9 @@ build_package_autoconf() {
} >&4 2>&1
}

build_package_copy_to() {
to="$1"
mkdir -p "$to"
cp -fR . "$to"
}

build_package_copy() {
build_package_copy_to "$PREFIX_PATH"
mkdir -p "$PREFIX_PATH"
cp -fR . "$PREFIX_PATH"
}

build_package_jxcore_v8_328() {
Expand Down Expand Up @@ -832,25 +817,13 @@ require_llvm() {
:
}

# Ensure that directories listed in LDFLAGS exist
# Kept for backward compatibility with 3rd-party definitions.
build_package_ldflags_dirs() {
local ldflags
read -d '' -r -a ldflags <<<"$LDFLAGS" || true
local index=0
local dir
while [ "$index" -lt "${#ldflags[@]}" ]; do
dir=""
case "${ldflags[index]}" in
-L ) dir="${ldflags[index+1]}" ;;
-L* ) dir="${ldflags[index]#-L}" ;;
esac
[ -z "$dir" ] || mkdir -p "$dir"
index=$((index+1))
done
true
}

build_package_enable_shared() {
if [[ " ${NODE_CONFIGURE_OPTS} " != *" --disable-shared"* ]]; then
if [[ " ${NODE_CONFIGURE_OPTS} ${NODE_CONFIGURE_OPTS_ARRAY[*]}" != *" --disable-shared"* ]]; then
package_option node configure --enable-shared
fi
}
Expand Down Expand Up @@ -1122,9 +1095,6 @@ else
fi
fi

export LDFLAGS="-L${PREFIX_PATH}/lib ${LDFLAGS}"
export CPPFLAGS="-I${PREFIX_PATH}/include ${CPPFLAGS}"

unset NODEOPT
unset NODELIB

Expand Down
16 changes: 6 additions & 10 deletions test/arguments.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
load test_helper

@test "not enough arguments for node-build" {
mkdir -p "$TMP"
# use empty inline definition so nothing gets built anyway
local definition="${BATS_TMPDIR}/build-definition"
echo '' > "$definition"

run node-build "$definition"

touch "${TMP}/empty-definition"
run node-build "${TMP}/empty-definition"
assert_failure
assert_output --partial 'Usage: node-build'
}

@test "extra arguments for node-build" {
mkdir -p "$TMP"
# use empty inline definition so nothing gets built anyway
local definition="${BATS_TMPDIR}/build-definition"
echo '' > "$definition"

run node-build "$definition" "${BATS_TMPDIR}/install" ""

touch "${TMP}/empty-definition"
run node-build "${TMP}/empty-definition" "${TMP}/install" ""
assert_failure
assert_output --partial 'Usage: node-build'
}
99 changes: 67 additions & 32 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,69 @@ executable() {
}

cached_tarball() {
mkdir -p "$NODE_BUILD_CACHE_PATH"
pushd "$NODE_BUILD_CACHE_PATH" >/dev/null
tarball "$@"
popd >/dev/null
local save_to_fixtures
case "$*" in
"node-v4.0.0 configure" )
save_to_fixtures=1
;;
esac

local tarball="${1}.tar.gz"
local fixture_tarball="${FIXTURE_ROOT}/${tarball}"
local cached_tarball="${NODE_BUILD_CACHE_PATH}/${tarball}"
shift 1

if [ -n "$save_to_fixtures" ] && [ -e "$fixture_tarball" ]; then
mkdir -p "$(dirname "$cached_tarball")"
cp "$fixture_tarball" "$cached_tarball"
return 0
fi

generate_tarball "$cached_tarball" "$@"
[ -z "$save_to_fixtures" ] || cp "$cached_tarball" "$fixture_tarball"
}

tarball() {
local name="$1"
local path="$PWD/$name"
local configure="$path/configure"
generate_tarball() {
local tarfile="$1"
shift 1
local name path
name="$(basename "${tarfile%.tar.gz}")"
path="$(mktemp -d "$TMP/tarball.XXXXX")/${name}"

executable "$configure" <<OUT
local file target
for file; do
case "$file" in
config | configure )
mkdir -p "$(dirname "${path}/${file}")"
cat > "${path}/${file}" <<OUT
#!$BASH
IFS=,
echo "$name: [\$*]" \${NODEOPT:+NODEOPT=\$NODEOPT} >> build.log
OUT

for file; do
mkdir -p "$(dirname "${path}/${file}")"
touch "${path}/${file}"
chmod +x "${path}/${file}"
;;
*:* )
target="${file#*:}"
file="${file%:*}"
mkdir -p "$(dirname "${path}/${file}")"
cp "$target" "${path}/${file}"
;;
* )
mkdir -p "$(dirname "${path}/${file}")"
touch "${path}/${file}"
;;
esac
done

tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
mkdir -p "$(dirname "$tarfile")"
tar czf "$tarfile" -C "${path%/*}" "$name"
rm -rf "$path"
}

stub_make_install() {
stub "$MAKE" \
" : echo \"$MAKE \$(inspect_args \"\$@\")\" >> build.log" \
"install : echo \"$MAKE \$(inspect_args \"\$@\")\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
"install* : echo \"$MAKE \$(inspect_args \"\$@\")\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
}

assert_build_log() {
Expand All @@ -59,8 +92,10 @@ assert_build_log() {
}

@test "apply node patch before building" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname '-s : echo Linux'
stub_repeated brew false
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'

Expand All @@ -83,7 +118,7 @@ OUT
}

@test "striplevel node patch before building" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
Expand All @@ -107,7 +142,7 @@ OUT
}

@test "apply node patch from git diff before building" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
Expand All @@ -132,7 +167,7 @@ OUT
}

@test "forward extra command-line arguments as configure flags" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_make_install

Expand All @@ -141,20 +176,20 @@ install_package "node-v4.0.0" "http://nodejs.org/dist/v4.0.0/node-v4.0.0.tar.gz"
DEF

# TODO: use configure flags meaningful to node
NODE_CONFIGURE_OPTS='--with-readline-dir=/custom' run node-build "$BATS_TMPDIR/build-definition" "$INSTALL_ROOT" -- cppflags="-DYJIT_FORCE_ENABLE -DRUBY_PATCHLEVEL_NAME=test" --with-openssl-dir=/path/to/openssl
NODE_CONFIGURE_OPTS='--with-readline-dir=/custom' run node-build "$BATS_TMPDIR/build-definition" "$INSTALL_ROOT" -- cppflags="-DYJIT_FORCE_ENABLE -DNODE_PATCHLEVEL_NAME=test" --with-openssl-dir=/path/to/openssl
assert_success

unstub make

assert_build_log <<OUT
node-v4.0.0: [--prefix=$INSTALL_ROOT,cppflags=-DYJIT_FORCE_ENABLE -DRUBY_PATCHLEVEL_NAME=test,--with-openssl-dir=/path/to/openssl,--with-readline-dir=/custom]
node-v4.0.0: [--prefix=$INSTALL_ROOT,cppflags=-DYJIT_FORCE_ENABLE -DNODE_PATCHLEVEL_NAME=test,--with-openssl-dir=/path/to/openssl,--with-readline-dir=/custom]
make -j 2
make install
OUT
}

@test "number of CPU cores defaults to 2" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname '-s : echo Darwin'
stub sysctl false
Expand All @@ -177,7 +212,7 @@ OUT
}

@test "number of CPU cores is detected on Mac" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname '-s : echo Darwin'
stub sysctl '-n hw.ncpu : echo 4'
Expand All @@ -201,7 +236,7 @@ OUT
}

@test "number of CPU cores is detected on FreeBSD" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname '-s : echo FreeBSD'
stub sysctl '-n hw.ncpu : echo 1'
Expand All @@ -226,7 +261,7 @@ OUT
}

@test "using MAKE_INSTALL_OPTS" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname '-s : echo Linux'
stub_make_install
Expand All @@ -243,7 +278,7 @@ DEF
assert_build_log <<OUT
node-v4.0.0: --prefix=$INSTALL_ROOT
make -j 2
make install --globalmake RUBYMAKE=true with spaces
make install --globalmake NODEMAKE=true with spaces
OUT
}

Expand All @@ -257,7 +292,7 @@ OUT
}

@test "make on FreeBSD defaults to gmake" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

stub_repeated uname "-s : echo FreeBSD"
MAKE=gmake stub_make_install
Expand All @@ -270,7 +305,7 @@ OUT
}

@test "can use NODE_CONFIGURE to apply a patch" {
cached_tarball "node-v4.0.0"
cached_tarball "node-v4.0.0" configure

executable "${BATS_TMPDIR}/custom-configure" <<CONF
#!$BASH
Expand Down Expand Up @@ -336,17 +371,17 @@ OUT
assert_output "node-build: TMPDIR=$TMPDIR is set to a non-accessible location"
}

@test "initializes LDFLAGS directories" {
cached_tarball "node-v4.0.0"
@test "does not initialize LDFLAGS directories" {
cached_tarball "node-v4.0.0" configure

export LDFLAGS="-L ${BATS_TEST_DIRNAME}/what/evs"
run_inline_definition <<DEF
install_package "node-v4.0.0" "http://nodejs.org/dist/v4.0.0/node-v4.0.0.tar.gz" ldflags_dirs
DEF
assert_success

assert [ -d "${INSTALL_ROOT}/lib" ]
assert [ -d "${BATS_TEST_DIRNAME}/what/evs" ]
assert [ ! -d "${INSTALL_ROOT}/lib" ]
assert [ ! -d "${BATS_TEST_DIRNAME}/what/evs" ]
}

@test "directory structure is fixed for jxcore source builds" {
Expand Down
Loading
Loading