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:
parent
24e226a540
commit
3e08f50944
|
@ -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).
|
||||
|
|
30
racket/src/worksp/msvcprep.ps1
Normal file
30
racket/src/worksp/msvcprep.ps1
Normal 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
|
Loading…
Reference in New Issue
Block a user