ajkhoury / LLVM-Build-Windows

38 stars 10 forks source link

Add support for VS2019 #2

Open zosrothko opened 3 years ago

zosrothko commented 3 years ago

Hello Aidan

I tried to add the support of VS2019 version of VisualStudio but there is too much side effect I do not know. So I would prefer you to add it to be sure that there would be no regression on some use cases.

Also, there is a need to force which version of VS to use in case of multiple VS installation. I would suggest you to add the -vs=(120|140|150|160)keyword.

Below is a snipet of one of mine

rem -version ^^[16.0^^,17.0^^)
set VS_VERSION=vs%1
rem  should be set "VSWHERE='%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe  -property installationPath -version ^[16.0^,17.0^)'"
if %VS_VERSION%==vs2019 (
  set "VSWHERE='C:\PROGRA~2\"Microsoft Visual Studio"\Installer\vswhere.exe  -latest -property installationPath -version ^[16.0^,17.0^)'"
) else (
if %VS_VERSION%==vs2017 (
  set "VSWHERE='C:\PROGRA~2\"Microsoft Visual Studio"\Installer\vswhere.exe  -latest -property installationPath -version ^[15.0^,16.0^)'"
)
)
for /f " delims=" %%a in (%VSWHERE%) do @set "VSCOMNTOOLS=%%a"

echo ============= %VSCOMNTOOLS% =============

if %VS_VERSION%==vs2019 (
  set VS_VARSALL=..\..\VC\Auxiliary\Build\vcvarsall.bat
  set "VS160COMNTOOLS=%VSCOMNTOOLS%\Common7\Tools\"
) else (
  if %VS_VERSION%==vs2017 (
    set VS_VARSALL=..\..\VC\Auxiliary\Build\vcvarsall.bat
    set "VS150COMNTOOLS=%VSCOMNTOOLS%\Common7\Tools\"
  ) else (
    set VS_VARSALL=..\..\VC\vcvarsall.bat
  )
)

if not defined VCINSTALLDIR (
  if %VS_VERSION%==vs2015 (
    if %PLATFORM%==x64 (
      call "%VS140COMNTOOLS%%VS_VARSALL%" x86_amd64 8.1
    ) else (
      call "%VS140COMNTOOLS%%VS_VARSALL%" x86 8.1
    )
  ) else (
    if %VS_VERSION%==vs2017 (
      if %PLATFORM%==x64 (
        call "%VS150COMNTOOLS%%VS_VARSALL%" x86_amd64 8.1
      ) else (
        call "%VS150COMNTOOLS%%VS_VARSALL%" x86 8.1
      )
    ) else (
      if %VS_VERSION%==vs2019 (
        if %PLATFORM%==x64 (
          call "%VS160COMNTOOLS%%VS_VARSALL%" x86_amd64 8.1
        ) else (
          call "%VS160COMNTOOLS%%VS_VARSALL%" x86 8.1
        )
      )
    )
  )
)

if not defined VSINSTALLDIR (
  echo Error: No Visual C++ environment found.
  echo Please run this script from a Visual Studio Command Prompt
  echo or run "%%VSnnCOMNTOOLS%%\vsvars32.bat" first.
  goto :buildfailed
)
harrisonGPU commented 1 year ago

@ajkhoury please add this comment in your project! Thanks!