Manage required baseruby version in one place

Add a Ruby script mode to `tool/missing-baseruby.bat` that checks if
`RUBY_VERSION` meets the required version.  This will enable similar
checks on mswin as well.
This commit is contained in:
Nobuyoshi Nakada 2024-03-30 18:34:45 +09:00
parent f697d3242f
commit 376ae22235
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
4 changed files with 11 additions and 8 deletions

View File

@ -75,10 +75,8 @@ AC_ARG_WITH(baseruby,
[ [
AC_PATH_PROG([BASERUBY], [ruby], [false]) AC_PATH_PROG([BASERUBY], [ruby], [false])
]) ])
required_baseruby_version=`${tooldir}/missing-baseruby.bat 2>&1 | sed '/.* BASERUBY must be /!d;s///;s/^Ruby *//;s/ .*//'`
required_baseruby_version=${required_baseruby_version%.0} # Note that `"x.y.0" > "x.y"` is true.
AS_IF([test "$HAVE_BASERUBY" != no], [ AS_IF([test "$HAVE_BASERUBY" != no], [
HAVE_BASERUBY="`RUBYOPT=- $BASERUBY --disable=gems -e 'print :yes if RUBY_VERSION > "'$required_baseruby_version'"' 2>/dev/null`" RUBYOPT=- $BASERUBY --disable=gems "${tooldir}/missing-baseruby.bat" || HAVE_BASERUBY=no
]) ])
AS_IF([test "${HAVE_BASERUBY:=no}" != no], [ AS_IF([test "${HAVE_BASERUBY:=no}" != no], [
AS_CASE(["$build_os"], [mingw*], [ AS_CASE(["$build_os"], [mingw*], [

View File

@ -1,12 +1,14 @@
: " :"" == "
@echo off || ( @echo off || (
:warn :warn
echo>&2.%~1 echo>&2.%~1
goto :eof goto :eof
:abort :abort
exit /b 1 exit /b 1
)||(
:)"||(
s = %^#
) )
: "
: ; call() { local call=${1#:}; shift; $call "$@"; } : ; call() { local call=${1#:}; shift; $call "$@"; }
: ; warn() { echo "$1" >&2; } : ; warn() { echo "$1" >&2; }
: ; abort () { exit 1; } : ; abort () { exit 1; }
@ -14,3 +16,4 @@
call :warn "executable host ruby is required. use --with-baseruby option." call :warn "executable host ruby is required. use --with-baseruby option."
call :warn "Note that BASERUBY must be Ruby 3.0.0 or later." call :warn "Note that BASERUBY must be Ruby 3.0.0 or later."
call :abort call :abort
: || (:^; abort if RUBY_VERSION < s[%r"warn .*Ruby ([\d.]+)(?:\.0)?",1])

View File

@ -11,13 +11,15 @@ PATH_SEPARATOR = ;
TZ = # skip timezone tests TZ = # skip timezone tests
PWD = $(MAKEDIR) PWD = $(MAKEDIR)
empty = empty =
tooldir = $(srcdir)/tool
!ifndef MFLAGS !ifndef MFLAGS
MFLAGS=-l MFLAGS=-l
!endif !endif
!if "$(BASERUBY)" == "" !if "$(BASERUBY)" == ""
! if [for %I in (ruby.exe) do @echo BASERUBY = %~s$$PATH:I > baseruby.mk] ! if [ruby $(tooldir)/missing-baseruby.bat 2> nul]
! else if [for %I in (ruby.exe) do @echo BASERUBY = %~s$$PATH:I > baseruby.mk]
! else ! else
! include baseruby.mk ! include baseruby.mk
! endif ! endif
@ -27,7 +29,7 @@ MFLAGS=-l
BASERUBY = BASERUBY =
!endif !endif
!if "$(BASERUBY)" == "" !if "$(BASERUBY)" == ""
BASERUBY = echo executable host ruby is required. use --with-baseruby option.^& exit 1 BASERUBY = $(tooldir:/=\)\missing-baseruby.bat
HAVE_BASERUBY = no HAVE_BASERUBY = no
!else !else
HAVE_BASERUBY = yes HAVE_BASERUBY = yes
@ -485,7 +487,6 @@ EXTOBJS = dmyext.$(OBJEXT)
arch_hdrdir = $(EXTOUT)/include/$(arch) arch_hdrdir = $(EXTOUT)/include/$(arch)
top_srcdir = $(srcdir) top_srcdir = $(srcdir)
hdrdir = $(srcdir)/include hdrdir = $(srcdir)/include
tooldir = $(srcdir)/tool
VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/missing;$(win_srcdir) VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/missing;$(win_srcdir)
!ifndef GIT !ifndef GIT

View File

@ -66,6 +66,7 @@ RJIT_SUPPORT = $(RJIT_SUPPORT)
# TOOLS # TOOLS
<< <<
!if defined(BASERUBY) !if defined(BASERUBY)
$(BASERUBY:/=\) "$(srcdir)/tool/missing-baseruby.bat"
@echo BASERUBY = $(BASERUBY:/=\)>> $(MAKEFILE) @echo BASERUBY = $(BASERUBY:/=\)>> $(MAKEFILE)
!endif !endif
!if "$(RUBY_DEVEL)" == "yes" !if "$(RUBY_DEVEL)" == "yes"