summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
authorEric Seifert <seiferteric@gmail.com>2021-09-21 23:09:21 -0700
committerLinus Groh <mail@linusgroh.de>2021-09-24 10:04:47 +0200
commit01a06dde0e8de63aadeb42f01c6a2952feffb892 (patch)
tree5bd2677dee476397495c351000a02e2fb0146305 /Ports
parent32932f83be01578025c9e5411be5b2729520036f (diff)
downloadserenity-01a06dde0e8de63aadeb42f01c6a2952feffb892.zip
Ports: Add Ruby 3.0.2
Diffstat (limited to 'Ports')
-rw-r--r--Ports/AvailablePorts.md1
-rwxr-xr-xPorts/ruby/package.sh35
-rw-r--r--Ports/ruby/patches/config.patch23
-rw-r--r--Ports/ruby/patches/locale.patch18
-rw-r--r--Ports/ruby/patches/math.patch27
-rw-r--r--Ports/ruby/patches/posix.patch12
-rw-r--r--Ports/ruby/patches/rusage.patch113
-rw-r--r--Ports/ruby/version.sh6
8 files changed, 235 insertions, 0 deletions
diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md
index ee285dccd5..93135eddb7 100644
--- a/Ports/AvailablePorts.md
+++ b/Ports/AvailablePorts.md
@@ -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 |
diff --git a/Ports/ruby/package.sh b/Ports/ruby/package.sh
new file mode 100755
index 0000000000..5aee03051a
--- /dev/null
+++ b/Ports/ruby/package.sh
@@ -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
diff --git a/Ports/ruby/patches/config.patch b/Ports/ruby/patches/config.patch
new file mode 100644
index 0000000000..ea6a606af1
--- /dev/null
+++ b/Ports/ruby/patches/config.patch
@@ -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 :
+
diff --git a/Ports/ruby/patches/locale.patch b/Ports/ruby/patches/locale.patch
new file mode 100644
index 0000000000..b6f49f2250
--- /dev/null
+++ b/Ports/ruby/patches/locale.patch
@@ -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
+
diff --git a/Ports/ruby/patches/math.patch b/Ports/ruby/patches/math.patch
new file mode 100644
index 0000000000..219894cca7
--- /dev/null
+++ b/Ports/ruby/patches/math.patch
@@ -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
+
diff --git a/Ports/ruby/patches/posix.patch b/Ports/ruby/patches/posix.patch
new file mode 100644
index 0000000000..53cd1fbe69
--- /dev/null
+++ b/Ports/ruby/patches/posix.patch
@@ -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;
+ }
+
diff --git a/Ports/ruby/patches/rusage.patch b/Ports/ruby/patches/rusage.patch
new file mode 100644
index 0000000000..5566c34781
--- /dev/null
+++ b/Ports/ruby/patches/rusage.patch
@@ -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
+ }
+ }
+
diff --git a/Ports/ruby/version.sh b/Ports/ruby/version.sh
new file mode 100644
index 0000000000..96029c7a27
--- /dev/null
+++ b/Ports/ruby/version.sh
@@ -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"