aboutsummaryrefslogtreecommitdiff
path: root/scripts/VcpkgPowershellUtils.ps1
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-01-22 18:19:30 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2018-01-23 14:16:06 -0800
commit0df743d6252efda732c00daa48cef28acbf3f078 (patch)
tree60182da2a0193af6396bcf5f1b67f0d980cc8935 /scripts/VcpkgPowershellUtils.ps1
parenta5fe308ea3c29c5f8715b8f0c78571759541c9b5 (diff)
downloadvcpkg-0df743d6252efda732c00daa48cef28acbf3f078.tar.gz
vcpkg-0df743d6252efda732c00daa48cef28acbf3f078.zip
[bootstrap] Build vcpkg in a clean environment
Diffstat (limited to 'scripts/VcpkgPowershellUtils.ps1')
-rw-r--r--scripts/VcpkgPowershellUtils.ps127
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index 7a6a67c2c..ec1e8b92b 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -168,10 +168,33 @@ function vcpkgInvokeCommand()
{
param ( [Parameter(Mandatory=$true)][string]$executable,
[string]$arguments = "",
- [switch]$wait)
+ [Parameter(Mandatory=$true)][switch]$wait)
Write-Verbose "Executing: ${executable} ${arguments}"
- $process = Start-Process -FilePath $executable -ArgumentList $arguments -PassThru -NoNewWindow
+ $process = Start-Process -FilePath "`"$executable`"" -ArgumentList $arguments -PassThru -NoNewWindow
+ if ($wait)
+ {
+ Wait-Process -InputObject $process
+ $ec = $process.ExitCode
+ Write-Verbose "Execution terminated with exit code $ec."
+ }
+}
+
+function vcpkgInvokeCommandClean()
+{
+ param ( [Parameter(Mandatory=$true)][string]$executable,
+ [string]$arguments = "",
+ [Parameter(Mandatory=$true)][switch]$wait)
+
+ Write-Verbose "Clean-Executing: ${executable} ${arguments}"
+ $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
+ $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1"
+ $command = "& `"$cleanEnvScript`"; & `"$executable`" $arguments"
+ $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
+ $encodedCommand = [Convert]::ToBase64String($bytes)
+ $arg = "-encodedCommand $encodedCommand"
+
+ $process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow
if ($wait)
{
Wait-Process -InputObject $process