1 :: Script will setup environment variables directly in callers environment.
3 :: If we are running from none Windows shell we will need to restore a clean PATH
4 :: before setting up VS MSVC build environment. If not there is a risk we will pick up
5 :: for example cygwin binaries when running toolchain commands not explicitly setup by
6 :: VS MSVC build environment.
9 if "%SHELL%" == "/bin/bash" (
10 for /f "tokens=2,*" %%a in ('%WINDIR%\System32\reg.exe query "HKCU\Environment" /v "Path" ^| %WINDIR%\System32\find.exe /i "REG_"') do (
13 for /f "tokens=2,*" %%a in ('%WINDIR%\System32\reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" ^| %WINDIR%\System32\find.exe /i "REG_"') do (
18 :: Restore default path, if we are running from none Windows shell.
19 if "%SHELL%" == "/bin/bash" (
20 call :restore_default_path "%HKCU_ENV_PATH%" "%HKLM_ENV_PATH%"
23 :: There is still a scenario where the default path can include cygwin\bin folder. If that's the case
24 :: there is still a big risk that build tools will be incorrectly resolved towards cygwin bin folder.
25 :: Make sure to adjust path and drop all cygwin paths.
27 call where /Q "cygpath.exe" && (
28 echo Warning, PATH includes cygwin bin folders. This can cause build errors due to incorrectly
29 echo located build tools. Build script will drop all cygwin folders from used PATH.
30 for %%a in ("%PATH:;=";"%") do (
31 if not exist "%%~a\cygpath.exe" (
32 call :add_to_new_path "%%~a"
37 if not "%NEW_PATH%" == "" (
45 :: Restore default PATH.
58 if "%NEW_PATH%" == "" (
61 SET "NEW_PATH=%NEW_PATH%;%~1"