]> granicus.if.org Git - icinga2/commitdiff
Update windows build scripts 6510/head
authorMarkus Frosch <markus.frosch@icinga.com>
Thu, 2 Aug 2018 12:42:14 +0000 (14:42 +0200)
committerMarkus Frosch <markus.frosch@icinga.com>
Fri, 3 Aug 2018 09:11:39 +0000 (11:11 +0200)
.gitignore
appveyor.yml
tools/win32/build.ps1
tools/win32/configure.ps1
tools/win32/download-openssl.ps1
tools/win32/test.ps1

index b3d357ecc9bb8e199fc7ebe4b635c0de5ee305f3..0e2ed3ffd20cde98e76050f662f5c8c114262e06 100644 (file)
 tickets.pickle
 
 ## Build artifacts
-build/
-build-debug/
-build-release/
-build32/
-build64/
+build*/
 debug/
 release/
 cmake-build-debug
index 05c72cd75fce34a9411b38646d30a40993cc583d..6e7f09b73f5e95a58586f1b4a7c97ea85d2c4148 100644 (file)
@@ -2,9 +2,11 @@
 version: 2.9.0.dev.{build}
 
 os: Visual Studio 2017
+platform: x64
 
 environment:
   CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
+  VSCMD_VER: 15.0
   BOOST_ROOT: 'C:\Libraries\boost_1_65_1'
   BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_65_1\lib64-msvc-14.1'
   BISON_BINARY: 'C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe'
@@ -16,36 +18,46 @@ branches:
 
 cache:
 - build -> appveyor.yml
-- vendor -> tools\win32\download-openssl.ps1
 - C:\ProgramData\chocolatey\lib\winflexbison3
 
 install:
-- ps: |
-    if (-not (Test-Path "vendor\OpenSSL")) {
-      .\tools\win32\download-openssl.ps1
-      if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode)  }
-    }
 - ps: |
     if (-not (Test-Path "C:\ProgramData\chocolatey\lib\winflexbison3")) {
-      choco install winflexbison3
-      if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode)  }
+      choco install winflexbison3
+      if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
     }
 
+# why that env handling, see
+# https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell#comment_44999171
 before_build:
 - ps: |
-    .\tools\win32\configure.ps1
-    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode)  }
+    $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\configure.ps1
+    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
+
     del build\Icinga*.msi
 
 build_script:
 - ps: |
-    .\tools\win32\build.ps1
-    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode)  }
+    .\tools\win32\build.ps1
+    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
 
 test_script:
 - ps: |
-    .\tools\win32\test.ps1
-    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode)  }
+    .\tools\win32\test.ps1
+    if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
 
 # Disable until we really need them
 # https://github.com/Icinga/icinga2/issues/6106
index 1110715188de917fec94caf9a2764c6770e7d374..d9dba5f94b95db8abc2d96ed1236a3f82f1d97b6 100644 (file)
@@ -1,7 +1,9 @@
-[string]$pwd = Get-Location
+if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
+  $env:ICINGA2_BUILDPATH = '.\build'
+}
 
-if (-not (Test-Path build)) {
-  Write-Host "Path '$pwd\build' does not exist!"
+if (-not (Test-Path $env:ICINGA2_BUILDPATH)) {
+  Write-Host "Path '$env:ICINGA2_BUILDPATH' does not exist!"
   exit 1
 }
 
@@ -12,5 +14,5 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
   $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
 }
 
-cmake.exe --build build --target PACKAGE --config RelWithDebInfo
-if ($lastexitcode -ne 0) { exit $lastexitcode }
\ No newline at end of file
+cmake.exe --build "$env:ICINGA2_BUILDPATH" --target PACKAGE --config RelWithDebInfo
+if ($lastexitcode -ne 0) { exit $lastexitcode }
index cdd66512f48b1f12513722aba628433626cd6ebb..1f40875ce5474b1a794d2e6148f151444352190d 100644 (file)
@@ -1,8 +1,12 @@
-if (-not (Test-Path build)) {
-  mkdir build
+if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
+  $env:ICINGA2_BUILDPATH = '.\build'
 }
-if (-not (Test-Path install)) {
-  mkdir install
+
+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'
@@ -11,13 +15,24 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
   $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
 }
 
