win32: add Power Shell script to set env vars

The added PS script runs msvcprep.bat in a sub shell then reads the environment
variables line by line and sets them in the current shell.
This commit is contained in:
Bogdan Popa 2020-07-14 15:52:18 +03:00 committed by GitHub
parent 24e226a540
commit 3e08f50944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -21,6 +21,10 @@ tries to find Visual Studio and run its "vcvarsall.bat". Provide an
argument such as "x86" (32-bit mode) or "x86_amd64" (64-bit mode) to
select the build mode.
When using PowerShell, run the "msvcprep.ps1" script instead of
"msvcprep.bat". Running the latter from PowerShell will appear to
work, but will not actually change any environment variables.
After you have Visual Studio command-line tools set up, then you can
build either the traditional Racket implementation or Racket-on-Chez
(or both).

View File

@ -0,0 +1,30 @@
<#
.SYNOPSIS
A variant of msvcprep.bat for PowerShell users.
.DESCRIPTION
Runs Visual Studio's vcvarsall.bat script to set the necessary
environment variables for a given target platform.
.EXAMPLE
Set variables for x86.
PS C:\>racket\src\worksp\msvcprep.ps1 x86
.EXAMPLE
Set variables for x86_64
PS C:\>racket\src\worksp\msvcprep.ps1 x86_amd64
.NOTES
Adapted from this StackOverflow answer:
* https://stackoverflow.com/a/2124759/144981
#>
$command = "echo off & " + $PSScriptRoot + "\msvcprep.bat " + $Args[0] + " & set"
cmd /c $command |
ForEach {
if ($_ -match "=") {
$v = $_.split("=", 2)
Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
}
}
Write-Host "Visual Studio variables set." -ForegroundColor Yellow