win32: Add CR to all batch files.

This reverts commit 23f9a0d655c4d405bb2397a147a1523436205486, "win32:
Strip CR from batch files", and add CR to the other batch files too.

`cmd.exe` seems to work well with LF at a glance, but sometimes `goto`
jumps to an unexpected line.  This is probably because it is looking
for the beginning of a line, assuming that all lines end with CRLF,
and as a result mistaking the `goto` operand for a label.
This commit is contained in:
Nobuyoshi Nakada 2026-01-26 15:36:04 +09:00 committed by Nobuyoshi Nakada
parent ace5b10de4
commit b839989fd2
Notes: git 2026-01-26 09:18:13 +00:00
10 changed files with 724 additions and 724 deletions

View File

@ -1,321 +1,321 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set PROMPT=$E[94m+$E[m$S
set witharg=
if "%~dp0" == "%CD%\" (
echo don't run in win32 directory.
exit /b 999
) else if "%0" == "%~nx0" (
set "WIN32DIR=%~$PATH:0"
) else if "%0" == "%~n0" (
set "WIN32DIR=%~$PATH:0"
) else (
set "WIN32DIR=%0"
)
set "WIN32DIR=%WIN32DIR:\=/%:/:"
call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%"
call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
set "WIN32DIR=%WIN32DIR:~0,-3%"
set XINCFLAGS=
set XLDFLAGS=
set pathlist=
set config_make=confargs~%RANDOM%.mak
set confargs=%config_make:.mak=.c%
echo>%config_make% # CONFIGURE
(
echo #define $ $$ //
echo !ifndef CONFIGURE_ARGS
echo #define CONFIGURE_ARGS \
) >%confargs%
:loop
set opt=%1
if "%1" == "" goto :end
if "%1" == "--debug-configure" (echo on & shift & goto :loop)
if "%1" == "--no-debug-configure" (echo off & shift & goto :loop)
if "%1" == "--prefix" goto :prefix
if "%1" == "--srcdir" goto :srcdir
if "%1" == "srcdir" goto :srcdir
if "%1" == "--target" goto :target
if "%1" == "target" goto :target
if "%1" == "--with-static-linked-ext" goto :extstatic
if "%1" == "--program-prefix" goto :pprefix
if "%1" == "--program-suffix" goto :suffix
if "%1" == "--program-transform-name" goto :transform_name
if "%1" == "--program-name" goto :installname
if "%1" == "--install-name" goto :installname
if "%1" == "--so-name" goto :soname
if "%1" == "--enable-install-doc" goto :enable-rdoc
if "%1" == "--disable-install-doc" goto :disable-rdoc
if "%1" == "--enable-install-static-library" goto :enable-lib
if "%1" == "--disable-install-static-library" goto :disable-lib
if "%1" == "--enable-debug-env" goto :enable-debug-env
if "%1" == "--disable-debug-env" goto :disable-debug-env
if "%1" == "--enable-devel" goto :enable-devel
if "%1" == "--disable-devel" goto :disable-devel
if "%1" == "--enable-rubygems" goto :enable-rubygems
if "%1" == "--disable-rubygems" goto :disable-rubygems
if "%1" == "--extout" goto :extout
if "%1" == "--path" goto :path
if "%1" == "--with-baseruby" goto :baseruby
if "%1" == "--without-baseruby" goto :nobaseruby
if "%1" == "--with-ntver" goto :ntver
if "%1" == "--with-libdir" goto :libdir
if "%1" == "--with-git" goto :git
if "%1" == "--without-git" goto :nogit
if "%1" == "--without-ext" goto :witharg
if "%1" == "--without-extensions" goto :witharg
if "%1" == "--with-opt-dir" goto :opt-dir
if "%1" == "--with-gmp" goto :gmp
if "%1" == "--with-gmp-dir" goto :gmp-dir
if "%opt:~0,10%" == "--without-" goto :withoutarg
if "%opt:~0,7%" == "--with-" goto :witharg
if "%1" == "-h" goto :help
if "%1" == "--help" goto :help
if "%opt:~0,1%" == "-" (
echo>>%confargs% %1 \
set witharg=
) else if "%witharg%" == "" (
echo>>%confargs% %1 \
) else (
echo>>%confargs% ,%1\
)
shift
goto :loop ;
:srcdir
echo>> %config_make% srcdir = %~2
echo>>%confargs% --srcdir=%2 \
shift
shift
goto :loop ;
:prefix
echo>> %config_make% prefix = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:pprefix
echo>> %config_make% PROGRAM_PREFIX = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:suffix
echo>> %config_make% PROGRAM_SUFFIX = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:installname
echo>> %config_make% RUBY_INSTALL_NAME = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:soname
echo>> %config_make% RUBY_SO_NAME = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:transform_name
shift
shift
goto :loop ;
:target
echo>> %config_make% target = %~2
echo>>%confargs% --target=%2 \
if "%~2" == "x64-mswin64" (
echo>> %config_make% TARGET_OS = mswin64
)
shift
shift
goto :loop ;
:extstatic
echo>> %config_make% EXTSTATIC = static
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-rdoc
echo>> %config_make% RDOCTARGET = rdoc
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-rdoc
echo>> %config_make% RDOCTARGET = nodoc
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-lib
echo>> %config_make% INSTALL_STATIC_LIBRARY = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-lib
echo>> %config_make% INSTALL_STATIC_LIBRARY = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-debug-env
echo>> %config_make% ENABLE_DEBUG_ENV = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-debug-env
echo>> %config_make% ENABLE_DEBUG_ENV = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-devel
echo>> %config_make% RUBY_DEVEL = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-devel
echo>> %config_make% RUBY_DEVEL = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-rubygems
echo>> %config_make% USE_RUBYGEMS = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-rubygems
echo>> %config_make% USE_RUBYGEMS = no
echo>>%confargs% %1 \
shift
goto :loop ;
:ntver
::- For version constants, see
::- https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks
set NTVER=%~2
if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" (
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
call set NTVER=%%NTVER:%%i=%%i%%
)
call set NTVER=_WIN32_WINNT_%%NTVER%%
)
echo>> %config_make% NTVER = %NTVER%
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:extout
if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2)
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:path
set pathlist=%pathlist%%~2;
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:baseruby
echo>> %config_make% HAVE_BASERUBY = yes
echo>> %config_make% BASERUBY = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:nobaseruby
echo>> %config_make% HAVE_BASERUBY = no
echo>> %config_make% BASERUBY =
echo>>%confargs% %1 \
shift
goto :loop ;
:libdir
echo>> %config_make% libdir_basename = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:git
echo>> %config_make% GIT = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:nogit
echo>> %config_make% GIT = never-use
echo>> %config_make% HAVE_GIT = no
echo>>%confargs% %1 \
shift
goto :loop ;
:gmp
echo>> %config_make% WITH_GMP = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:gmp-dir
:opt-dir
set opt=%~2
for %%I in (%opt:;= %) do (
set d=%%I
call pushd %%d:/=\%% && (
call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include
call set XLDFLAGS=%%XLDFLAGS%% -libpath:%%CD:\=/%%/lib
popd
)
)
:witharg
echo>>%confargs% %1=%2\
set witharg=1
shift
shift
goto :loop ;
:withoutarg
echo>>%confargs% %1 \
shift
goto :loop ;
:help
echo Configuration:
echo --help display this help
echo --srcdir=DIR find the sources in DIR [configure dir or `..']
echo Installation directories:
echo --prefix=PREFIX install files in PREFIX [/usr]
echo System types:
echo --target=TARGET configure for TARGET [i386-mswin32]
echo Optional Package:
echo --with-baseruby=RUBY use RUBY as baseruby [ruby]
echo --with-static-linked-ext link external modules statically
echo --with-ext="a,b,..." use extensions a, b, ...
echo --without-ext="a,b,..." ignore extensions a, b, ...
echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by `;'
echo --disable-install-doc do not install rdoc indexes during install
echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK)
echo --with-ntver=_WIN32_WINNT_XXXX
echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX
echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line.
del %confargs% %config_make%
goto :exit
:end
(
echo //
echo configure_args = CONFIGURE_ARGS
echo !endif
echo #undef $
) >> %confargs%
(
cl -EP %confargs% 2>nul | findstr "! ="
echo.
if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS%
if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS%
if NOT "%pathlist%" == "" (
call echo PATH = %%pathlist:;=/bin;%%$^(PATH^)
call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^)
call echo LIB = %%pathlist:;=/lib;%%$^(LIB^)
)
) >> %config_make%
del %confargs% > nul
nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^
config_make=%config_make% ^
MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile
:exit
@endlocal
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set PROMPT=$E[94m+$E[m$S
set witharg=
if "%~dp0" == "%CD%\" (
echo don't run in win32 directory.
exit /b 999
) else if "%0" == "%~nx0" (
set "WIN32DIR=%~$PATH:0"
) else if "%0" == "%~n0" (
set "WIN32DIR=%~$PATH:0"
) else (
set "WIN32DIR=%0"
)
set "WIN32DIR=%WIN32DIR:\=/%:/:"
call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%"
call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
set "WIN32DIR=%WIN32DIR:~0,-3%"
set XINCFLAGS=
set XLDFLAGS=
set pathlist=
set config_make=confargs~%RANDOM%.mak
set confargs=%config_make:.mak=.c%
echo>%config_make% # CONFIGURE
(
echo #define $ $$ //
echo !ifndef CONFIGURE_ARGS
echo #define CONFIGURE_ARGS \
) >%confargs%
:loop
set opt=%1
if "%1" == "" goto :end
if "%1" == "--debug-configure" (echo on & shift & goto :loop)
if "%1" == "--no-debug-configure" (echo off & shift & goto :loop)
if "%1" == "--prefix" goto :prefix
if "%1" == "--srcdir" goto :srcdir
if "%1" == "srcdir" goto :srcdir
if "%1" == "--target" goto :target
if "%1" == "target" goto :target
if "%1" == "--with-static-linked-ext" goto :extstatic
if "%1" == "--program-prefix" goto :pprefix
if "%1" == "--program-suffix" goto :suffix
if "%1" == "--program-transform-name" goto :transform_name
if "%1" == "--program-name" goto :installname
if "%1" == "--install-name" goto :installname
if "%1" == "--so-name" goto :soname
if "%1" == "--enable-install-doc" goto :enable-rdoc
if "%1" == "--disable-install-doc" goto :disable-rdoc
if "%1" == "--enable-install-static-library" goto :enable-lib
if "%1" == "--disable-install-static-library" goto :disable-lib
if "%1" == "--enable-debug-env" goto :enable-debug-env
if "%1" == "--disable-debug-env" goto :disable-debug-env
if "%1" == "--enable-devel" goto :enable-devel
if "%1" == "--disable-devel" goto :disable-devel
if "%1" == "--enable-rubygems" goto :enable-rubygems
if "%1" == "--disable-rubygems" goto :disable-rubygems
if "%1" == "--extout" goto :extout
if "%1" == "--path" goto :path
if "%1" == "--with-baseruby" goto :baseruby
if "%1" == "--without-baseruby" goto :nobaseruby
if "%1" == "--with-ntver" goto :ntver
if "%1" == "--with-libdir" goto :libdir
if "%1" == "--with-git" goto :git
if "%1" == "--without-git" goto :nogit
if "%1" == "--without-ext" goto :witharg
if "%1" == "--without-extensions" goto :witharg
if "%1" == "--with-opt-dir" goto :opt-dir
if "%1" == "--with-gmp" goto :gmp
if "%1" == "--with-gmp-dir" goto :gmp-dir
if "%opt:~0,10%" == "--without-" goto :withoutarg
if "%opt:~0,7%" == "--with-" goto :witharg
if "%1" == "-h" goto :help
if "%1" == "--help" goto :help
if "%opt:~0,1%" == "-" (
echo>>%confargs% %1 \
set witharg=
) else if "%witharg%" == "" (
echo>>%confargs% %1 \
) else (
echo>>%confargs% ,%1\
)
shift
goto :loop ;
:srcdir
echo>> %config_make% srcdir = %~2
echo>>%confargs% --srcdir=%2 \
shift
shift
goto :loop ;
:prefix
echo>> %config_make% prefix = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:pprefix
echo>> %config_make% PROGRAM_PREFIX = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:suffix
echo>> %config_make% PROGRAM_SUFFIX = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:installname
echo>> %config_make% RUBY_INSTALL_NAME = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:soname
echo>> %config_make% RUBY_SO_NAME = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:transform_name
shift
shift
goto :loop ;
:target
echo>> %config_make% target = %~2
echo>>%confargs% --target=%2 \
if "%~2" == "x64-mswin64" (
echo>> %config_make% TARGET_OS = mswin64
)
shift
shift
goto :loop ;
:extstatic
echo>> %config_make% EXTSTATIC = static
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-rdoc
echo>> %config_make% RDOCTARGET = rdoc
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-rdoc
echo>> %config_make% RDOCTARGET = nodoc
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-lib
echo>> %config_make% INSTALL_STATIC_LIBRARY = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-lib
echo>> %config_make% INSTALL_STATIC_LIBRARY = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-debug-env
echo>> %config_make% ENABLE_DEBUG_ENV = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-debug-env
echo>> %config_make% ENABLE_DEBUG_ENV = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-devel
echo>> %config_make% RUBY_DEVEL = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-devel
echo>> %config_make% RUBY_DEVEL = no
echo>>%confargs% %1 \
shift
goto :loop ;
:enable-rubygems
echo>> %config_make% USE_RUBYGEMS = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:disable-rubygems
echo>> %config_make% USE_RUBYGEMS = no
echo>>%confargs% %1 \
shift
goto :loop ;
:ntver
::- For version constants, see
::- https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks
set NTVER=%~2
if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" (
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
call set NTVER=%%NTVER:%%i=%%i%%
)
call set NTVER=_WIN32_WINNT_%%NTVER%%
)
echo>> %config_make% NTVER = %NTVER%
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:extout
if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2)
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:path
set pathlist=%pathlist%%~2;
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:baseruby
echo>> %config_make% HAVE_BASERUBY = yes
echo>> %config_make% BASERUBY = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:nobaseruby
echo>> %config_make% HAVE_BASERUBY = no
echo>> %config_make% BASERUBY =
echo>>%confargs% %1 \
shift
goto :loop ;
:libdir
echo>> %config_make% libdir_basename = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:git
echo>> %config_make% GIT = %~2
echo>>%confargs% %1=%2 \
shift
shift
goto :loop ;
:nogit
echo>> %config_make% GIT = never-use
echo>> %config_make% HAVE_GIT = no
echo>>%confargs% %1 \
shift
goto :loop ;
:gmp
echo>> %config_make% WITH_GMP = yes
echo>>%confargs% %1 \
shift
goto :loop ;
:gmp-dir
:opt-dir
set opt=%~2
for %%I in (%opt:;= %) do (
set d=%%I
call pushd %%d:/=\%% && (
call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include
call set XLDFLAGS=%%XLDFLAGS%% -libpath:%%CD:\=/%%/lib
popd
)
)
:witharg
echo>>%confargs% %1=%2\
set witharg=1
shift
shift
goto :loop ;
:withoutarg
echo>>%confargs% %1 \
shift
goto :loop ;
:help
echo Configuration:
echo --help display this help
echo --srcdir=DIR find the sources in DIR [configure dir or `..']
echo Installation directories:
echo --prefix=PREFIX install files in PREFIX [/usr]
echo System types:
echo --target=TARGET configure for TARGET [i386-mswin32]
echo Optional Package:
echo --with-baseruby=RUBY use RUBY as baseruby [ruby]
echo --with-static-linked-ext link external modules statically
echo --with-ext="a,b,..." use extensions a, b, ...
echo --without-ext="a,b,..." ignore extensions a, b, ...
echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by `;'
echo --disable-install-doc do not install rdoc indexes during install
echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK)
echo --with-ntver=_WIN32_WINNT_XXXX
echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX
echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line.
del %confargs% %config_make%
goto :exit
:end
(
echo //
echo configure_args = CONFIGURE_ARGS
echo !endif
echo #undef $
) >> %confargs%
(
cl -EP %confargs% 2>nul | findstr "! ="
echo.
if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS%
if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS%
if NOT "%pathlist%" == "" (
call echo PATH = %%pathlist:;=/bin;%%$^(PATH^)
call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^)
call echo LIB = %%pathlist:;=/lib;%%$^(LIB^)
)
) >> %config_make%
del %confargs% > nul
nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^
config_make=%config_make% ^
MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile
:exit
@endlocal

