diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:32:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:32:39 +0000 |
commit | 56ae875861ab260b80a030f50c4aff9f9dc8fff0 (patch) | |
tree | 531412110fc901a5918c7f7442202804a83cada9 /tools/win32 | |
parent | Initial commit. (diff) | |
download | icinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.tar.xz icinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.zip |
Adding upstream version 2.14.2.upstream/2.14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/win32')
-rw-r--r-- | tools/win32/build-choco.ps1 | 42 | ||||
-rw-r--r-- | tools/win32/build.ps1 | 27 | ||||
-rw-r--r-- | tools/win32/configure-dev.ps1 | 69 | ||||
-rw-r--r-- | tools/win32/configure.ps1 | 72 | ||||
-rw-r--r-- | tools/win32/load-vsenv.ps1 | 59 | ||||
-rw-r--r-- | tools/win32/test.ps1 | 33 |
6 files changed, 302 insertions, 0 deletions
diff --git a/tools/win32/build-choco.ps1 b/tools/win32/build-choco.ps1 new file mode 100644 index 0000000..32138bd --- /dev/null +++ b/tools/win32/build-choco.ps1 @@ -0,0 +1,42 @@ +Set-PsDebug -Trace 1 + +if(-not (Test-Path "$($env:ProgramData)\chocolatey\choco.exe")) { + throw "Could not find Choco executable. Abort." +} + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = '.\build' +} + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1.template")) { + throw "Could not find Chocolatey install script template. Abort." +} + +$chocoInstallScriptTemplatePath = "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1.template" +$chocoInstallScript = Get-Content $chocoInstallScriptTemplatePath + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\*-x86.msi")) { + throw "Could not find Icinga 2 32 bit MSI package. Abort." +} + +$hashMSIpackage32 = Get-FileHash "$($env:ICINGA2_BUILDPATH)\*-x86.msi" +Write-Output "File Hash for 32 bit MSI package: $($hashMSIpackage32.Hash)." + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\*-x86_64.msi")) { + throw "Could not find Icinga 2 64 bit MSI package. Abort." +} + +$hashMSIpackage64 = Get-FileHash "$($env:ICINGA2_BUILDPATH)\*-x86_64.msi" +Write-Output "File Hash for 32 bit MSI package: $($hashMSIpackage64.Hash)" + +$chocoInstallScript = $chocoInstallScript.Replace("%CHOCO_32BIT_CHECKSUM%", "$($hashMSIpackage32.Hash)") +$chocoInstallScript = $chocoInstallScript.Replace("%CHOCO_64BIT_CHECKSUM%", "$($hashMSIpackage64.Hash)") +Write-Output $chocoInstallScript + +Set-Content -Path "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1" -Value $chocoInstallScript + +cd "$($env:ICINGA2_BUILDPATH)\choco" +& "$($env:ProgramData)\chocolatey\choco.exe" "pack" +cd "..\.." + +Move-Item -Path "$($env:ICINGA2_BUILDPATH)\choco\*.nupkg" -Destination "$($env:ICINGA2_BUILDPATH)"
\ No newline at end of file diff --git a/tools/win32/build.ps1 b/tools/win32/build.ps1 new file mode 100644 index 0000000..33346a9 --- /dev/null +++ b/tools/win32/build.ps1 @@ -0,0 +1,27 @@ +Set-PsDebug -Trace 1 + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = '.\build' +} + +if (-not (Test-Path env:CMAKE_BUILD_TYPE)) { + $env:CMAKE_BUILD_TYPE = 'RelWithDebInfo' +} + +if (-not (Test-Path $env:ICINGA2_BUILDPATH)) { + Write-Host "Path '$env:ICINGA2_BUILDPATH' does not exist!" + exit 1 +} + +if (-not (Test-Path env:CMAKE_PATH)) { + $env:CMAKE_PATH = 'C:\Program Files\CMake\bin' +} +if (-not ($env:PATH -contains $env:CMAKE_PATH)) { + $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH +} + +cmake.exe --build "$env:ICINGA2_BUILDPATH" --target ALL_BUILD --config $env:CMAKE_BUILD_TYPE +if ($lastexitcode -ne 0) { exit $lastexitcode } + +cmake.exe --build "$env:ICINGA2_BUILDPATH" --target PACKAGE --config $env:CMAKE_BUILD_TYPE +if ($lastexitcode -ne 0) { exit $lastexitcode } diff --git a/tools/win32/configure-dev.ps1 b/tools/win32/configure-dev.ps1 new file mode 100644 index 0000000..6fc12b3 --- /dev/null +++ b/tools/win32/configure-dev.ps1 @@ -0,0 +1,69 @@ +Set-PsDebug -Trace 1 + +# Specify default targets for VS 2019 for developers. + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = '.\debug' +} +if (-not (Test-Path "$env:ICINGA2_BUILDPATH")) { + mkdir "$env:ICINGA2_BUILDPATH" | out-null +} + +if (-not (Test-Path env:CMAKE_BUILD_TYPE)) { + $env:CMAKE_BUILD_TYPE = 'Debug' +} +if (-not (Test-Path env:ICINGA2_INSTALLPATH)) { + $env:ICINGA2_INSTALLPATH = 'C:\Program Files\Icinga2-debug' +} +if (-not (Test-Path env:CMAKE_PATH)) { + $env:CMAKE_PATH = 'C:\Program Files\CMake\bin' +} +if (-not ($env:PATH -contains $env:CMAKE_PATH)) { + $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH +} +if (-not (Test-Path env:CMAKE_GENERATOR)) { + $env:CMAKE_GENERATOR = 'Visual Studio 16 2019' +} +if (-not (Test-Path env:CMAKE_GENERATOR_PLATFORM)) { + $env:CMAKE_GENERATOR_PLATFORM = 'x64' +} +if (-not (Test-Path env:OPENSSL_ROOT_DIR)) { + $env:OPENSSL_ROOT_DIR = 'c:\local\OpenSSL-Win64' +} +if (-not (Test-Path env:BOOST_ROOT)) { + $env:BOOST_ROOT = 'c:\local\boost_1_84_0' +} +if (-not (Test-Path env:BOOST_LIBRARYDIR)) { + $env:BOOST_LIBRARYDIR = 'c:\local\boost_1_84_0\lib64-msvc-14.2' +} +if (-not (Test-Path env:FLEX_BINARY)) { + $env:FLEX_BINARY = 'C:\ProgramData\chocolatey\bin\win_flex.exe' +} +if (-not (Test-Path env:BISON_BINARY)) { + $env:BISON_BINARY = 'C:\ProgramData\chocolatey\bin\win_bison.exe' +} + +$sourcePath = Get-Location + +cd "$env:ICINGA2_BUILDPATH" + +# Invalidate cache in case something in the build environment changed +if (Test-Path CMakeCache.txt) { + Remove-Item -Force CMakeCache.txt | Out-Null +} + +& cmake.exe "$sourcePath" ` + -DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" ` + -G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" -DCPACK_GENERATOR=WIX ` + -DCMAKE_INSTALL_PREFIX="$env:ICINGA2_INSTALLPATH" ` + -DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" ` + -DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" ` + -DBOOST_INCLUDEDIR="$env:BOOST_ROOT" ` + -DFLEX_EXECUTABLE="$env:FLEX_BINARY" ` + -DBISON_EXECUTABLE="$env:BISON_BINARY" + +cd "$sourcePath" + +if ($lastexitcode -ne 0) { + exit $lastexitcode +} diff --git a/tools/win32/configure.ps1 b/tools/win32/configure.ps1 new file mode 100644 index 0000000..55f0a58 --- /dev/null +++ b/tools/win32/configure.ps1 @@ -0,0 +1,72 @@ +Set-PsDebug -Trace 1 + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = '.\build' +} + +if (-not (Test-Path env:CMAKE_BUILD_TYPE)) { + $env:CMAKE_BUILD_TYPE = 'RelWithDebInfo' +} +if (-not (Test-Path "$env:ICINGA2_BUILDPATH")) { + mkdir "$env:ICINGA2_BUILDPATH" | out-null +} +if (-not (Test-Path env:CMAKE_PATH)) { + $env:CMAKE_PATH = 'C:\Program Files\CMake\bin' +} +if (-not ($env:PATH -contains $env:CMAKE_PATH)) { + $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH +} +if (-not (Test-Path env:CMAKE_GENERATOR)) { + $env:CMAKE_GENERATOR = 'Visual Studio 16 2019' +} +if (-not (Test-Path env:BITS)) { + $env:BITS = 64 +} +if (-not (Test-Path env:CMAKE_GENERATOR_PLATFORM)) { + if ($env:BITS -eq 32) { + $env:CMAKE_GENERATOR_PLATFORM = 'Win32' + } else { + $env:CMAKE_GENERATOR_PLATFORM = 'x64' + } +} +if (-not (Test-Path env:OPENSSL_ROOT_DIR)) { + $env:OPENSSL_ROOT_DIR = "c:\local\OpenSSL_3_0_12-Win${env:BITS}" +} +if (-not (Test-Path env:BOOST_ROOT)) { + $env:BOOST_ROOT = "c:\local\boost_1_84_0-Win${env:BITS}" +} +if (-not (Test-Path env:BOOST_LIBRARYDIR)) { + $env:BOOST_LIBRARYDIR = "c:\local\boost_1_84_0-Win${env:BITS}\lib${env:BITS}-msvc-14.2" +} +if (-not (Test-Path env:FLEX_BINARY)) { + $env:FLEX_BINARY = 'C:\ProgramData\chocolatey\bin\win_flex.exe' +} +if (-not (Test-Path env:BISON_BINARY)) { + $env:BISON_BINARY = 'C:\ProgramData\chocolatey\bin\win_bison.exe' +} + +$sourcePath = Get-Location + +cd "$env:ICINGA2_BUILDPATH" + +#-DCMAKE_INSTALL_PREFIX="C:\Program Files\Icinga2" ` + +# Invalidate cache in case something in the build environment changed +if (Test-Path CMakeCache.txt) { + Remove-Item -Force CMakeCache.txt | Out-Null +} + +& cmake.exe "$sourcePath" ` + -DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" ` + -G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" -DCPACK_GENERATOR=WIX ` + -DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" ` + -DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" ` + -DBOOST_INCLUDEDIR="$env:BOOST_ROOT" ` + -DFLEX_EXECUTABLE="$env:FLEX_BINARY" ` + -DBISON_EXECUTABLE="$env:BISON_BINARY" + +cd "$sourcePath" + +if ($lastexitcode -ne 0) { + exit $lastexitcode +} 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] + } +} diff --git a/tools/win32/test.ps1 b/tools/win32/test.ps1 new file mode 100644 index 0000000..d7ad90c --- /dev/null +++ b/tools/win32/test.ps1 @@ -0,0 +1,33 @@ +Set-PsDebug -Trace 1 + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = 'build' +} + +if (-not (Test-Path env:CMAKE_BUILD_TYPE)) { + $env:CMAKE_BUILD_TYPE = 'RelWithDebInfo' +} + +[string]$pwd = Get-Location + +if (-not (Test-Path $env:ICINGA2_BUILDPATH)) { + Write-Host "Path '$pwd\$env:ICINGA2_BUILDPATH' does not exist!" + exit 1 +} + +if (-not (Test-Path env:CMAKE_PATH)) { + $env:CMAKE_PATH = 'C:\Program Files\CMake\bin' +} +if (-not ($env:PATH -contains $env:CMAKE_PATH)) { + $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH +} + +cd "$env:ICINGA2_BUILDPATH" + +ctest.exe -C "${env:CMAKE_BUILD_TYPE}" -T test -O $env:ICINGA2_BUILDPATH/Test.xml --output-on-failure --log_level=all +if ($lastexitcode -ne 0) { + cd .. + exit $lastexitcode +} + +cd .. |