mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
Reduce the requirements of lastrev
Remove baseruby from the prerequisites so that `lastrev` will work as long as Git is installed.
This commit is contained in:
1 parent
57fd148554
commit
4361d8e48f
5 files changed
+192
-29
Notes:
git
2026-10-15 08:09:27 +00:00
No files matched your search
@@ -20,6 +20,8 @@ mflags = $(MFLAGS)
|
||||
gnumake_recursive =
|
||||
sequential = $(gnumake:yes=-sequential)
|
||||
enable_shared = $(ENABLE_SHARED:no=)
|
||||
yes_git = $(WITH_GIT:no=)
|
||||
no_git = $(WITH_GIT:yes=)
|
||||
|
||||
UNICODE_VERSION = 17.0.0
|
||||
UNICODE_EMOJI_VERSION_0 = $(UNICODE_VERSION)///
|
||||
@@ -1356,14 +1358,14 @@ clean-build-tool:
|
||||
- cd build-tool 2> $(NULL) && $(MAKE) clean 2> $(NULL) || $(NULLCMD)
|
||||
- $(RMDIR) build-tool 2> $(NULL) || $(NULLCMD)
|
||||
|
||||
$(srcdir)/revision.h$(no_baseruby:no=~disabled~): $(REVISION_H)
|
||||
$(srcdir)/revision.h$(no_git:no=~disabled~): $(REVISION_H)
|
||||
|
||||
REVISION_H_CMD = $(BASERUBY) $(tooldir)/file2lastrev.rb -q --revision.h \
|
||||
--srcdir="$(srcdir)" --output=revision.h --timestamp=$(REVISION_H)
|
||||
REVISION_H_CMD = $(LASTREV) | $(IFCHANGE) --timestamp=.revision.time revision.h -
|
||||
|
||||
$(REVISION_H)$(no_baseruby:no=~disabled~):
|
||||
$(REVISION_H)$(no_git:no=~disabled~):
|
||||
$(Q) $(REVISION_H_CMD)
|
||||
$(REVISION_H)$(yes_baseruby:yes=~disabled~):
|
||||
$(REVISION_H)$(yes_git:yes=~disabled~):
|
||||
$(Q) exit >> revision.h
|
||||
$(Q) exit > $@
|
||||
|
||||
# uncommon.mk: $(REVISION_H)
|
||||
|
||||
@@ -250,6 +250,7 @@ AR = @AR@
|
||||
ARFLAGS = @ARFLAGS@$(empty)
|
||||
RANLIB = @RANLIB@
|
||||
AS = @AS@
|
||||
LASTREV = $(SHELL) $(tooldir)/lastrev
|
||||
IFCHANGE = $(SHELL) $(tooldir)/ifchange
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJCOPY = @OBJCOPY@
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
: ${git=git}
|
||||
|
||||
date_type=cd
|
||||
width=10
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 [options] [working-directory [head]]
|
||||
options:
|
||||
-g, --git=git-command specify the git command[$git]
|
||||
-d, --date=author|committer specify date type
|
||||
-w, --width=width abbreviation width [default=$width]
|
||||
"
|
||||
exit ${1}
|
||||
}
|
||||
|
||||
die () {
|
||||
echo "${0##*/}: $1" 1>&2
|
||||
usage 1 1>&2
|
||||
}
|
||||
|
||||
while getopts g:d:w:h-: opt; do
|
||||
optarg="$OPTARG"
|
||||
if [ "$opt" = "-" ]; then
|
||||
opt="-${optarg%%=*}"
|
||||
case "$optarg" in
|
||||
*=*)
|
||||
optarg="${optarg#*=}";;
|
||||
*)
|
||||
eval 'optarg="${'$OPTIND'}"'
|
||||
case "${optarg}" in
|
||||
-*)
|
||||
optarg=;;
|
||||
*)
|
||||
shift $OPTIND; OPTIND=1;;
|
||||
esac
|
||||
esac
|
||||
fi
|
||||
|
||||
case "-$opt" in
|
||||
-g|--git)
|
||||
git="$optarg";;
|
||||
-d|--date)
|
||||
case author in "$optarg"*) date_type=ad; :;; *) false;; esac ||
|
||||
case committer in "$optarg"*) date_type=cd; :;; *) false;; esac ||
|
||||
die "Unknown date $optarg";;
|
||||
-w|--width)
|
||||
width="$optarg";;
|
||||
-h|--help)
|
||||
usage;;
|
||||
--)
|
||||
break;;
|
||||
-*)
|
||||
die "Unknown option $1";;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
gitdir="${1-.}" head="${2-HEAD}"
|
||||
|
||||
branch=`${git} -C "${gitdir}" symbolic-ref --short "${head}" 2>/dev/null` || branch="$head"
|
||||
set `${git} -C "${gitdir}" log -1 --no-show-signature "--abbrev=${width}" \
|
||||
"--date=format-local:%FT%TZ %Y %m %d" "--format=%h %H %${date_type}" "${head}" --`
|
||||
|
||||
echo "#define RUBY_REVISION \"$1\""
|
||||
echo "#define RUBY_FULL_REVISION \"${2}\""
|
||||
echo "#define RUBY_BRANCH_NAME \"${branch}\""
|
||||
echo "#define RUBY_RELEASE_DATETIME \"${3}\""
|
||||
echo "#define RUBY_RELEASE_YEAR ${4}"
|
||||
echo "#define RUBY_RELEASE_MONTH ${5#0}"
|
||||
echo "#define RUBY_RELEASE_DAY ${6#0}"
|
||||
@@ -124,6 +124,7 @@ LRAMA = $(BASERUBY) $(top_srcdir)/tool/lrama/exe/lrama
|
||||
AR = lib -nologo
|
||||
PURIFY =
|
||||
AUTOCONF = autoconf
|
||||
LASTREV = $(COMSPEC) /C $(srcdir:/=\)\win32\lastrev.bat
|
||||
IFCHANGE = $(COMSPEC) /C $(srcdir:/=\)\win32\ifchange.bat
|
||||
RM = $(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat
|
||||
RM1 = del
|
||||
|
||||
+111
-24
@@ -1,31 +1,118 @@
|
||||
@echo off
|
||||
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
|
||||
|
||||
if "%1" == "" (set gitdir=.) else (set "gitdir=%1")
|
||||
for %%I in (%0) do set "progname=%%~nI"
|
||||
|
||||
if not defined git (set "git=git")
|
||||
if not defined gitdir (set "gitdir=.")
|
||||
set "head=HEAD"
|
||||
set "width=10"
|
||||
set "date_type=cd"
|
||||
goto :optloop
|
||||
|
||||
:usage
|
||||
for %%I in (
|
||||
"usage: %progname% [options] [working-directory [head]]"
|
||||
"options:"
|
||||
" -g, --git=git-command specify the git command[%git%]"
|
||||
" -d, --date=author|committer specify date type"
|
||||
" -w, --width=width abbreviation width [default=%width%]"
|
||||
) do echo.%%~I
|
||||
exit %1
|
||||
:die
|
||||
for %%I in (%1) do (echo %progname%: %%~I) 1>&2
|
||||
call :usage 1 1>&2
|
||||
|
||||
:optloop
|
||||
set "opt=%1"
|
||||
if not defined opt (goto :optend)
|
||||
if not "%opt:~0,1%" == "-" (goto :optend)
|
||||
if "%opt%" == "--" (shift /1 & goto :optend)
|
||||
shift
|
||||
if not "%opt:~0,2%" == "--" goto :shortopt
|
||||
for /f "delims== tokens=1,*" %%I in ("%opt%") do (set "opt=%%I" & set "optarg=%%J")
|
||||
goto :eachopt
|
||||
:shortopt
|
||||
set "optarg=%opt:~2%"
|
||||
set "opt=%opt:~0,2%"
|
||||
if defined optarg goto :have_optarg
|
||||
set "optarg=%1"
|
||||
if not defined optarg (
|
||||
call :die "Missing argument for %opt%"
|
||||
)
|
||||
if "%optarg:~0,1%" == "-" (set optarg=) else (shift)
|
||||
goto :eachopt
|
||||
:have_optarg
|
||||
if "%opt%" == "-g" (set "opt=--git" & goto :eachopt)
|
||||
if "%opt%" == "-d" (set "opt=--date" & goto :eachopt)
|
||||
if "%opt%" == "-w" (set "opt=--width" & goto :eachopt)
|
||||
if "%opt%" == "-h" (set "opt=--help" & goto :eachopt)
|
||||
call :die "Unknown option %opt"
|
||||
::-
|
||||
:eachopt
|
||||
if defined optarg goto :havearg
|
||||
set "optarg=%1"
|
||||
if "%optarg:~0,1%" == "-" (set "optarg=") else (shift)
|
||||
:havearg
|
||||
if "%opt%" == "--git" (
|
||||
set "git=%optarg%"
|
||||
goto :optloop
|
||||
)
|
||||
if "%opt%" == "--date" (
|
||||
((echo author) | findstr -b -l -c:"%optarg%" > nul) && (set "date_type=ad" & goto :optloop)
|
||||
((echo committer) | findstr -b -l -c:"%optarg%" > nul) && (set "date_type=cd" & goto :optloop)
|
||||
call :die "Unknown date %optarg%"
|
||||
)
|
||||
if "%opt%" == "--width" (
|
||||
set /a "width=%optarg%"
|
||||
goto :optloop
|
||||
)
|
||||
if "%opt%" == "--debug" (
|
||||
set "PROMPT=$E[94m+$E[m$S"
|
||||
echo on
|
||||
goto :optloop
|
||||
)
|
||||
if "%opt%" == "--help" (
|
||||
call :usage
|
||||
)
|
||||
call :die "Unknown option: %1"
|
||||
|
||||
:optend
|
||||
|
||||
if not defined git goto :EOF
|
||||
|
||||
if not "%1" == "" (set "gitdir=%1")
|
||||
if not "%2" == "" (set "head=%2")
|
||||
|
||||
set TZ=UTC
|
||||
::- shorten %H for the stabilities, the length of %h may vary
|
||||
for /f "usebackq tokens=1-3" %%I in (
|
||||
`git -C "%gitdir%" log -1 --no-show-signature "--date=format-local:%%F %%T" "--format=%%H %%cd" HEAD`
|
||||
|
||||
(for /f "usebackq tokens=1" %%I in (
|
||||
`%git% -C "%gitdir%" symbolic-ref --short %head%`
|
||||
) do set branch=%%I) 2> nul
|
||||
if not defined branch (
|
||||
set "branch=%head%"
|
||||
)
|
||||
|
||||
for /f "usebackq tokens=1-6" %%A in (
|
||||
`%git% -C "%gitdir%" log -1 --no-show-signature "--abbrev=%width%" ^
|
||||
"--date=format-local:%%FT%%TZ %%Y %%m %%d" "--format=%%h %%H %%%date_type%" "%head%" --`
|
||||
) do (
|
||||
set rev=%%I
|
||||
set dt=%%J
|
||||
set tm=%%K
|
||||
)
|
||||
if not "%dt%" == "" (
|
||||
set /a yy=%dt:-=% / 10000
|
||||
set /a mm=%dt:-=% / 100 %% 100
|
||||
set /a dd=%dt:-=% %% 100
|
||||
)
|
||||
for /f "usebackq tokens=1" %%I in (
|
||||
`git -C "%gitdir%" symbolic-ref --short HEAD`
|
||||
) do set branch=%%I
|
||||
if not "%rev%" == "" (
|
||||
echo #define RUBY_REVISION "%rev:~,10%"
|
||||
echo #define RUBY_FULL_REVISION "%rev%"
|
||||
echo #define RUBY_BRANCH_NAME "%branch%"
|
||||
echo #define RUBY_RELEASE_DATETIME "%dt%T%tm%Z"
|
||||
echo #define RUBY_RELEASE_YEAR %yy%
|
||||
echo #define RUBY_RELEASE_MONTH %mm%
|
||||
echo #define RUBY_RELEASE_DAY %dd%
|
||||
set rev=%%A
|
||||
set full=%%B
|
||||
set dt=%%C
|
||||
set yy=%%D
|
||||
set /a mm=1%%E %% 100
|
||||
set /a dd=1%%F %% 100
|
||||
)
|
||||
|
||||
if "%rev%" == "" goto :EOF
|
||||
|
||||
echo #define RUBY_REVISION "%rev%"
|
||||
echo #define RUBY_FULL_REVISION "%full%"
|
||||
echo #define RUBY_BRANCH_NAME "%branch%"
|
||||
echo #define RUBY_RELEASE_DATETIME "%dt%"
|
||||
echo #define RUBY_RELEASE_YEAR %yy%
|
||||
echo #define RUBY_RELEASE_MONTH %mm%
|
||||
echo #define RUBY_RELEASE_DAY %dd%
|
||||
|
||||
@endlocal
|
||||
Reference in new issue
Block a user