View File

@ -1,137 +1,137 @@
@echo off
:: usage: ifchange target temporary
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
:: @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 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
exit /b 1
)
set dest=%1
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
fc.exe %dest% %src% > nul && (
:nt_unchanged
del %src%
:nt_unchanged1
for %%I in (%1) do echo %%~I unchanged
goto :nt_end
)
)
for %%I in (%1) do echo %%~I updated
del /f %dest% 2> nul
copy %src% %dest% > nul
del %src%
:nt_end
if "%timestamp%" == "" goto :end
if "%timestamp%" == "." (
for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI
)
goto :end > "%timestamp%"
:help
for %%I in (
"usage: %progname% [options] target new-file"
"options:"
" --timestamp[=file] touch timestamp file. (default: prefixed with '.time')"
" under the directory of the target)"
" --keep[=suffix] keep old file with suffix. (default: '.old')"
" --empty assume unchanged if the new file is empty."
" --color[=always|auto|never] colorize output."
) do echo.%%~I
goto :eof
:end
@echo off
:: usage: ifchange target temporary
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
:: @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 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
exit /b 1
)
set dest=%1
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
fc.exe %dest% %src% > nul && (
:nt_unchanged
del %src%
:nt_unchanged1
for %%I in (%1) do echo %%~I unchanged
goto :nt_end
)
)
for %%I in (%1) do echo %%~I updated
del /f %dest% 2> nul
copy %src% %dest% > nul
del %src%
:nt_end
if "%timestamp%" == "" goto :end
if "%timestamp%" == "." (
for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI
)
goto :end > "%timestamp%"
:help
for %%I in (
"usage: %progname% [options] target new-file"
"options:"
" --timestamp[=file] touch timestamp file. (default: prefixed with '.time')"
" under the directory of the target)"
" --keep[=suffix] keep old file with suffix. (default: '.old')"
" --empty assume unchanged if the new file is empty."
" --color[=always|auto|never] colorize output."
) do echo.%%~I
goto :eof
:end

