Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adsk Contrib - Improve Windows batch files to find installed Visual Studio location #1980

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions share/dev/windows/ocio.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ set INSTALL_PATH_OK=n
rem Python location
set PYTHON_PATH=

rem Microsoft Visual Studio path
set MSVS_PATH=%programfiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
rem Microsoft Visual Studio path (will auto-find if not passed in cmd args)
set MSVS_PATH=

set DO_CONFIGURE=0

Expand Down Expand Up @@ -75,6 +75,22 @@ if NOT "%~1"=="" (
goto :args_loop
)

rem If not overridden by the cmd line args, find and use the latest Visual Studio
if NOT DEFINED MSVS_PATH (
for /f %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -format value -property installationPath -latest') do (
echo Found Visual Studio installation at '%%i'
set MSVS_PATH=%%i
)
)

IF NOT EXIST "!MSVS_PATH!" (
echo Could not find MS Visual Studio. Please provide the location for Microsoft Visual Studio vcvars64.bat or modify MSVS_PATH in the script.
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "--msvs <path>"
echo E.g. C:\Program Files\Microsoft Visual Studio\2022\Enterprise\
exit /b
)

rem Testing the path before cmake
IF NOT EXIST "!VCPKG_PATH!" (
echo Could not find Vcpkg. Please provide the location for vcpkg or modify VCPKG_PATH in this script.
Expand Down Expand Up @@ -103,14 +119,6 @@ if NOT EXIST "!PYTHON_PATH!\python.exe" (
)
)

IF NOT EXIST "!MSVS_PATH!" (
echo Could not find MS Visual Studio. Please provide the location for Microsoft Visual Studio vcvars64.bat or modify MSVS_PATH in the script.
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "--msvs <path>"
echo E.g. C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
exit /b
)

if !CUSTOM_BUILD_PATH!==0 (
echo.
set /p BUILD_PATH_OK=Default build path [!BUILD_PATH!] is used. Is it ok? [y/n]:
Expand Down Expand Up @@ -139,7 +147,7 @@ set INSTALL_PATH=!INSTALL_PATH!\!CMAKE_BUILD_TYPE!

rem ****************************************************************************************************************
rem Setting up the environment using MS Visual Studio batch script
set VCVARS64_PATH="!MSVS_PATH!\vcvars64.bat"
set VCVARS64_PATH="!MSVS_PATH!\VC\Auxiliary\Build\vcvars64.bat"
IF NOT EXIST !VCVARS64_PATH! (
rem Checking for vcvars64.bat script.
rem !MSVS_PATH! is checked earlier in the script
Expand Down Expand Up @@ -295,8 +303,8 @@ echo.
echo Optional options depending on the environment:
echo --python Python installation location
echo.
echo --msvs path where to find vcvars64.bat from Microsoft Visual Studio
echo Default: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
echo --msvs Root folder of the Microsoft Visual Studio. (E.g. C:\Program Files\Microsoft Visual Studio\2022)
echo Default: installation path of the latest Visual Studio found in the system by the vswhere.exe tool.
echo.
echo --b build location
echo Default: %TEMP%\OCIO\build
Expand Down
14 changes: 6 additions & 8 deletions share/dev/windows/ocio_deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,14 @@ if ErrorLevel 1 (
)

echo Checking for Microsoft Visual Studio...
set MSVS=0
for /d %%a in ("%programfiles%\Microsoft Visual Studio*") do (
for /f "tokens=3 delims=\" %%x in ("%%a") do set MSVS=1
set MSVS_PATH=
for /f %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -format value -property installationPath -latest') do (
echo Found Visual Studio installation at '%%i'
set MSVS_PATH=%%i
)

if !MSVS!==0 (
echo No Microsoft Visual Studio installation was found in !programfiles!.
echo For non-standard installation path, please use the following option:
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "ocio_deps --vs <path>"
if NOT EXIST !MSVS_PATH! (
echo No Microsoft Visual Studio installation was found in the system.
exit /b
)

Expand Down
Loading