Skip to content

Commit 78b2752

Browse files
tryfix .bat
1 parent 1b3eb47 commit 78b2752

File tree

1 file changed

+56
-17
lines changed

1 file changed

+56
-17
lines changed

setup-msvc.bat

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ echo Calling vcvarsall.bat...
8282
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" %HOST_ARCH%_x64
8383

8484
:: Add a small delay to ensure environment variables are set
85-
timeout /t 2 /nobreak >nul
85+
ping 127.0.0.1 -n 3 >nul
8686

8787
:: Check if we have the required tools in common locations
8888
set "FOUND_CL=0"
@@ -97,15 +97,23 @@ if %errorLevel% equ 0 (
9797
echo cl.exe not found in PATH, checking common locations...
9898

9999
:: Check common MSVC installation paths
100-
for %%p in (
101-
"%VS_PATH%\VC\Tools\MSVC\*\bin\Hostx64\x64\cl.exe"
102-
"%VS_PATH%\VC\Tools\MSVC\*\bin\HostARM64\x64\cl.exe"
103-
"%VS_PATH%\VC\Tools\MSVC\*\bin\Hostx86\x64\cl.exe"
104-
) do (
105-
if exist "%%p" (
100+
for /d %%v in ("%VS_PATH%\VC\Tools\MSVC\*") do (
101+
if exist "%%v\bin\Hostx64\x64\cl.exe" (
106102
set "FOUND_CL=1"
107-
for %%f in ("%%p") do set "CL_PATH=%%~dpf"
108-
echo Found cl.exe at: !CL_PATH!
103+
set "CL_PATH=%%v\bin\Hostx64\x64"
104+
echo Found cl.exe at: %%v\bin\Hostx64\x64\cl.exe
105+
goto :found_cl
106+
)
107+
if exist "%%v\bin\HostARM64\x64\cl.exe" (
108+
set "FOUND_CL=1"
109+
set "CL_PATH=%%v\bin\HostARM64\x64"
110+
echo Found cl.exe at: %%v\bin\HostARM64\x64\cl.exe
111+
goto :found_cl
112+
)
113+
if exist "%%v\bin\Hostx86\x64\cl.exe" (
114+
set "FOUND_CL=1"
115+
set "CL_PATH=%%v\bin\Hostx86\x64"
116+
echo Found cl.exe at: %%v\bin\Hostx86\x64\cl.exe
109117
goto :found_cl
110118
)
111119
)
@@ -121,15 +129,23 @@ if %errorLevel% equ 0 (
121129
echo link.exe not found in PATH, checking common locations...
122130

123131
:: Check common MSVC installation paths for link.exe
124-
for %%p in (
125-
"%VS_PATH%\VC\Tools\MSVC\*\bin\Hostx64\x64\link.exe"
126-
"%VS_PATH%\VC\Tools\MSVC\*\bin\HostARM64\x64\link.exe"
127-
"%VS_PATH%\VC\Tools\MSVC\*\bin\Hostx86\x64\link.exe"
128-
) do (
129-
if exist "%%p" (
132+
for /d %%v in ("%VS_PATH%\VC\Tools\MSVC\*") do (
133+
if exist "%%v\bin\Hostx64\x64\link.exe" (
130134
set "FOUND_LINK=1"
131-
for %%f in ("%%p") do set "LINK_PATH=%%~dpf"
132-
echo Found link.exe at: !LINK_PATH!
135+
set "LINK_PATH=%%v\bin\Hostx64\x64"
136+
echo Found link.exe at: %%v\bin\Hostx64\x64\link.exe
137+
goto :found_link
138+
)
139+
if exist "%%v\bin\HostARM64\x64\link.exe" (
140+
set "FOUND_LINK=1"
141+
set "LINK_PATH=%%v\bin\HostARM64\x64"
142+
echo Found link.exe at: %%v\bin\HostARM64\x64\link.exe
143+
goto :found_link
144+
)
145+
if exist "%%v\bin\Hostx86\x64\link.exe" (
146+
set "FOUND_LINK=1"
147+
set "LINK_PATH=%%v\bin\Hostx86\x64"
148+
echo Found link.exe at: %%v\bin\Hostx86\x64\link.exe
133149
goto :found_link
134150
)
135151
)
@@ -141,6 +157,29 @@ if %errorLevel% equ 0 (
141157
if %FOUND_CL% equ 0 (
142158
echo Error: cl.exe not found in PATH or common MSVC locations
143159
echo This usually means the MSVC compiler tools are not properly installed.
160+
echo.
161+
echo Debugging information:
162+
echo VS_PATH: %VS_PATH%
163+
echo HOST_ARCH: %HOST_ARCH%
164+
echo.
165+
echo Checking if MSVC directories exist:
166+
if exist "%VS_PATH%\VC\Tools\MSVC\" (
167+
echo MSVC Tools directory exists, listing versions:
168+
dir "%VS_PATH%\VC\Tools\MSVC\" /b
169+
echo.
170+
echo Checking for cl.exe in latest version:
171+
for /f %%i in ('dir "%VS_PATH%\VC\Tools\MSVC\" /b /o-n') do (
172+
echo Checking: %VS_PATH%\VC\Tools\MSVC\%%i\bin\HostARM64\x64\cl.exe
173+
if exist "%VS_PATH%\VC\Tools\MSVC\%%i\bin\HostARM64\x64\cl.exe" (
174+
echo Found cl.exe in %%i version!
175+
)
176+
goto :break_loop
177+
)
178+
:break_loop
179+
) else (
180+
echo MSVC Tools directory does not exist at: %VS_PATH%\VC\Tools\MSVC\
181+
)
182+
echo.
144183
echo Please install Visual Studio Build Tools with C++ development tools.
145184
echo Exiting with error code 1.
146185
exit /b 1

0 commit comments

Comments
 (0)