diff --git a/appveyor.yml b/appveyor.yml index 48fb507b0..92dfe7bef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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] - } - } + & .\tools\win32\load-vsenv.ps1 - if (-not (Test-Path ".\build\vendor\OpenSSL")) { - & .\tools\win32\download-openssl.ps1 - if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } - } - - & .\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 diff --git a/tools/win32/build.ps1 b/tools/win32/build.ps1 index d9dba5f94..33346a91b 100644 --- a/tools/win32/build.ps1 +++ b/tools/win32/build.ps1 @@ -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 } diff --git a/tools/win32/configure.ps1 b/tools/win32/configure.ps1 index 0ea0a50cb..63305e5dc 100644 --- a/tools/win32/configure.ps1 +++ b/tools/win32/configure.ps1 @@ -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" diff --git a/tools/win32/download-openssl.ps1 b/tools/win32/download-openssl.ps1 deleted file mode 100644 index 0e074e6ae..000000000 --- a/tools/win32/download-openssl.ps1 +++ /dev/null @@ -1,76 +0,0 @@ -$ErrorActionPreference = "Stop" - -$OpenSSL_version = '1.1.0g-1' - -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" -} - -$OpenSSL_fileversion = $OpenSSL_version.Replace('.', '_').Split('-')[0] -$OpenSSL_file = [string]::Format( - 'openssl-{0}-binary-icinga-{1}-{2}.zip', - $OpenSSL_fileversion, - $OpenSSL_arch, - $OpenSSL_vcbuild -) -$OpenSSL_url = [string]::Format( - 'https://github.com/Icinga/openssl-windows/releases/download/v{0}/{1}', - $OpenSSL_version, - $OpenSSL_file -) - -if (-not (Test-Path env:ICINGA2_BUILDPATH)) { - $env:ICINGA2_BUILDPATH = '.\build' -} - -$vendor_path = $env:ICINGA2_BUILDPATH + '\vendor' -$OpenSSL_zip_location = $env:ICINGA2_BUILDPATH + '\vendor\' + $OpenSSL_file -$OpenSSL_vendor_path = "$vendor_path\OpenSSL-$OpenSSL_arch-$OpenSSL_vcbuild" - -# Tune Powershell TLS protocols -$AllProtocols = [System.Net.SecurityProtocolType]'Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols - -if (-not (Test-Path $env:ICINGA2_BUILDPATH)) { - mkdir $env:ICINGA2_BUILDPATH | out-null -} -if (-not (Test-Path $vendor_path)) { - mkdir $vendor_path | out-null -} - -if (Test-Path $OpenSSL_zip_location) { - Write-Output "OpenSSL archive available at $OpenSSL_zip_location" -} else { - Write-Output "Downloading OpenSSL binary dist from $OpenSSL_url" - - $progressPreference = 'silentlyContinue' - Invoke-WebRequest -Uri $OpenSSL_url -OutFile $OpenSSL_zip_location - $progressPreference = 'Continue' - - if (Test-Path $OpenSSL_vendor_path) { - Remove-Item -Recurse $OpenSSL_vendor_path - } -} - -if (-not (Test-Path $OpenSSL_vendor_path)) { - mkdir $OpenSSL_vendor_path | out-null - - Write-Output "Extracting ZIP to $OpenSSL_vendor_path" - Add-Type -AssemblyName System.IO.Compression.FileSystem - $pwd = Get-Location - [System.IO.Compression.ZipFile]::ExtractToDirectory( - (Join-Path -path $pwd -childpath $OpenSSL_zip_location), - (Join-Path -path $pwd -childpath $OpenSSL_vendor_path) - ) - if ($lastexitcode -ne 0){ exit $lastexitcode } -} else { - Write-Output "OpenSSL is already available at $OpenSSL_vendor_path" -} diff --git a/tools/win32/load-vsenv.ps1 b/tools/win32/load-vsenv.ps1 new file mode 100644 index 000000000..86fcf4fba --- /dev/null +++ b/tools/win32/load-vsenv.ps1 @@ -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] + } +} diff --git a/tools/win32/test.ps1 b/tools/win32/test.ps1 index 81fe8e6fa..3d3c12540 100644 --- a/tools/win32/test.ps1 +++ b/tools/win32/test.ps1 @@ -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