Ports: Add Ruby 3.0.2

This commit is contained in:
Eric Seifert 2021-09-21 23:09:21 -07:00 committed by Linus Groh
parent 32932f83be
commit 01a06dde0e
Notes: sideshowbarker 2024-07-18 03:30:24 +09:00
9 changed files with 286 additions and 0 deletions

View file

@ -139,6 +139,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
| [`radare2`](radare2/) | radare2 reverse engineering framework | 5.4.0-git | https://github.com/radareorg/radare2 |
| [`readline`](readline/) | GNU Readline Library | 8.1 | https://tiswww.case.edu/php/chet/readline/rltop.html |
| [`rsync`](rsync/) | rsync | 3.1.3 | https://rsync.samba.org/ |
| [`ruby`](ruby/) | Ruby | 3.0.2 | https://www.ruby-lang.org/ |
| [`sam`](sam/) | Software Automatic Mouth (SAM) | c86ea39 | https://github.com/vidarh/SAM |
| [`scummvm`](scummvm/) | ScummVM | 2.2.0 | https://www.scummvm.org/ |
| [`SDL2`](SDL2/) | Simple DirectMedia Layer (SDL2) | | https://github.com/SerenityOS/SDL |

35
Ports/ruby/package.sh Executable file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env -S bash ../.port_include.sh
source version.sh
port=ruby
version=${RUBY_VERSION}
useconfigure="true"
files="${RUBY_ARCHIVE_URL} ${RUBY_ARCHIVE} ${RUBY_ARCHIVE_SHA256SUM}
https://cache.ruby-lang.org/pub/misc/logo/ruby-logo-kit.zip ruby-logo-kit.zip 7f0a980e09874d35d80b958949dc2460e683957de3d2494a1499aea9d9989055"
auth_type="sha256"
launcher_name="Ruby IRB"
launcher_category="Development"
launcher_command="/usr/local/bin/ruby /usr/local/bin/irb --nomultiline --nosingleline"
launcher_run_in_terminal="true"
icon_file="../ruby-kit/ruby.png"
configopts="--with-coroutine=x86 --disable-install-doc"
export CFLAGS="-DNGROUPS_MAX=65536"
# Note: The showproperty command is used when linting ports, we don't actually need ruby at this time.
if [ "$1" != "showproperty" ]; then
if [ -x "$(command -v ruby)" ]; then
# Check if major and minor version of ruby are matching
if [ $(ruby --version | awk {'printf $2'} | awk -Fp {'print $1'}) != "$RUBY_VERSION" ]; then
echo "Error: ruby version does not match needed version to build ${RUBY_VERSION}" >&2
echo "Build this ruby version on your host using Toolchain/BuildRuby.sh or install it otherwise and try again." >&2
exit 1
fi
else
echo "Error: ruby is not installed but is required to build ${RUBY_VERSION}" >&2
echo "Build this ruby version on your host using Toolchain/BuildRuby.sh or install it otherwise and try again." >&2
exit 1
fi
fi

View file

@ -0,0 +1,23 @@
--- ruby-3.0.2/tool/config.sub 2021-07-07 03:08:35.000000000 -0700
+++ ruby-3.0.2/tool/config.sub 2021-09-15 10:18:47.677232027 -0700
@@ -1695,7 +1695,7 @@
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
- gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+ gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | serenity* | irix* \
| *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
| sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
--- ruby-3.0.2/configure 2021-09-16 14:10:42.314091669 -0700
+++ ruby-3.0.2/configure 2021-09-18 19:14:21.633876942 -0700
@@ -28610,7 +28610,7 @@
*) :
;;
esac ;; #(
- linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | haiku*) :
+ linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | serenity* | haiku*) :
: ${LDSHARED='$(CC) -shared'}
if test "$rb_cv_binary_elf" = yes; then :

View file

@ -0,0 +1,18 @@
--- ruby-3.0.2/ext/nkf/nkf-utf8/nkf.h 2021-07-07 03:08:35.000000000 -0700
+++ ruby-3.0.2/ext/nkf/nkf-utf8/nkf.h 2021-09-16 11:43:53.021002630 -0700
@@ -152,14 +152,6 @@
# ifndef HAVE_LOCALE_H
# define HAVE_LOCALE_H
# endif
-#elif defined(__BIONIC__) /* bionic doesn't have locale */
-#else
-# ifndef HAVE_LANGINFO_H
-# define HAVE_LANGINFO_H
-# endif
-# ifndef HAVE_LOCALE_H
-# define HAVE_LOCALE_H
-# endif
#endif
#ifdef HAVE_LANGINFO_H