-[string]$pwd = Get-Location
-
 if (-not (Test-Path env:CMAKE_GENERATOR)) {
   $env:CMAKE_GENERATOR = 'Visual Studio 15 2017 Win64'
 }
 if (-not (Test-Path env:OPENSSL_ROOT_DIR)) {
-  $env:OPENSSL_ROOT_DIR = $pwd + '\vendor\OpenSSL'
+  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"
 }
 if (-not (Test-Path env:BOOST_ROOT)) {
   $env:BOOST_ROOT = 'c:\local\boost_1_65_1'
@@ -32,12 +47,15 @@ if (-not (Test-Path env:BISON_BINARY)) {
   $env:BISON_BINARY = 'C:\ProgramData\chocolatey\bin\win_bison.exe'
 }
 
-cd build
+$sourcePath = Get-Location
 
-& cmake.exe .. `
+cd "$env:ICINGA2_BUILDPATH"
+
+#-DCMAKE_INSTALL_PREFIX="C:\Program Files\Icinga2" `
+
+& cmake.exe "$sourcePath" `
   -DCMAKE_BUILD_TYPE=RelWithDebInfo `
   -G $env:CMAKE_GENERATOR -DCPACK_GENERATOR=WIX `
-  -DCMAKE_INSTALL_PREFIX="..\install" `
   -DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF `
   -DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" `
   -DBOOST_ROOT="$env:BOOST_ROOT" `
@@ -45,9 +63,8 @@ cd build
   -DFLEX_EXECUTABLE="$env:FLEX_BINARY" `
   -DBISON_EXECUTABLE="$env:BISON_BINARY"
 
+cd "$sourcePath"
+
 if ($lastexitcode -ne 0) {
-  cd ..
   exit $lastexitcode
 }
-
-cd ..
index 1ebe348f952d1fca406fabffd8a148b4f53c6b47..0e074e6aed81734496d42056ababbd29b7cc857c 100644 (file)
@@ -1,7 +1,19 @@
-[string]$pwd = Get-Location
+$ErrorActionPreference = "Stop"
+
 $OpenSSL_version = '1.1.0g-1'
-$OpenSSL_arch = 'x64'
-$OpenSSL_vcbuild = 'vc150'
+
+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',
@@ -15,12 +27,23 @@ $OpenSSL_url = [string]::Format(
   $OpenSSL_file
 )
 
-$OpenSSL_zip_location = $pwd + '\vendor\' + $OpenSSL_file
-$vendor_path = $pwd + '\vendor'
-$OpenSSL_vendor_path = $vendor_path + '\OpenSSL'
+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
+  mkdir $vendor_path | out-null
 }
 
 if (Test-Path $OpenSSL_zip_location) {
@@ -30,21 +53,24 @@ if (Test-Path $OpenSSL_zip_location) {
 
   $progressPreference = 'silentlyContinue'
   Invoke-WebRequest -Uri $OpenSSL_url -OutFile $OpenSSL_zip_location
-  if ($lastexitcode -ne 0){ exit $lastexitcode }
   $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
+  mkdir $OpenSSL_vendor_path | out-null
 
   Write-Output "Extracting ZIP to $OpenSSL_vendor_path"
   Add-Type -AssemblyName System.IO.Compression.FileSystem
-  [System.IO.Compression.ZipFile]::ExtractToDirectory($OpenSSL_zip_location, $OpenSSL_vendor_path)
-  if ($lastexitcode -ne 0){ exit $lastexitcode }  
+  $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"
 }
index 913c82c58e3d65b87e88b3fba13db678e9b2ac29..81fe8e6fa3d3db7852cf0763f03ecc566bc0c087 100644 (file)
@@ -1,7 +1,11 @@
+if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
+  $env:ICINGA2_BUILDPATH = 'build'
+}
+
 [string]$pwd = Get-Location
 
-if (-not (Test-Path build)) {
-  Write-Host "Path '$pwd\build' does not exist!"
+if (-not (Test-Path $env:ICINGA2_BUILDPATH)) {
+  Write-Host "Path '$pwd\$env:ICINGA2_BUILDPATH' does not exist!"
   exit 1
 }
 
@@ -12,12 +16,12 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
   $env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
 }
 
-cd build
+cd "$env:ICINGA2_BUILDPATH"
 
-ctest.exe -C RelWithDebInfo -T test -O build/Test.xml --output-on-failure
+ctest.exe -C RelWithDebInfo -T test -O $env:ICINGA2_BUILDPATH/Test.xml --output-on-failure
 if ($lastexitcode -ne 0) {
   cd ..
   exit $lastexitcode
 }
 
-cd ..
\ No newline at end of file
+cd ..