-
Notifications
You must be signed in to change notification settings - Fork 47
/
build.ps1
82 lines (75 loc) · 2.78 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#powershell -ExecutionPolicy ByPass -File build.ps1
param(
[string]$libdigidocpp = $PSScriptRoot,
[string]$platform = "x64",
[string]$git = "git.exe",
[string]$vcpkg = "vcpkg\vcpkg.exe",
[string]$vcpkg_dir = (split-path -parent $vcpkg),
[string]$vcpkg_installed = $libdigidocpp,
[string]$vcpkg_installed_platform = "$vcpkg_installed\vcpkg_installed_$platform",
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
[string]$msiversion = "4.1.0.$build_number",
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi",
[string]$cmake = "cmake.exe",
[string]$generator = "NMake Makefiles",
[string]$vcvars = "vcvarsall",
[string]$swig = $null,
[string]$doxygen = $null,
[switch]$boost = $false,
[string]$sign = $null
)
Try {
& wix > $null
}
Catch {
& dotnet tool install -g --version 5.0.2 wix
& wix extension add -g WixToolset.UI.wixext/5.0.2
}
if(!(Test-Path -Path $vcpkg)) {
& $git clone https://github.com/microsoft/vcpkg $vcpkg_dir
& $vcpkg_dir\bootstrap-vcpkg.bat
}
$cmakeext = @()
$wixext = @()
$target = @("all")
if($swig) {
$cmakeext += "-DSWIG_EXECUTABLE=$swig"
$wixext += "-d", "swig=$swig"
}
if($doxygen) {
$cmakeext += "-DDOXYGEN_EXECUTABLE=$doxygen"
$wixext += "-d", "docLocation=$(Get-Location)/$platform/share/doc/libdigidocpp"
}
if($boost) {
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
$target += "check"
}
foreach($type in @("Debug", "RelWithDebInfo")) {
$buildpath = $platform+$type
& $vcvars $platform "&&" $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" `
"-DCMAKE_BUILD_TYPE=$type" `
"-DCMAKE_INSTALL_PREFIX=$platform" `
"-DCMAKE_INSTALL_LIBDIR=bin" `
"-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" `
"-DVCPKG_INSTALLED_DIR=$vcpkg_installed_platform" `
"-DSIGNCERT=$sign" `
$cmakeext "&&" $cmake --build $buildpath --target $target "&&" $cmake --install $buildpath
}
if($sign) {
& $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
/tr http://timestamp.digicert.com /td SHA256 `
$vcpkg_installed_platform/$platform-windows/bin/*.dll `
$vcpkg_installed_platform/$platform-windows/debug/bin/*.dll
}
& $vcvars $platform "&&" wix build -nologo -arch $platform -out $msi_name $wixext `
-ext WixToolset.UI.wixext `
-bv "WixUIBannerBmp=$libdigidocpp/banner.bmp" `
-bv "WixUIDialogBmp=$libdigidocpp/dlgbmp.bmp" `
-d "ICON=$libdigidocpp/ID.ico" `
-d "vcpkg=$vcpkg_installed_platform/$platform-windows" `
-d "libdigidocpp=$(Get-Location)/$platform" `
$libdigidocpp\libdigidocpp.wxs
if($sign) {
& $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
/tr http://timestamp.digicert.com /td SHA256 "$msi_name"
}