View File

@ -1,14 +1,14 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools
set components=%components% Windows11SDK.26100
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC
)
set override=--passive
for %%I in (%components%) do (
call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I
)
echo on
winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%"
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools
set components=%components% Windows11SDK.26100
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC
)
set override=--passive
for %%I in (%components%) do (
call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I
)
echo on
winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%"

View File

@ -1,29 +1,29 @@
::- Install msys packages for rubygems
::- The dependencies are taken from vcpkg.json to share the common info.
@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1
@set PROMPT=$h$e[96m$g$e[39m$s
@set script=%0
@call set "srcdir=%%script:\win32\%~nx0=%%"
@if not defined MINGW_PACKAGE_PREFIX (
::- Enable msys environment by ridk (from RubyInstaller-DevKit)
where ridk >nul 2>&1 || (
(echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2
exit /b 1
)
call ridk enable %*
echo:
) else if not "%1" == "" (
::- Switch msys environment by ridk (from RubyInstaller-DevKit)
call ridk enable %*
echo:
)
@set pkgs=
@(
for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @(
call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I"
)
) < "%srcdir%\vcpkg.json"
pacman -S --needed --noconfirm %pkgs:~1%
::- Install msys packages for rubygems
::- The dependencies are taken from vcpkg.json to share the common info.
@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1
@set PROMPT=$h$e[96m$g$e[39m$s
@set script=%0
@call set "srcdir=%%script:\win32\%~nx0=%%"
@if not defined MINGW_PACKAGE_PREFIX (
::- Enable msys environment by ridk (from RubyInstaller-DevKit)
where ridk >nul 2>&1 || (
(echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2
exit /b 1
)
call ridk enable %*
echo:
) else if not "%1" == "" (
::- Switch msys environment by ridk (from RubyInstaller-DevKit)
call ridk enable %*
echo:
)
@set pkgs=
@(
for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @(
call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I"
)
) < "%srcdir%\vcpkg.json"
pacman -S --needed --noconfirm %pkgs:~1%

View File

@ -1,30 +1,30 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
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
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
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

View File

@ -1,3 +1,3 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
for %%I in (%*) do if not exist "%%~I/." mkdir "%%~I"
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
for %%I in (%*) do if not exist "%%~I/." mkdir "%%~I"

View File

@ -1,64 +1,64 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set prog=%~n0
set dryrun=
set recursive=
set debug=
set error=0
set parent=
:optloop
if "%1" == "-f" shift
if "%1" == "-n" (shift & set "dryrun=%1" & goto :optloop)
if "%1" == "-r" (shift & set "recursive=%1" & goto :optloop)
if "%1" == "--debug" (shift & set "debug=%1" & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
:begin
if "%1" == "" goto :EOF
set p=%1
shift
set p=%p:/=\%
call :remove %p%
goto :begin
:remove
setlocal
::- Split %1 by '?' and '*', wildcard characters
for /f "usebackq delims=?* tokens=1*" %%I in ('%1') do (set "par=%%I" & set "sub=%%J")
if "%sub%" == "" goto :remove_plain
if "%sub:\=%" == "%sub%" goto :remove_plain
::- Extract the first wildcard
set "q=%1"
call set "q=%%q:%par%=%%"
set q=%q:~0,1%
::- `delims` chars at the beginning are removed in `for`
if "%sub:~0,1%" == "\" (
set "sub=%sub:~1%"
set "par=%par%%q%"
) else (
for /f "usebackq delims=\\ tokens=1*" %%I in ('%sub%') do (set "par=%par%%q%%%I" & set "sub=%%J")
)
::- Recursive search
for /d %%D in (%par%) do (
call :remove %sub% %2%%D\
)
goto :remove_end
:remove_plain
set p=%2%1
if not exist "%1" goto :remove_end
if not "%dryrun%" == "" (
echo Removing %p:\=/%
goto :remove_end
)
::- Try `rd` first for symlink to a directory; `del` attemps to remove all
::- files under the target directory, instead of the symlink itself.
(rd /q "%p%" || del /q "%p%") 2> nul && goto :remove_end
if "%recursive%" == "-r" for /D %%I in (%p%) do (
rd /s /q %%I || call set error=%%ERRORLEVEL%%
)
:remove_end
endlocal & set "error=%error%" & goto :EOF
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set prog=%~n0
set dryrun=
set recursive=
set debug=
set error=0
set parent=
:optloop
if "%1" == "-f" shift
if "%1" == "-n" (shift & set "dryrun=%1" & goto :optloop)
if "%1" == "-r" (shift & set "recursive=%1" & goto :optloop)
if "%1" == "--debug" (shift & set "debug=%1" & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
:begin
if "%1" == "" goto :EOF
set p=%1
shift
set p=%p:/=\%
call :remove %p%
goto :begin
:remove
setlocal
::- Split %1 by '?' and '*', wildcard characters
for /f "usebackq delims=?* tokens=1*" %%I in ('%1') do (set "par=%%I" & set "sub=%%J")
if "%sub%" == "" goto :remove_plain
if "%sub:\=%" == "%sub%" goto :remove_plain
::- Extract the first wildcard
set "q=%1"
call set "q=%%q:%par%=%%"
set q=%q:~0,1%
::- `delims` chars at the beginning are removed in `for`
if "%sub:~0,1%" == "\" (
set "sub=%sub:~1%"
set "par=%par%%q%"
) else (
for /f "usebackq delims=\\ tokens=1*" %%I in ('%sub%') do (set "par=%par%%q%%%I" & set "sub=%%J")
)
::- Recursive search
for /d %%D in (%par%) do (
call :remove %sub% %2%%D\
)
goto :remove_end
:remove_plain
set p=%2%1
if not exist "%1" goto :remove_end
if not "%dryrun%" == "" (
echo Removing %p:\=/%
goto :remove_end
)
::- Try `rd` first for symlink to a directory; `del` attemps to remove all
::- files under the target directory, instead of the symlink itself.
(rd /q "%p%" || del /q "%p%") 2> nul && goto :remove_end
if "%recursive%" == "-r" for /D %%I in (%p%) do (
rd /s /q %%I || call set error=%%ERRORLEVEL%%
)
:remove_end
endlocal & set "error=%error%" & goto :EOF

View File

@ -1,34 +1,34 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set parents=1
:optloop
if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
if "%1" == "-p" (shift & (set parents=1) & goto :optloop)
:begin
if "%1" == "" goto :end
set dir=%1
shift
set dir=%dir:/=\%
:rmdirs
if /%dir:~-2%/ == /\./ set dir=%dir:~0,-2%
if not exist "%dir%\." goto :begin
if "%dir%" == "." goto :begin
if "%dir%" == ".." goto :begin
rd "%dir%" 2> nul || goto :begin
if "%parents%" == "" goto :begin
:trim_sep
if not /%dir:~-1%/ == /\/ goto :trim_base
set dir=%dir:~0,-1%
if not "%dir%" == "" goto :trim_sep
:trim_base
if /%dir:~-1%/ == /\/ goto :parent
set dir=%dir:~0,-1%
if not "%dir%" == "" goto :trim_base
:parent
set dir=%dir:~0,-1%
if "%dir%" == "" goto :begin
if "%dir:~-1%" == ":" goto :begin
goto :rmdirs
shift
goto :begin
:end
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set parents=1
:optloop
if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
if "%1" == "-p" (shift & (set parents=1) & goto :optloop)
:begin
if "%1" == "" goto :end
set dir=%1
shift
set dir=%dir:/=\%
:rmdirs
if /%dir:~-2%/ == /\./ set dir=%dir:~0,-2%
if not exist "%dir%\." goto :begin
if "%dir%" == "." goto :begin
if "%dir%" == ".." goto :begin
rd "%dir%" 2> nul || goto :begin
if "%parents%" == "" goto :begin
:trim_sep
if not /%dir:~-1%/ == /\/ goto :trim_base
set dir=%dir:~0,-1%
if not "%dir%" == "" goto :trim_sep
:trim_base
if /%dir:~-1%/ == /\/ goto :parent
set dir=%dir:~0,-1%
if not "%dir%" == "" goto :trim_base
:parent
set dir=%dir:~0,-1%
if "%dir%" == "" goto :begin
if "%dir:~-1%" == ":" goto :begin
goto :rmdirs
shift
goto :begin
:end

View File

@ -1,36 +1,36 @@
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set rt=
set rtver=
set osver=
for /f "usebackq" %%I in (`
dumpbin -dependents %1 ^|
findstr -r -i -c:"\<vcruntime.*\.dll$" -c:"\<msvcr.*\.dll$"
`) do (
set rt=%%~nI
)
for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @(
::- downcase
call set rt=%%rt:%%i=%%i%%
)
if "%rt%" == "msvcrt" (
call set rtver=60
) else if "%rt:~0,5%" == "msvcr" (
call set rtver=%%rt:msvcr=%%
call set osver=_%%rtver%%
) else if "%rt:~0,9%" == "vcruntime" (
call set rtver=%%rt:vcruntime=%%
call set osver=_%%rtver%%
) else (
(echo %0: %1 is not linked to msvcrt nor vcruntime) 1>&2
exit 1
)
for %%I in (
"PLATFORM = $(TARGET_OS)%osver%"
"RT = %rt%"
"RT_VER = %rtver%"
) do @(
echo %%~I
)
@echo off
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
set rt=
set rtver=
set osver=
for /f "usebackq" %%I in (`
dumpbin -dependents %1 ^|
findstr -r -i -c:"\<vcruntime.*\.dll$" -c:"\<msvcr.*\.dll$"
`) do (
set rt=%%~nI
)
for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @(
::- downcase
call set rt=%%rt:%%i=%%i%%
)
if "%rt%" == "msvcrt" (
call set rtver=60
) else if "%rt:~0,5%" == "msvcr" (
call set rtver=%%rt:msvcr=%%
call set osver=_%%rtver%%
) else if "%rt:~0,9%" == "vcruntime" (
call set rtver=%%rt:vcruntime=%%
call set osver=_%%rtver%%
) else (
(echo %0: %1 is not linked to msvcrt nor vcruntime) 1>&2
exit 1
)
for %%I in (
"PLATFORM = $(TARGET_OS)%osver%"
"RT = %rt%"
"RT_VER = %rtver%"
) do @(
echo %%~I
)

View File

@ -1,56 +1,56 @@
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
::- do not `echo off` that affects the called batch files
::- check for vswhere
@set vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
@if not exist "%vswhere%" (
echo 1>&2 vswhere.exe not found
exit /b 1
)
::- find the latest build tool and its setup batch file.
@set VSDEVCMD=
@set VSDEV_ARGS=
@set where_opt=
@set arch=
:argloop
@(set arg=%1) & if defined arg (shift) else (goto :argend)
@if "%arg%" == "-prerelease" (
set where_opt=-prerelease
goto :argloop
)
@if /i "%arg%" == "-arch" (
set arch=%1
shift
goto :argloop
)
@if /i "%arg:~0,6%" == "-arch=" (
set arch=%arg:~6%
goto :argloop
)
@set VSDEV_ARGS=%VSDEV_ARGS% %arg%
@goto :argloop
:argend
@if defined VSDEV_ARGS set VSDEV_ARGS=%VSDEV_ARGS:~1%
@for /f "delims=" %%I in ('"%vswhere%" -products * -latest -property installationPath %where_opt%') do @(
set VSDEVCMD=%%I\Common7\Tools\VsDevCmd.bat
)
@if not defined VSDEVCMD (
echo 1>&2 Visual Studio not found
exit /b 1
)
::- default to the current processor.
@set host_arch=%PROCESSOR_ARCHITECTURE%
@if not defined arch set arch=%PROCESSOR_ARCHITECTURE%
::- `vsdevcmd.bat` requires arch names to be lowercase
@for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @(
call set arch=%%arch:%%i=%%i%%
call set host_arch=%%host_arch:%%i=%%i%%
)
@if "%arch%" == "x86_64" set arch=amd64
::- chain to `vsdevcmd.bat`
@(endlocal && "%VSDEVCMD%" -arch=%arch% -host_arch=%host_arch% %VSDEV_ARGS%)
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
::- do not `echo off` that affects the called batch files
::- check for vswhere
@set vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
@if not exist "%vswhere%" (
echo 1>&2 vswhere.exe not found
exit /b 1
)
::- find the latest build tool and its setup batch file.
@set VSDEVCMD=
@set VSDEV_ARGS=
@set where_opt=
@set arch=
:argloop
@(set arg=%1) & if defined arg (shift) else (goto :argend)
@if "%arg%" == "-prerelease" (
set where_opt=-prerelease
goto :argloop
)
@if /i "%arg%" == "-arch" (
set arch=%1
shift
goto :argloop
)
@if /i "%arg:~0,6%" == "-arch=" (
set arch=%arg:~6%
goto :argloop
)
@set VSDEV_ARGS=%VSDEV_ARGS% %arg%
@goto :argloop
:argend
@if defined VSDEV_ARGS set VSDEV_ARGS=%VSDEV_ARGS:~1%
@for /f "delims=" %%I in ('"%vswhere%" -products * -latest -property installationPath %where_opt%') do @(
set VSDEVCMD=%%I\Common7\Tools\VsDevCmd.bat
)
@if not defined VSDEVCMD (
echo 1>&2 Visual Studio not found
exit /b 1
)
::- default to the current processor.
@set host_arch=%PROCESSOR_ARCHITECTURE%
@if not defined arch set arch=%PROCESSOR_ARCHITECTURE%
::- `vsdevcmd.bat` requires arch names to be lowercase
@for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @(
call set arch=%%arch:%%i=%%i%%
call set host_arch=%%host_arch:%%i=%%i%%
)
@if "%arch%" == "x86_64" set arch=amd64
::- chain to `vsdevcmd.bat`
@(endlocal && "%VSDEVCMD%" -arch=%arch% -host_arch=%host_arch% %VSDEV_ARGS%)