Skip to content

Commit b839989

Browse files
committed
win32: Add CR to all batch files.
This reverts commit 23f9a0d, "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.
1 parent ace5b10 commit b839989

10 files changed

Lines changed: 724 additions & 724 deletions

win32/configure.bat

Lines changed: 321 additions & 321 deletions
Large diffs are not rendered by default.

win32/ifchange.bat

Lines changed: 137 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,137 @@
1-
@echo off
2-
:: usage: ifchange target temporary
3-
4-
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
5-
6-
:: @set PROMPT=$T:$S
7-
for %%I in (%0) do set progname=%%~nI
8-
set timestamp=
9-
set keepsuffix=
10-
set empty=
11-
set color=auto
12-
:optloop
13-
set optarg=
14-
:optnext
15-
for %%I in (%1) do set opt=%%~I
16-
if not "%opt:~0,2%" == "--" (
17-
if not "%optarg%" == "" (
18-
call set %optarg%=%%opt%%
19-
shift
20-
goto :optloop
21-
)
22-
goto :optend
23-
)
24-
if "%opt%" == "--" (
25-
shift
26-
goto :optend
27-
)
28-
if "%opt%" == "--timestamp" (
29-
set timestamp=.
30-
set optarg=timestamp
31-
shift
32-
goto :optnext
33-
)
34-
if "%opt:~0,12%" == "--timestamp=" (
35-
set timestamp=%opt:~12%
36-
shift
37-
goto :optloop
38-
)
39-
if "%opt%" == "--keep" (
40-
set keepsuffix=.old
41-
set optarg=keep
42-
shift
43-
goto :optnext
44-
)
45-
if "%opt:~0,7%" == "--keep=" (
46-
set keepsuffix=%opt:~7%
47-
shift
48-
goto :optloop
49-
)
50-
if "%opt%" == "--empty" (
51-
set empty=yes
52-
shift
53-
goto :optloop
54-
)
55-
if "%opt%" == "--color" (
56-
set color=always
57-
set optarg=color
58-
shift
59-
goto :optnext
60-
)
61-
if "%opt:~0,8%" == "--color=" (
62-
set color=%opt:~8%
63-
shift
64-
goto :optloop
65-
)
66-
if "%opt%" == "--debug" (
67-
shift
68-
echo on
69-
goto :optloop
70-
)
71-
if "%opt%" == "--help" (
72-
call :help
73-
exit /b
74-
)
75-
echo %progname%: unknown option: %1 1>&2
76-
exit /b 1
77-
:optend
78-
79-
if "%2" == "" (
80-
call :help 1>&2
81-
exit /b 1
82-
)
83-
84-
set dest=%1
85-
set src=%2
86-
set dest=%dest:/=\%
87-
set src=%src:/=\%
88-
89-
if not "%src%" == "-" goto :srcfile
90-
if not "%TMPDIR%" == "" (
91-
set src=%TMPDIR%\ifchange%RANDOM%.tmp
92-
) else if not "%TEMP%" == "" (
93-
set src=%TEMP%\ifchange%RANDOM%.tmp
94-
) else if not "%TMP%" == "" (
95-
set src=%TMP%\ifchange%RANDOM%.tmp
96-
) else (
97-
set src=.\ifchange%RANDOM%.tmp
98-
)
99-
findstr -r -c:"^" > "%src%"
100-
:srcfile
101-
102-
if exist %dest% (
103-
if not exist %src% goto :nt_unchanged1
104-
if not "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged
105-
fc.exe %dest% %src% > nul && (
106-
:nt_unchanged
107-
del %src%
108-
:nt_unchanged1
109-
for %%I in (%1) do echo %%~I unchanged
110-
goto :nt_end
111-
)
112-
)
113-
for %%I in (%1) do echo %%~I updated
114-
del /f %dest% 2> nul
115-
copy %src% %dest% > nul
116-
del %src%
117-
118-
:nt_end
119-
if "%timestamp%" == "" goto :end
120-
if "%timestamp%" == "." (
121-
for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI
122-
)
123-
goto :end > "%timestamp%"
124-
125-
:help
126-
for %%I in (
127-
"usage: %progname% [options] target new-file"
128-
"options:"
129-
" --timestamp[=file] touch timestamp file. (default: prefixed with '.time')"
130-
" under the directory of the target)"
131-
" --keep[=suffix] keep old file with suffix. (default: '.old')"
132-
" --empty assume unchanged if the new file is empty."
133-
" --color[=always|auto|never] colorize output."
134-
) do echo.%%~I
135-
goto :eof
136-
137-
:end
1+
@echo off
2+
:: usage: ifchange target temporary
3+
4+
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
5+
6+
:: @set PROMPT=$T:$S
7+
for %%I in (%0) do set progname=%%~nI
8+
set timestamp=
9+
set keepsuffix=
10+
set empty=
11+
set color=auto
12+
:optloop
13+
set optarg=
14+
:optnext
15+
for %%I in (%1) do set opt=%%~I
16+
if not "%opt:~0,2%" == "--" (
17+
if not "%optarg%" == "" (
18+
call set %optarg%=%%opt%%
19+
shift
20+
goto :optloop
21+
)
22+
goto :optend
23+
)
24+
if "%opt%" == "--" (
25+
shift
26+
goto :optend
27+
)
28+
if "%opt%" == "--timestamp" (
29+
set timestamp=.
30+
set optarg=timestamp
31+
shift
32+
goto :optnext
33+
)
34+
if "%opt:~0,12%" == "--timestamp=" (
35+
set timestamp=%opt:~12%
36+
shift
37+
goto :optloop
38+
)
39+
if "%opt%" == "--keep" (
40+
set keepsuffix=.old
41+
set optarg=keep
42+
shift
43+
goto :optnext
44+
)
45+
if "%opt:~0,7%" == "--keep=" (
46+
set keepsuffix=%opt:~7%
47+
shift
48+
goto :optloop
49+
)
50+
if "%opt%" == "--empty" (
51+
set empty=yes
52+
shift
53+
goto :optloop
54+
)
55+
if "%opt%" == "--color" (
56+
set color=always
57+
set optarg=color
58+
shift
59+
goto :optnext
60+
)
61+
if "%opt:~0,8%" == "--color=" (
62+
set color=%opt:~8%
63+
shift
64+
goto :optloop
65+
)
66+
if "%opt%" == "--debug" (
67+
shift
68+
echo on
69+
goto :optloop
70+
)
71+
if "%opt%" == "--help" (
72+
call :help
73+
exit /b
74+
)
75+
echo %progname%: unknown option: %1 1>&2
76+
exit /b 1
77+
:optend
78+
79+
if "%2" == "" (
80+
call :help 1>&2
81+
exit /b 1
82+
)
83+
84+
set dest=%1
85+
set src=%2
86+
set dest=%dest:/=\%
87+
set src=%src:/=\%
88+
89+
if not "%src%" == "-" goto :srcfile
90+
if not "%TMPDIR%" == "" (
91+
set src=%TMPDIR%\ifchange%RANDOM%.tmp
92+
) else if not "%TEMP%" == "" (
93+
set src=%TEMP%\ifchange%RANDOM%.tmp
94+
) else if not "%TMP%" == "" (
95+
set src=%TMP%\ifchange%RANDOM%.tmp
96+
) else (
97+
set src=.\ifchange%RANDOM%.tmp
98+
)
99+
findstr -r -c:"^" > "%src%"
100+
:srcfile
101+
102+
if exist %dest% (
103+
if not exist %src% goto :nt_unchanged1
104+
if not "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged
105+
fc.exe %dest% %src% > nul && (
106+
:nt_unchanged
107+
del %src%
108+
:nt_unchanged1
109+
for %%I in (%1) do echo %%~I unchanged
110+
goto :nt_end
111+
)
112+
)
113+
for %%I in (%1) do echo %%~I updated
114+
del /f %dest% 2> nul
115+
copy %src% %dest% > nul
116+
del %src%
117+
118+
:nt_end
119+
if "%timestamp%" == "" goto :end
120+
if "%timestamp%" == "." (
121+
for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI
122+
)
123+
goto :end > "%timestamp%"
124+
125+
:help
126+
for %%I in (
127+
"usage: %progname% [options] target new-file"
128+
"options:"
129+
" --timestamp[=file] touch timestamp file. (default: prefixed with '.time')"
130+
" under the directory of the target)"
131+
" --keep[=suffix] keep old file with suffix. (default: '.old')"
132+
" --empty assume unchanged if the new file is empty."
133+
" --color[=always|auto|never] colorize output."
134+
) do echo.%%~I
135+
goto :eof
136+
137+
:end

