forked from microsoft/vcpkg-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ce.ps1
40 lines (31 loc) · 1.1 KB
/
ce.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
$ENV:NODE_OPTIONS="--enable-source-maps"
function resolve {
param ( [string] $name )
$name = Resolve-Path $name -ErrorAction 0 -ErrorVariable _err
if (-not($name)) { return $_err[0].TargetObject }
$Error.clear()
return $name
}
if( $ENV:VCPKG_ROOT ) {
$SCRIPT:VCPKG_ROOT=(resolve $ENV:VCPKG_ROOT)
$ENV:VCPKG_ROOT=$VCPKG_ROOT
} else {
$SCRIPT:VCPKG_ROOT=(resolve "$HOME/.vcpkg")
$ENV:VCPKG_ROOT=$VCPKG_ROOT
}
# setup the postscript file
# Generate 31 bits of randomness, to avoid clashing with concurrent executions.
$env:Z_VCPKG_POSTSCRIPT = resolve "${VCPKG_ROOT}/VCPKG_tmp_$(Get-Random -SetSeed $PID).ps1"
node $PSScriptRoot/ce @args
# dot-source the postscript file to modify the environment
if ($env:Z_VCPKG_POSTSCRIPT -and (Test-Path $env:Z_VCPKG_POSTSCRIPT)) {
# write-host (get-content -raw $env:Z_VCPKG_POSTSCRIPT)
$content = get-content -raw $env:Z_VCPKG_POSTSCRIPT
if( $content ) {
iex $content
}
Remove-Item -Force $env:Z_VCPKG_POSTSCRIPT
remove-item -ea 0 -force env:Z_VCPKG_POSTSCRIPT
}