diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index af3d48de72d2d2..38f628243ccff4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -154,30 +154,9 @@ jobs: # windows-11-arm runner cannot run `ruby tool/file2lastrev.rb --revision.h --output=revision.h` - name: make revision.h run: | - if not exist revision.h ( - for /f "tokens=1-3" %%I in ('git log -1 "--date=format-local:%%F %%T" "--format=%%H %%cd" @') do ( - set rev=%%I - set dt=%%J - set tm=%%K - ) - call set yy=%%dt:~0,4%% - call set /a mm=100%%dt:~5,2%% %%%% 100 - call set /a dd=100%%dt:~8,2%% %%%% 100 - call set branch=%%GITHUB_REF:refs/heads/=%% - ( - call echo #define RUBY_REVISION "%%rev:~,10%%" - call echo #define RUBY_FULL_REVISION "%%rev%%" - call echo #define RUBY_BRANCH_NAME "%%branch%%" - call echo #define RUBY_RELEASE_DATETIME "%%dt%%T%%tm%%" - call echo #define RUBY_RELEASE_YEAR %%yy%% - call echo #define RUBY_RELEASE_MONTH %%mm%% - call echo #define RUBY_RELEASE_DAY %%dd%% - ) > revision.h - copy /y NUL .revision.time - ) + win32\lastrev.bat | win32\ifchange.bat --timestamp=.revision.time revision.h - type revision.h - env: - TZ: UTC + working-directory: src - run: nmake diff --git a/vcpkg.json b/vcpkg.json index 7ea28de5a2da23..b8b0faf93edb1a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -7,5 +7,5 @@ "openssl", "zlib" ], - "builtin-baseline": "120deac3062162151622ca4860575a33844ba10b" + "builtin-baseline": "4334d8b4c8916018600212ab4dd4bbdc343065d1" } \ No newline at end of file diff --git a/win32/ifchange.bat b/win32/ifchange.bat index 1de98f99900d70..c7a57fad3583c4 100755 --- a/win32/ifchange.bat +++ b/win32/ifchange.bat @@ -1,54 +1,78 @@ @echo off :: usage: ifchange target temporary +:: @set PROMPT=$T:$S for %%I in (%0) do set progname=%%~nI set timestamp= set keepsuffix= set empty= set color=auto :optloop +set optarg= +:optnext for %%I in (%1) do set opt=%%~I -if "%opt%" == "--" ( - shift -) else if "%opt%" == "--timestamp" ( - set timestamp=. - shift - goto :optloop -) else if "%opt:~0,12%" == "--timestamp=" ( - set timestamp=%opt:~12% - shift - goto :optloop -) else if "%opt%" == "--keep" ( - set keepsuffix=.old - shift - goto :optloop -) else if "%opt:~0,7%" == "--keep=" ( - set keepsuffix=%opt:~7% - shift - goto :optloop -) else if "%opt%" == "--empty" ( - set empty=yes - shift - goto :optloop -) else if "%opt%" == "--color" ( - set color=always - shift - goto :optloop -) else if "%opt:~0,8%" == "--color=" ( - set color=%opt:~8% - shift - goto :optloop -) else if "%opt%" == "--debug" ( - shift - echo on - goto :optloop -) else if "%opt%" == "--help" ( - call :help - exit /b -) else if "%opt:~0,2%" == "--" ( + if not "%opt:~0,2%" == "--" ( + if not "%optarg%" == "" ( + call set %optarg%=%%opt%% + shift + goto :optloop + ) + goto :optend + ) + if "%opt%" == "--" ( + shift + goto :optend + ) + if "%opt%" == "--timestamp" ( + set timestamp=. + set optarg=timestamp + shift + goto :optnext + ) + if "%opt:~0,12%" == "--timestamp=" ( + set timestamp=%opt:~12% + shift + goto :optloop + ) + if "%opt%" == "--keep" ( + set keepsuffix=.old + set optarg=keep + shift + goto :optnext + ) + if "%opt:~0,7%" == "--keep=" ( + set keepsuffix=%opt:~7% + shift + goto :optloop + ) + if "%opt%" == "--empty" ( + set empty=yes + shift + goto :optloop + ) + if "%opt%" == "--color" ( + set color=always + set optarg=color + shift + goto :optnext + ) + if "%opt:~0,8%" == "--color=" ( + set color=%opt:~8% + shift + goto :optloop + ) + if "%opt%" == "--debug" ( + shift + echo on + goto :optloop + ) + if "%opt%" == "--help" ( + call :help + exit /b + ) echo %progname%: unknown option: %1 1>&2 exit /b 1 -) +:optend if "%2" == "" ( call :help 1>&2 @@ -60,6 +84,19 @@ set src=%2 set dest=%dest:/=\% set src=%src:/=\% +if not "%src%" == "-" goto :srcfile + if not "%TMPDIR%" == "" ( + set src=%TMPDIR%\ifchange%RANDOM%.tmp + ) else if not "%TEMP%" == "" ( + set src=%TEMP%\ifchange%RANDOM%.tmp + ) else if not "%TMP%" == "" ( + set src=%TMP%\ifchange%RANDOM%.tmp + ) else ( + set src=.\ifchange%RANDOM%.tmp + ) + findstr -r -c:"^" > "%src%" +:srcfile + if exist %dest% ( if not exist %src% goto :nt_unchanged1 if not "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged diff --git a/win32/lastrev.bat b/win32/lastrev.bat new file mode 100755 index 00000000000000..f1c799f8976f2c --- /dev/null +++ b/win32/lastrev.bat @@ -0,0 +1,29 @@ +@setlocal +@echo off +if "%1" == "" (set gitdir=.) else (set gitdir=%1) +set TZ=UTC +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` +) 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% +) +@endlocal