Skip to content

Commit

Permalink
Fix some issues in windows toolchain script (#6)
Browse files Browse the repository at this point in the history
Fix some issues in toolchain.ps1:
- python 3.9 is installed by default now but the script still checks python 3.8 install path to determine the installation result;
- MSVC can be installed using `vs_buildtools.exe` from command line. In such case, `vswhere.exe` is not applicable. Thus, update the script to support pre-configured `VS_HOME` ENV.
  • Loading branch information
toothache authored Dec 8, 2020
1 parent f365907 commit 9edaaca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions win/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1647,3 +1647,5 @@ $RECYCLE.BIN/


# End of https://www.gitignore.io/api/c,svn,c++,cvs,vim,tex,java,ninja,xcode,maven,macos,linux,latex,emacs,clion,cmake,matlab,python,csharp,eclipse,android,windows,pycharm,intellij,notepadpp,autotools,mercurial,jetbrains,powershell,objective-c,sublimetext,libreoffice,tortoisegit,visualstudio,microsoftoffice,jupyternotebook,visualstudiocode

!pkgs/env
34 changes: 30 additions & 4 deletions win/pkgs/env/toolchain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if (-Not $Env:ROASTER_TOOLCHAIN_COMMITED)

if (${Env:PYTHONHOME} -eq $null -or -not $(Test-Path ${Env:PYTHONHOME}/python.exe -ErrorAction SilentlyContinue))
{
${Env:PYTHONHOME} = Join-Path ${Env:ProgramFiles} Python38
${Env:PYTHONHOME} = Join-Path ${Env:ProgramFiles} Python39
}

if (${Env:PYTHONHOME} -eq $null -or -not $(Test-Path ${Env:PYTHONHOME}/python.exe -ErrorAction SilentlyContinue))
Expand All @@ -105,9 +105,9 @@ if (-Not $Env:ROASTER_TOOLCHAIN_COMMITED)
Invoke-WebRequest -Uri $DownloadURL -OutFile $DownloadPath
Write-Host "Installing Python..."
& $DownloadPath /passive InstallAllUsers=1 PrependPath=1 | Out-Null
if ($(Test-Path ${Env:ProgramFiles}/Python38/python.exe -ErrorAction SilentlyContinue))
if ($(Test-Path ${Env:ProgramFiles}/Python39/python.exe -ErrorAction SilentlyContinue))
{
${Env:PYTHONHOME} = Join-Path ${Env:ProgramFiles} Python38
${Env:PYTHONHOME} = Join-Path ${Env:ProgramFiles} Python39
Write-Host "Python installed successfully."
}
else
Expand Down Expand Up @@ -169,8 +169,34 @@ if (-Not $Env:ROASTER_TOOLCHAIN_COMMITED)

if (${Env:VSCMD_VER} -eq $null)
{
${VS_HOME} = & "${Env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -property installationPath
${VS_HOME} = & "${Env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" `
-latest `
-products * `
-property installationPath `
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64

$vcvars_script = "${VS_HOME}/VC/Auxiliary/Build/vcvarsall.bat"
if (-Not (Test-Path $vcvars_script))
{
Write-Host "Unable to locate Visual Studio command file: vcvarsall.bat. This is required for VC env import."
Exit 1
}

Invoke-Expression $($(cmd /c "`"${VS_HOME}/VC/Auxiliary/Build/vcvarsall.bat`" x64 10.0.16299.0 & set") -Match '^.+=' -Replace '^','${Env:' -Replace '=','}="' -Replace '$','"' | Out-String)

if ((${Env:VCToolsVersion} -eq $null) -or -not ${Env:VCToolsVersion}.StartsWith("14.2"))
{
# MSVC internal version numbering
# https://en.wikipedia.org/wiki/Microsoft_Visual_C++
Write-Host "Invalid MSVC version: ${Env:VCToolsVersion}. vc142 is expetced."
Exit 1
}

if ((${Env:WindowsSDKVersion} -eq $null) -or -not ${Env:WindowsSDKVersion}.StartsWith("10.0.16299.0"))
{
Write-Host "Invalid WinSDK version: ${Env:WindowsSDKVersion}, 10.0.16299.0 (Redstone3) is expetced."
Exit 1
}
}
}

Expand Down

0 comments on commit 9edaaca

Please sign in to comment.