From 7be37fa118a6547e608dd554721df007b0ebfb1d Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 31 Oct 2019 22:45:08 +0100 Subject: Updating setvcvars.cmd and fixed error in VS2005 --HG-- branch : vs2019_support --- setvcvars.cmd | 101 ++++++++++++++++++++++++++++++++++++++------------ src/host/os_is64bit.c | 5 ++- 2 files changed, 81 insertions(+), 25 deletions(-) diff --git a/setvcvars.cmd b/setvcvars.cmd index 67062b0..f33ca81 100644 --- a/setvcvars.cmd +++ b/setvcvars.cmd @@ -1,12 +1,12 @@ @echo off @if not "%OS%"=="Windows_NT" @(echo This script requires Windows NT 4.0 or later to run properly! & goto :EOF) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -::: 2009-2018, Oliver Schneider (assarbad.net) - PUBLIC DOMAIN/CC0 +::: 2009-2019, Oliver Schneider (assarbad.net) - PUBLIC DOMAIN/CC0 ::: Available from: ::: ::: PURPOSE: This script can be used to run the vcvars32.bat/vcvarsall.bat ::: from any of the existing Visual C++ versions starting with .NET -::: (2002) through 2017 or versions (or a single version) given on +::: (2002) through 2019 or versions (or a single version) given on ::: the command line. ::: The script will try to find the newest installed VC version by ::: iterating over the space-separated (descending) list of versions @@ -25,9 +25,9 @@ setlocal & pushd . :: Toolsets (potentially) supported set SUPPORTED_TSET=amd64 x86 ia64 x86_ia64 x86_amd64 amd64_x86 x86_arm amd64_arm :: Internal representation of the version number -set SUPPORTED_VC=15.0 14.0 12.0 11.0 10.0 9.0 8.0 7.1 7.0 +set SUPPORTED_VC=16.0 15.0 14.0 12.0 11.0 10.0 9.0 8.0 7.1 7.0 :: Marketing name of the Visual Studio versions -set SUPPORTED_NICE=2017 2015 2013 2012 2010 2008 2005 2003 2002 +set SUPPORTED_NICE=2019 2017 2015 2013 2012 2010 2008 2005 2003 2002 set DEFAULT_TSET=x86 if not "%~1" == "" @( if "%~1" == "/?" goto :Help @@ -39,7 +39,7 @@ if not "%~1" == "" @( ) if defined VCVER_FRIENDLY echo This script expects a clean environment. Don't run it several times in the same instance of CMD! Or use setlocal and endlocal in your own script to limit the effect of this one.&popd&endlocal&goto :EOF set MIN_VC=7.0 -set MAX_VC=15.0 +set MAX_VC=16.0 set MIN_NICE=2002 reg /? > NUL 2>&1 || echo "REG.EXE is a prerequisite but wasn't found!" && goto :EOF set SETVCV_ERROR=0 @@ -91,20 +91,57 @@ goto :EOF setlocal ENABLEEXTENSIONS & set VCVER=%~1 :: We're not interested in overwriting an already existing value if defined VCVARS_PATH @( endlocal & goto :EOF ) -:: Now let's distinguish the "nice" version numbers (2002, ... 2017) from the internal ones +:: Now let's distinguish the "nice" version numbers (2002, ... 2019) from the internal ones set VCVER=%VCVER:vs=% -set NICEVER=%VCVER% +:: Not a "real" version number, but the marketing one (2002, ... 2019)? +if %VCVER% GEQ %MIN_NICE% call :NICE_%VCVER% > NUL 2>&1 set NUMVER=%VCVER:.0=% -echo %NUMVER% -:: Not a "real" version number, but the marketing one (2002, ... 2017)? -if "%VCVER%" geq "%MIN_NICE%" call :NICE_%VCVER% > NUL 2>&1 +set NUMVER=%NUMVER:.1=% :: Figure out the set of supported toolsets set VCVERLBL=%VCVER:.=_% +call :PRETTY_%VCVERLBL% > NUL 2>&1 call :TSET_%VCVERLBL% > NUL 2>&1 +if not defined NICEVER @( echo ERROR: This script does not know the given version Visual C++ version&endlocal&set SETVCV_ERROR=1&goto :EOF ) :: Jump over those "subs" goto :NICE_SET +:PRETTY_16_0 + set NICEVER=2019 + goto :EOF +:PRETTY_15_0 + set NICEVER=2017 + goto :EOF +:PRETTY_14_0 + set NICEVER=2015 + goto :EOF +:PRETTY_12_0 + set NICEVER=2013 + goto :EOF +:PRETTY_11_0 + set NICEVER=2012 + goto :EOF +:PRETTY_10_0 + set NICEVER=2010 + goto :EOF +:PRETTY_9_0 + set NICEVER=2008 + goto :EOF +:PRETTY_8_0 + set NICEVER=2005 + goto :EOF +:PRETTY_7_1 + set NICEVER=2003 + goto :EOF +:PRETTY_7_0 + set NICEVER=2002 + goto :EOF +:NICE_2019 + set VCVER=16.0 + set VSWHERE_RANGE=16.0,17.0 + set NEWVS=1 + goto :EOF :NICE_2017 set VCVER=15.0 + set VSWHERE_RANGE=15.0,16.0 set NEWVS=1 goto :EOF :NICE_2015 @@ -131,6 +168,7 @@ goto :NICE_SET :NICE_2002 set VCVER=7.0 goto :EOF +:TSET_16_0 :TSET_15_0 :TSET_14_0 :TSET_12_0 @@ -145,11 +183,23 @@ goto :NICE_SET set SUPPORTED_TSET=x86 ia64 amd64 x86_amd64 x86_ia64 goto :EOF :NICE_SET -echo Trying to locate Visual C++ %VCVER% ^(%VCTGT_TOOLSET%^) +echo Trying to locate Visual C++ %NICEVER% ^(= %VCVER%, %VCTGT_TOOLSET%^) :: Is it a version below 15? Then we use the old registry keys -if "%NUMVER%" lss "15" goto :OLDVS +if %NUMVER% LSS 15 goto :OLDVS echo Modern (^>=2017) Visual Studio :: This is where we intend to find the installation path in the registry +set _VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe +"%_VSWHERE%" -? > NUL 2>&1 || set _VSWHERE=vswhere.exe +"%_VSWHERE%" -? > NUL 2>&1 || goto :SKIPVSWHERE +::%VSWHERE_RANGE% +if not defined _VCINSTALLDIR @( + for /f "usebackq tokens=*" %%i in (`"%_VSWHERE%" -products * -format value -property installationPath -version %NUMVER%`) do ( + call :SetVar _VCINSTALLDIR "%%i" + ) +) +if defined _VCINSTALLDIR goto :DETECTION_FINISHED +:SKIPVSWHERE +if not "%NICEVER%" == "2017" goto :DETECTION_FINISHED set _VSINSTALLKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 if not defined _VCINSTALLDIR @( for /f "tokens=2*" %%i in ('reg query "%_VSINSTALLKEY%" /v %VCVER% 2^> NUL') do @( @@ -165,7 +215,7 @@ if not defined _VCINSTALLDIR @( ) goto :DETECTION_FINISHED :OLDVS -echo Old (^<2017) Visual Studio +:: echo Old (^<2017) Visual Studio :: The versions of Visual Studio prior to 2017 were all using this key set _VSINSTALLKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%VCVER%\Setup\VC if not defined _VCINSTALLDIR @( @@ -200,42 +250,45 @@ if not "%VCTGT_TOOLSET%" == "" @( if "%VCTGT_TOOLSET%" == "%%i" call :SetVar TEMP_SUPPORTED yes ) ) -if not "%TEMP_SUPPORTED%" == "yes" @( echo ERROR: Invalid toolset %TEMP_TOOLSET% for version %VCVER% of Visual C++&endlocal&set SETVCV_ERROR=1&goto :EOF ) +if not "%TEMP_SUPPORTED%" == "yes" @( echo ERROR: Invalid toolset %TEMP_TOOLSET% for version %VCVER% of Visual C++&endlocal&set SETVCV_ERROR=2&goto :EOF ) set VCTGT_TOOLSET=%TEMP_TOOLSET% :: Return, in case nothing was found -if not defined VCVARS_PATH @( endlocal&set SETVCV_ERROR=1&goto :EOF ) +if not defined VCVARS_PATH @( endlocal&set SETVCV_ERROR=3&goto :EOF ) :: Replace the . in the version by an underscore set VCVERLBL=%VCVER:.=_% :: Try to set a friendlier name for the Visual Studio version call :FRIENDLY_%VCVERLBL% > NUL 2>&1 :: Jump over those "subs" goto :FRIENDLY_SET +:FRIENDLY_16_0 + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] + goto :EOF :FRIENDLY_15_0 - set _VCVER=2017 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_14_0 - set _VCVER=2015 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_12_0 - set _VCVER=2013 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_11_0 - set _VCVER=2012 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_10_0 - set _VCVER=2010 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_9_0 - set _VCVER=2008 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_8_0 - set _VCVER=2005 ^[%TEMP_TOOLSET%^] + set _VCVER=%NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_7_1 - set _VCVER=.NET 2003 ^[%TEMP_TOOLSET%^] + set _VCVER=.NET %NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_7_0 - set _VCVER=.NET 2002 ^[%TEMP_TOOLSET%^] + set _VCVER=.NET %NICEVER% ^[%TEMP_TOOLSET%^] goto :EOF :FRIENDLY_SET if not defined _VCVER call :SetVar _VCVER "%VCVER%" diff --git a/src/host/os_is64bit.c b/src/host/os_is64bit.c index 2537c2e..a296981 100755 --- a/src/host/os_is64bit.c +++ b/src/host/os_is64bit.c @@ -6,6 +6,10 @@ #include "premake.h" +#if PLATFORM_WINDOWS +typedef BOOL(WINAPI* WowFuncSig)(HANDLE, PBOOL); +#endif + int os_is64bit(lua_State* L) { #if PLATFORM_WINDOWS @@ -20,7 +24,6 @@ int os_is64bit(lua_State* L) // returns false, the platform might still be 64-bit, but more // checking will need to be done on the Lua side of things. #if PLATFORM_WINDOWS - typedef BOOL(WINAPI* WowFuncSig)(HANDLE, PBOOL); if (hKrnl32) { WowFuncSig func = (WowFuncSig)GetProcAddress(hKrnl32, "IsWow64Process"); -- cgit v1.2.3