-@echo on\r
+@echo off\r
setlocal enabledelayedexpansion\r
\r
if "%1"=="" goto usage\r
REM https://github.com/swig/swig/issues/769\r
\r
\r
-REM You need to modify the paths below:\r
-set vsdevcmd=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat\r
+set vsdevcmd=\r
+set vs_2019_prefix=C:\Program Files (x86)\Microsoft Visual Studio\2019\r
+:: try potential activated visual studio, then 2019, with different editions\r
+call :find_visual_studio "%VSINSTALLDIR%"\r
+call :find_visual_studio "%vs_2019_prefix%\Enterprise"\r
+call :find_visual_studio "%vs_2019_prefix%\Professional"\r
+call :find_visual_studio "%vs_2019_prefix%\Community"\r
+call :find_visual_studio "%vs_2019_prefix%\BuildTools"\r
+if not exist "%vsdevcmd%" (\r
+ echo Can't find any installation of Visual Studio\r
+ exit /b 1\r
+)\r
+echo Using VS devcmd: %vsdevcmd%\r
\r
+:: start echoing what we do\r
+@echo on\r
set python32_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310-32\r
set python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\r
\r
:parse_args_done\r
exit /b 0\r
::==============================================================================\r
+:find_visual_studio\r
+set "vs_install=%~1"\r
+if "%vs_install%" == "" exit /b 1\r
+\r
+if "%vsdevcmd%" NEQ "" exit /b 0 :: already found\r
+\r
+set "candidate=%vs_install%\Common7\Tools\VsDevCmd.bat"\r
+echo trying VS devcmd: %candidate%\r
+if exist "%candidate%" set "vsdevcmd=%candidate%"\r
+exit /b 0\r