View file

@ -0,0 +1,27 @@
--- ruby-3.0.2/ext/bigdecimal/bigdecimal.h 2021-09-15 10:18:47.365241873 -0700
+++ ruby-3.0.2/ext/bigdecimal/bigdecimal.h 2021-09-16 11:56:52.989171237 -0700
@@ -74,23 +74,6 @@
#endif
#endif
-#ifndef HAVE_LABS
-static inline long
-labs(long const x)
-{
- if (x < 0) return -x;
- return x;
-}
-#endif
-
-#ifndef HAVE_LLABS
-static inline LONG_LONG
-llabs(LONG_LONG const x)
-{
- if (x < 0) return -x;
- return x;
-}
-#endif
#ifndef HAVE_FINITE
static int

View file

@ -0,0 +1,12 @@
--- ruby-3.0.2/include/ruby/internal/intern/select/posix.h
+++ ruby-3.0.2/include/ruby/internal/intern/select/posix.h
@@ -55,7 +55,7 @@ rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
}
static inline void
-rb_fd_dup(rb_fdset_t *dst, const fd_set *src, int n)
+rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
{
*dst = *src;
}

View file

@ -0,0 +1,113 @@
--- ruby-3.2.0/process.c 2021-09-16 13:10:16.001908642 -0700
+++ ruby-3.2.0/process.c 2021-09-16 14:21:00.080586664 -0700
@@ -324,9 +324,6 @@
static ID id_TIMES_BASED_CLOCK_MONOTONIC;
static ID id_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID;
#endif
-#ifdef RUSAGE_SELF
-static ID id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID;
-#endif
static ID id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID;
#ifdef __APPLE__
static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;
@@ -7878,16 +7875,6 @@
rb_proc_times(VALUE obj)
{
VALUE utime, stime, cutime, cstime, ret;
-#if defined(RUSAGE_SELF) && defined(RUSAGE_CHILDREN)
- struct rusage usage_s, usage_c;
-
- if (getrusage(RUSAGE_SELF, &usage_s) != 0 || getrusage(RUSAGE_CHILDREN, &usage_c) != 0)
- rb_sys_fail("getrusage");
- utime = DBL2NUM((double)usage_s.ru_utime.tv_sec + (double)usage_s.ru_utime.tv_usec/1e6);
- stime = DBL2NUM((double)usage_s.ru_stime.tv_sec + (double)usage_s.ru_stime.tv_usec/1e6);
- cutime = DBL2NUM((double)usage_c.ru_utime.tv_sec + (double)usage_c.ru_utime.tv_usec/1e6);
- cstime = DBL2NUM((double)usage_c.ru_stime.tv_sec + (double)usage_c.ru_stime.tv_usec/1e6);
-#else
const double hertz = (double)get_clk_tck();
struct tms buf;
@@ -7896,7 +7883,6 @@
stime = DBL2NUM(buf.tms_stime / hertz);
cutime = DBL2NUM(buf.tms_cutime / hertz);
cstime = DBL2NUM(buf.tms_cstime / hertz);
-#endif
ret = rb_struct_new(rb_cProcessTms, utime, stime, cutime, cstime);
RB_GC_GUARD(utime);
RB_GC_GUARD(stime);
@@ -8312,26 +8298,6 @@
}
#endif
-#ifdef RUSAGE_SELF
-#define RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID \
- ID2SYM(id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID)
- if (clk_id == RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) {
- struct rusage usage;
- int32_t usec;
- ret = getrusage(RUSAGE_SELF, &usage);
- if (ret != 0)
- rb_sys_fail("getrusage");
- tt.giga_count = usage.ru_utime.tv_sec + usage.ru_stime.tv_sec;
- usec = (int32_t)(usage.ru_utime.tv_usec + usage.ru_stime.tv_usec);
- if (1000000 <= usec) {
- tt.giga_count++;
- usec -= 1000000;
- }
- tt.count = usec * 1000;
- denominators[num_denominators++] = 1000000000;
- goto success;
- }
-#endif
#ifdef HAVE_TIMES
#define RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID \
@@ -9082,9 +9048,6 @@
id_TIMES_BASED_CLOCK_MONOTONIC = rb_intern_const("TIMES_BASED_CLOCK_MONOTONIC");
id_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID");
#endif
-#ifdef RUSAGE_SELF
- id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID");
-#endif
id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID");
#ifdef __APPLE__
id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC = rb_intern_const("MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC");
--- ruby-3.2.0/gc.c 2021-09-16 13:10:15.953909370 -0700
+++ ruby-3.2.0/gc.c 2021-09-16 14:21:52.135786845 -0700
@@ -11530,17 +11530,6 @@
}
#endif
-#ifdef RUSAGE_SELF
- {
- struct rusage usage;
- struct timeval time;
- if (getrusage(RUSAGE_SELF, &usage) == 0) {
- time = usage.ru_utime;
- return time.tv_sec + time.tv_usec * 1e-6;
- }
- }
-#endif
-
#ifdef _WIN32
{
FILETIME creation_time, exit_time, kernel_time, user_time;
@@ -11600,18 +11589,6 @@
#if MALLOC_ALLOCATED_SIZE
record->allocated_size = malloc_allocated_size;
#endif
-#if GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY
-#ifdef RUSAGE_SELF
- {
- struct rusage usage;
- if (getrusage(RUSAGE_SELF, &usage) == 0) {
- record->maxrss = usage.ru_maxrss;
- record->minflt = usage.ru_minflt;
- record->majflt = usage.ru_majflt;
- }
- }
-#endif
-#endif
}
}

