From 56ae875861ab260b80a030f50c4aff9f9dc8fff0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:32:39 +0200 Subject: Adding upstream version 2.14.2. Signed-off-by: Daniel Baumann --- tools/win32/load-vsenv.ps1 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tools/win32/load-vsenv.ps1 (limited to 'tools/win32/load-vsenv.ps1') diff --git a/tools/win32/load-vsenv.ps1 b/tools/win32/load-vsenv.ps1 new file mode 100644 index 0000000..c5323dc --- /dev/null +++ b/tools/win32/load-vsenv.ps1 @@ -0,0 +1,59 @@ +# why that env handling, see +# https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell#comment_44999171 + +Set-PsDebug -Trace 1 + +$SOURCE = Get-Location + +if (Test-Path env:ICINGA2_BUILDPATH) { + $BUILD = $env:ICINGA2_BUILDPATH +} else { + $BUILD = "${SOURCE}\Build" +} + +if (-not (Test-Path $BUILD)) { + mkdir $BUILD | Out-Null +} + +if (Test-Path env:VS_INSTALL_PATH) { + $VSBASE = $env:VS_INSTALL_PATH +} else { + $VSBASE = "C:\Program Files (x86)\Microsoft Visual Studio\2019" +} + +if (Test-Path env:BITS) { + $bits = $env:BITS +} else { + $bits = 64 +} + +# Execute vcvars in cmd and store env +$vcvars_locations = @( + "${VSBASE}\BuildTools\VC\Auxiliary\Build\vcvars${bits}.bat" + "${VSBASE}\Community\VC\Auxiliary\Build\vcvars${bits}.bat" + "${VSBASE}\Enterprise\VC\Auxiliary\Build\vcvars${bits}.bat" +) + +$vcvars = $null +foreach ($file in $vcvars_locations) { + if (Test-Path $file) { + $vcvars = $file + break + } +} + +if ($vcvars -eq $null) { + throw "Could not get Build environment script at locations: ${vcvars_locations}" +} + +cmd.exe /c "call `"${vcvars}`" && set > `"${BUILD}\vcvars.txt`"" +if ($LastExitCode -ne 0) { + throw "Could not load Build environment from: ${vcvars}" +} + +# Load environment for PowerShell +Get-Content "${BUILD}\vcvars.txt" | Foreach-Object { + if ($_ -match "^(VSCMD.*?)=(.*)$") { + Set-Content ("env:" + $matches[1]) $matches[2] + } +} -- cgit v1.2.3