From 5936c0db6f978b05bd37cf8eaa7af1196fb49ef5 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 2 Feb 2018 17:19:14 +0100 Subject: [PATCH] windows: Add build scripts --- tools/win32/build.ps1 | 16 ++++++++++ tools/win32/configure.ps1 | 53 ++++++++++++++++++++++++++++++++ tools/win32/download-openssl.ps1 | 48 +++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 tools/win32/build.ps1 create mode 100644 tools/win32/configure.ps1 create mode 100644 tools/win32/download-openssl.ps1 diff --git a/tools/win32/build.ps1 b/tools/win32/build.ps1 new file mode 100644 index 000000000..111071518 --- /dev/null +++ b/tools/win32/build.ps1 @@ -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 index 000000000..cdd66512f --- /dev/null +++ b/tools/win32/configure.ps1 @@ -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 index 000000000..466e661c8 --- /dev/null +++ b/tools/win32/download-openssl.ps1 @@ -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 -- 2.40.0