6
Ports/ruby/version.sh Normal file
View file

@ -0,0 +1,6 @@
RUBY_MAJOR="3.0"
RUBY_TEENY="2"
RUBY_VERSION="${RUBY_MAJOR}.${RUBY_TEENY}"
RUBY_ARCHIVE="ruby-${RUBY_VERSION}.tar.gz"
RUBY_ARCHIVE_URL="https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR}/${RUBY_ARCHIVE}"
RUBY_ARCHIVE_SHA256SUM="5085dee0ad9f06996a8acec7ebea4a8735e6fac22f22e2d98c3f2bc3bef7e6f1"

51
Toolchain/BuildRuby.sh Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -e
# This file will need to be run in bash, for now.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCH=${ARCH:-"i686"}
PREFIX_DIR="$DIR/Local/$ARCH"
BUILD_DIR="$DIR/Build/$ARCH"
TARBALLS_DIR="$DIR/Tarballs"
# shellcheck source=/dev/null
source "$DIR/../Ports/ruby/version.sh"
mkdir -p "${TARBALLS_DIR}"
pushd "${TARBALLS_DIR}"
if [ ! -e "${RUBY_ARCHIVE}" ]; then
echo "Downloading Ruby from ${RUBY_ARCHIVE_URL}..."
curl -O "${RUBY_ARCHIVE_URL}"
else
echo "${RUBY_ARCHIVE} already exists, not downloading archive"
fi
if ! sha256sum --status -c <(echo "${RUBY_ARCHIVE_SHA256SUM}" "${RUBY_ARCHIVE}"); then
echo "Ruby archive SHA256 sum mismatch, please run script again"
rm -f "${RUBY_ARCHIVE}"
exit 1
fi
if [ ! -d "ruby-${RUBY_VERSION}" ]; then
echo "Extracting ${RUBY_ARCHIVE}..."
tar -xf "${RUBY_ARCHIVE}"
else
echo "ruby-${RUBY_VERSION} already exists, not extracting archive"
fi
popd
if [ -z "$MAKEJOBS" ]; then
MAKEJOBS=$(nproc)
fi
mkdir -p "${PREFIX_DIR}"
mkdir -p "${BUILD_DIR}/ruby"
pushd "${BUILD_DIR}/ruby"
"${TARBALLS_DIR}"/ruby-"${RUBY_VERSION}"/configure --prefix="${PREFIX_DIR}"
make -j "${MAKEJOBS}"
make install
popd