Skip to content
Permalink
Browse files

windows: Improve Powershell Tools and AppVeyor config

[travis skip]
  • Loading branch information...
lazyfrosch committed Apr 4, 2019
1 parent d0da5e0 commit ca67d7e9631cc727a919d27876d256f1c85602ff
Showing with 94 additions and 120 deletions.
  1. +11 −20 appveyor.yml
  2. +10 −1 tools/win32/build.ps1
  3. +8 −22 tools/win32/configure.ps1
  4. +0 −76 tools/win32/download-openssl.ps1
  5. +58 −0 tools/win32/load-vsenv.ps1
  6. +7 −1 tools/win32/test.ps1
@@ -1,18 +1,20 @@
---
version: 2.9.0.dev.{build}
version: 2.11.0.dev.{build}

os: Visual Studio 2017
platform: x64

environment:
BITS: 64
CMAKE_BUILD_TYPE: Debug
CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
VSCMD_VER: 15.0
# https://www.appveyor.com/docs/windows-images-software/#boost
BOOST_ROOT: 'C:\Libraries\boost_1_66_0'
BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_66_0\lib64-msvc-14.1'
BOOST_ROOT: 'C:\Libraries\boost_1_67_0'
BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_67_0\lib64-msvc-14.1'
# https://www.appveyor.com/docs/windows-images-software/#tools
OPENSSL_ROOT_DIR: 'C:\OpenSSL-v111-Win64'
BISON_BINARY: 'C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe'
FLEX_BINARY: 'C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe'
CMAKE_BUILD_TYPE: Debug

branches:
only:
@@ -33,32 +35,21 @@ install:
# https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell#comment_44999171
before_build:
- ps: |
$bits = $env:PLATFORM -replace "^x", ""
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars${bits}.bat`" && set > `"${env:TEMP}\vcvars.txt`""
Get-Content "$env:TEMP\vcvars.txt" | Foreach-Object {
if ($_ -match "^(VSCMD.*?)=(.*)$") {
Set-Content ("env:" + $matches[1]) $matches[2]
}
}
if (-not (Test-Path ".\build\vendor\OpenSSL")) {
& .\tools\win32\download-openssl.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
}
& .\tools\win32\load-vsenv.ps1
& .\tools\win32\configure.ps1
& powershell.exe .\tools\win32\configure.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
del build\Icinga*.msi
build_script:
- ps: |
& .\tools\win32\build.ps1
& powershell.exe .\tools\win32\build.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
test_script:
- ps: |
& .\tools\win32\test.ps1
& powershell.exe .\tools\win32\test.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
# Disable until we really need them
@@ -1,7 +1,13 @@
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
@@ -14,5 +20,8 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
$env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
}

cmake.exe --build "$env:ICINGA2_BUILDPATH" --target PACKAGE --config RelWithDebInfo
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 }
@@ -1,3 +1,5 @@
Set-PsDebug -Trace 1

if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
$env:ICINGA2_BUILDPATH = '.\build'
}
@@ -8,40 +10,23 @@ if (-not (Test-Path env:CMAKE_BUILD_TYPE)) {
if (-not (Test-Path "$env:ICINGA2_BUILDPATH")) {
mkdir "$env:ICINGA2_BUILDPATH" | out-null
}
if (-not (Test-Path "$env:ICINGA2_BUILDPATH\install")) {
mkdir "$env:ICINGA2_BUILDPATH\install" | 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 15 2017 Win64'
}
if (-not (Test-Path env:OPENSSL_ROOT_DIR)) {
if (Test-Path env:VSCMD_ARG_TGT_ARCH) {
$OpenSSL_arch = $env:VSCMD_ARG_TGT_ARCH
} else {
throw "Missing env variable VSCMD_ARG_TGT_ARCH"
}

if (Test-Path env:VSCMD_VER) {
$VSmajor = $env:VSCMD_VER -replace "\..*$", ""
$OpenSSL_vcbuild = "vc${VSmajor}0"
} else {
throw "Missing env variable VSCMD_VER"
}

$env:OPENSSL_ROOT_DIR = "$env:ICINGA2_BUILDPATH\vendor\OpenSSL-$OpenSSL_arch-$OpenSSL_vcbuild"
$env:OPENSSL_ROOT_DIR = 'c:\local\OpenSSL_1_1_1b-Win64'
}
if (-not (Test-Path env:BOOST_ROOT)) {
$env:BOOST_ROOT = 'c:\local\boost_1_65_1'
$env:BOOST_ROOT = 'c:\local\boost_1_69_0-Win64'
}
if (-not (Test-Path env:BOOST_LIBRARYDIR)) {
$env:BOOST_LIBRARYDIR = 'c:\local\boost_1_65_1\lib64-msvc-14.1'
$env:BOOST_LIBRARYDIR = 'c:\local\boost_1_69_0-Win64\lib64-msvc-14.1'
}
if (-not (Test-Path env:FLEX_BINARY)) {
$env:FLEX_BINARY = 'C:\ProgramData\chocolatey\bin\win_flex.exe'
@@ -63,11 +48,12 @@ if (Test-Path CMakeCache.txt) {

& cmake.exe "$sourcePath" `
-DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" `
-G $env:CMAKE_GENERATOR -DCPACK_GENERATOR=WIX `
-G "$env:CMAKE_GENERATOR" -DCPACK_GENERATOR=WIX `
-DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF `
-DICINGA2_WITH_LIVESTATUS=OFF -DICINGA2_WITH_COMPAT=OFF `
-DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" `
-DBOOST_ROOT="$env:BOOST_ROOT" `
-DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" `
-DBOOST_INCLUDEDIR="$env:BOOST_ROOT" `
-DFLEX_EXECUTABLE="$env:FLEX_BINARY" `
-DBISON_EXECUTABLE="$env:BISON_BINARY"

This file was deleted.

@@ -0,0 +1,58 @@
# 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\2017"
}

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"
)

$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]
}
}
@@ -1,7 +1,13 @@
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)) {
@@ -18,7 +24,7 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {

cd "$env:ICINGA2_BUILDPATH"

ctest.exe -C RelWithDebInfo -T test -O $env:ICINGA2_BUILDPATH/Test.xml --output-on-failure
ctest.exe -C "${env:CMAKE_BUILD_TYPE}" -T test -O $env:ICINGA2_BUILDPATH/Test.xml --output-on-failure
if ($lastexitcode -ne 0) {
cd ..
exit $lastexitcode

0 comments on commit ca67d7e

Please sign in to comment.
You can’t perform that action at this time.