]> granicus.if.org Git - icinga2/commitdiff
windows: Add build scripts
authorMarkus Frosch <markus.frosch@icinga.com>
Fri, 2 Feb 2018 16:19:14 +0000 (17:19 +0100)
committerMarkus Frosch <markus.frosch@icinga.com>
Wed, 7 Feb 2018 15:07:25 +0000 (16:07 +0100)
tools/win32/build.ps1 [new file with mode: 0644]
tools/win32/configure.ps1 [new file with mode: 0644]
tools/win32/download-openssl.ps1 [new file with mode: 0644]

diff --git a/tools/win32/build.ps1 b/tools/win32/build.ps1
new file mode 100644 (file)
index 0000000..1110715
--- /dev/null
@@ -0,0 +1,16 @@
+[string]$pwd = Get-Location
+
+if (-not (Test-Path build)) {
+  Write-Host "Path '$pwd\build' 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 build --target PACKAGE --config RelWithDebInfo
+if ($lastexitcode -ne 0) { exit $lastexitcode }
\ No newline at end of file
diff --git a/tools/win32/configure.ps1 b/tools/win32/configure.ps1
new file mode 100644 (file)
index 0000000..cdd6651
--- /dev/null
@@ -0,0 +1,53 @@
+if (-not (Test-Path build)) {
+  mkdir build
+}
+if (-not (Test-Path install)) {
+  mkdir install
+}
+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
+}
+
+[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 (-not (Test-Path env:BOOST_ROOT)) {
+  $env:BOOST_ROOT = 'c:\local\boost_1_65_1'
+}
+if (-not (Test-Path env:BOOST_LIBRARYDIR)) {
+  $env:BOOST_LIBRARYDIR = 'c:\local\boost_1_65_1\lib64-msvc-14.1'
+}
+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'
+}
+
+cd build
+
+& cmake.exe .. `
+  -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" `
+  -DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" `
+  -DFLEX_EXECUTABLE="$env:FLEX_BINARY" `
+  -DBISON_EXECUTABLE="$env:BISON_BINARY"
+
+if ($lastexitcode -ne 0) {
+  cd ..
+  exit $lastexitcode
+}
+
+cd ..
diff --git a/tools/win32/download-openssl.ps1 b/tools/win32/download-openssl.ps1
new file mode 100644 (file)
index 0000000..466e661
--- /dev/null
@@ -0,0 +1,48 @@
+[string]$pwd = Get-Location
+$OpenSSL_version = '1.1.0g'
+$OpenSSL_arch = 'x64'
+$OpenSSL_vcbuild = 'vc150'
+$OpenSSL_fileversion = $OpenSSL_version.Replace('.', '_')
+$OpenSSL_file = [string]::Format(
+  'openssl-{0}-binary-icinga-{1}-{2}.zip',
+  $OpenSSL_fileversion,
+  $OpenSSL_arch,
+  $OpenSSL_vcbuild
+)
+
+# TODO: from GitHub Release!
+#$OpenSSL_url = ''
+$OpenSSL_url = 'https://ci.appveyor.com/api/buildjobs/4hwjjxgvvyeplrjd/artifacts/' + $OpenSSL_file
+
+$OpenSSL_zip_location = $pwd + '\vendor\' + $OpenSSL_file
+$vendor_path = $pwd + '\vendor'
+$OpenSSL_vendor_path = $vendor_path + '\OpenSSL'
+
+if (-not (Test-Path $vendor_path)) {
+  mkdir $vendor_path
+}
+
+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
+  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
+}
+
+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 }
+
+exit 0