diff --git a/doc/21-development.md b/doc/21-development.md index 7bcf3bded32..5081112ff51 100644 --- a/doc/21-development.md +++ b/doc/21-development.md @@ -1732,6 +1732,42 @@ The required steps are described in [this script](https://github.com/dnsmichi/do The following sections explain how to setup the required build tools and how to run and debug the code. +#### TL;DR + +If you're going to setup a dev environment on a fresh Windows machine +and don't care for the details, + +1. ensure there are 35 GB free space on C: +2. run the following in an administrative Powershell: + 1. `Enable-WindowsOptionalFeature -FeatureName "NetFx3" -Online` + (reboot when asked!) + 2. `powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Icinga/icinga2/master/doc/win-dev.ps1')"` + (will take some time) + +This installs everything needed for cloning and building Icinga 2 +on the command line (Powershell) as follows: + +(Don't forget to open a new Powershell window +to be able to use the newly installed Git.) + +``` +git clone https://github.com/Icinga/icinga2.git +cd .\icinga2\ +mkdir build +cd .\build\ + +& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" ` + -DBoost_INCLUDE_DIR=C:\local\boost_1_71_0-Win64 ` + -DBISON_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe ` + -DFLEX_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe ` + -DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF .. + +& "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" .\icinga2.sln +``` + +Building icinga2.sln via Visual Studio itself seems to require a reboot +after installing the build tools and building once via command line. + #### Chocolatey Open an administrative command prompt (Win key, type “cmd”, right-click and “run as administrator”) and paste the following instructions: diff --git a/doc/win-dev.ps1 b/doc/win-dev.ps1 new file mode 100644 index 00000000000..37d6323b8a7 --- /dev/null +++ b/doc/win-dev.ps1 @@ -0,0 +1,77 @@ +Set-PSDebug -Trace 1 + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' +$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' + +function ThrowOnNativeFailure { + if (-not $?) { + throw 'Native failure' + } +} + + +$VsVersion = 2019 +$MsvcVersion = '14.2' +$BoostVersion = @(1, 71, 0) +$OpensslVersion = '1_1_1h' + + +function Install-Exe { + param ( + [string]$Url, + [string]$Dir + ) + + $TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().Guid) + $ExeFile = Join-Path $TempDir inst.exe + + New-Item -ItemType Directory -Path $TempDir + + for ($trial = 1;; ++$trial) { + try { + Invoke-WebRequest -Uri $Url -OutFile $ExeFile -UseBasicParsing + } catch { + if ($trial -ge 2) { + throw + } + + continue + } + + break + } + + Start-Process -Wait -FilePath $ExeFile -ArgumentList @('/VERYSILENT', '/INSTALL', '/PASSIVE', '/NORESTART', "/DIR=${Dir}") + Remove-Item -Recurse -Path $TempDir +} + + +Invoke-Expression (New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1') + +$RegEnv = 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' +$ChocoPath = ";$(Join-Path $Env:AllUsersProfile chocolatey\bin)" + +Set-ItemProperty -Path $RegEnv -Name Path -Value ((Get-ItemProperty -Path $RegEnv -Name Path).Path + $ChocoPath) +$Env:Path += $ChocoPath + + +choco install -y "visualstudio${VsVersion}community" +choco install -y "visualstudio${VsVersion}-workload-netcoretools" +choco install -y "visualstudio${VsVersion}-workload-vctools" +choco install -y "visualstudio${VsVersion}-workload-manageddesktop" +choco install -y "visualstudio${VsVersion}-workload-nativedesktop" +choco install -y "visualstudio${VsVersion}-workload-universal" +choco install -y "visualstudio${VsVersion}buildtools" + + +choco install -y git +choco install -y cmake +choco install -y winflexbison3 +choco install -y windows-sdk-8.1 +choco install -y wixtoolset + + +Install-Exe -Url "https://packages.icinga.com/windows/dependencies/boost_$($BoostVersion -join '_')-msvc-${MsvcVersion}-64.exe" -Dir "C:\local\boost_$($BoostVersion -join '_')-Win64" + +Install-Exe -Url "https://packages.icinga.com/windows/dependencies/Win64OpenSSL-${OpensslVersion}.exe" -Dir "C:\local\OpenSSL_${OpensslVersion}-Win64"