Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull ruby build #924

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
216084d
Add RUBY_BUILD_TARBALL_OVERRIDE to override the ruby tarball URL
eregon Sep 21, 2023
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
5f4cea1
Merge pull request #2258 from eregon/overridable-url
mislav Oct 13, 2023
536495d
ruby-build 20231014
eregon Oct 14, 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 `[email protected]` requirement on macOS
mislav Oct 20, 2023
99fda28
JRuby: remove `[email protected]` 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
739a152
Merge ruby-build v20231025
jasonkarns Jun 4, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ The build process may be configured through the following environment variables:
| `NODE_BUILD_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz). |
| `NODE_BUILD_SKIP_MIRROR` | Bypass the download mirror and fetch all package files from their original URLs. |
| `NODE_BUILD_ROOT` | Custom build definition directory. (Default: `share/node-build`) |
| `NODE_BUILD_TARBALL_OVERRIDE` | Override the URL to fetch the node tarball from, optionally followed by `#checksum`. |
| `NODE_BUILD_DEFINITIONS` | Additional paths to search for build definitions. (Colon-separated list) |
| `CC` | Path to the C compiler. |
| `NODE_CFLAGS` | Additional `CFLAGS` options (_e.g.,_ to override `-O3`). |
Expand Down
118 changes: 63 additions & 55 deletions bin/node-build
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ fetch_tarball() {
local checksum
local extracted_dir

if is_node_package "$1" && [ -n "$NODE_BUILD_TARBALL_OVERRIDE" ]; then
package_url="$NODE_BUILD_TARBALL_OVERRIDE"
fi

if [ -z "$package_url" ]; then
echo "error: failed to download $package_name (missing package url)" >&2
return 1
Expand Down Expand Up @@ -601,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 @@ -736,6 +730,7 @@ build_package_standard_install() {
} >&4 2>&1
}

# Backward Compatibility for standard function
build_package_standard() {
build_package_standard_build "$@"
build_package_standard_install "$@"
Expand All @@ -746,14 +741,11 @@ build_package_autoconf() {
} >&4 2>&1
}

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

build_package_copy() {
build_package_copy_to "$PREFIX_PATH"
{ "$NODE_BIN" setup.rb
} >&4 2>&1
}

build_package_jxcore_v8_328() {
Expand Down Expand Up @@ -792,6 +784,10 @@ build_package_graal() {
rm -rf demo sample src
}

build_package_copy() {
mkdir -p "$PREFIX_PATH"
cp -fR . "$PREFIX_PATH"
}
before_install_package() {
:
}
Expand All @@ -813,6 +809,25 @@ fix_jxcore_directory_structure() {
} >&4
}

require_java() {
local required="$1"
local java_version version_string
java_version="$(java -version 2>&1 || true)"
version_string="$(grep 'java version' <<<"$java_version" | head -1 | grep -o '[0-9.]\+' | head -1 || true)"
[ -n "$version_string" ] || version_string="$(grep 'openjdk version' <<<"$java_version" | head -1 | grep -o '[0-9.]\+' | head -1 || true)"
IFS="."
# shellcheck disable=SC2206
local nums=($version_string)
IFS="$OLDIFS"
local found_version="${nums[0]}"
[ "$found_version" -gt 1 ] 2>/dev/null || found_version="${nums[1]}"
[ "$found_version" -ge "$required" ] 2>/dev/null && return 0
colorize 1 "ERROR" >&3
echo ": Java >= ${required} required, but your Java version was:" >&3
cat <<<"$java_version" >&3
return 1
}

# Kept for backward compatibility
require_java7() {
require_java 7
Expand All @@ -828,46 +843,42 @@ 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
}

apply_node_patch() {
local patchfile
case "$1" in
node-* | iojs-* )
if is_node_package "$1"; then
patchfile="$(mktemp "${TMP}/node-patch.XXXXXX")"
cat "${2:--}" >"$patchfile"

local striplevel=0
grep -q '^--- a/' "$patchfile" && striplevel=1
patch -p$striplevel --force -i "$patchfile"
fi
}

is_node_package() {
case "$1" in
node-* | iojs-* )
return 0
;;
*)
return 1
;;
esac
}

version() {
local git_revision

# Read the revision from git if the remote points to "node-build" repository
if GIT_DIR="$NODE_BUILD_INSTALL_PREFIX/.git" git remote -v 2>/dev/null | grep -q /node-build; then
git_revision="$(GIT_DIR="$NODE_BUILD_INSTALL_PREFIX/.git" git describe --tags HEAD 2>/dev/null || true)"
Expand Down Expand Up @@ -1109,9 +1120,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'
}
Loading
Loading