win32/install-buildtools.cmd

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
@echo off
2-
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
3-
4-
set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools
5-
set components=%components% Windows11SDK.26100
6-
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
7-
set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC
8-
)
9-
set override=--passive
10-
for %%I in (%components%) do (
11-
call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I
12-
)
13-
echo on
14-
winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%"
1+
@echo off
2+
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
3+
4+
set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools
5+
set components=%components% Windows11SDK.26100
6+
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
7+
set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC
8+
)
9+
set override=--passive
10+
for %%I in (%components%) do (
11+
call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I
12+
)
13+
echo on
14+
winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%"

win32/install-msys-packages.cmd

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
::- Install msys packages for rubygems
2-
::- The dependencies are taken from vcpkg.json to share the common info.
3-
4-
@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1
5-
@set PROMPT=$h$e[96m$g$e[39m$s
6-
@set script=%0
7-
@call set "srcdir=%%script:\win32\%~nx0=%%"
8-
9-
@if not defined MINGW_PACKAGE_PREFIX (
10-
::- Enable msys environment by ridk (from RubyInstaller-DevKit)
11-
where ridk >nul 2>&1 || (
12-
(echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2
13-
exit /b 1
14-
)
15-
call ridk enable %*
16-
echo:
17-
) else if not "%1" == "" (
18-
::- Switch msys environment by ridk (from RubyInstaller-DevKit)
19-
call ridk enable %*
20-
echo:
21-
)
22-
23-
@set pkgs=
24-
@(
25-
for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @(
26-
call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I"
27-
)
28-
) < "%srcdir%\vcpkg.json"
29-
pacman -S --needed --noconfirm %pkgs:~1%
1+
::- Install msys packages for rubygems
2+
::- The dependencies are taken from vcpkg.json to share the common info.
3+
4+
@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1
5+
@set PROMPT=$h$e[96m$g$e[39m$s
6+
@set script=%0
7+
@call set "srcdir=%%script:\win32\%~nx0=%%"
8+
9+
@if not defined MINGW_PACKAGE_PREFIX (
10+
::- Enable msys environment by ridk (from RubyInstaller-DevKit)
11+
where ridk >nul 2>&1 || (
12+
(echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2
13+
exit /b 1
14+
)
15+
call ridk enable %*
16+
echo:
17+
) else if not "%1" == "" (
18+
::- Switch msys environment by ridk (from RubyInstaller-DevKit)
19+
call ridk enable %*
20+
echo:
21+
)
22+
23+
@set pkgs=
24+
@(
25+
for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @(
26+
call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I"
27+
)
28+
) < "%srcdir%\vcpkg.json"
29+
pacman -S --needed --noconfirm %pkgs:~1%

0 commit comments

Comments
 (0)