-
Notifications
You must be signed in to change notification settings - Fork 47
/
build.ps1
89 lines (82 loc) · 2.93 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
83
84
85
86
87
88
89
#powershell -ExecutionPolicy ByPass -File build.ps1
param(
[string]$libdigidocpp = $PSScriptRoot,
[string]$platform = $env:VSCMD_ARG_TGT_ARCH,
[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]$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]$vcpkg_triplet = "$platform-windows",
[string]$cmake = "cmake.exe",
[string]$generator = "NMake Makefiles",
[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($platform -eq "arm64" -and $env:VSCMD_ARG_HOST_ARCH -ne "arm64") {
$cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes"
$wixext += "-d", "disablePython=1"
$boost = $false
}
if($boost) {
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
$target += "check"
}
foreach($type in @("Debug", "RelWithDebInfo")) {
$buildpath = $platform+$type
& $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" $cmakeext `
"-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" `
"-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" `
"-DSIGNCERT=$sign"
& $cmake --build $buildpath --target $target
& $cmake --install $buildpath
}
if($sign) {
& 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/$vcpkg_triplet/bin/*.dll `
$vcpkg_installed_platform/$vcpkg_triplet/debug/bin/*.dll
}
& 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/$vcpkg_triplet" `
-d "libdigidocpp=$(Get-Location)/$platform" `
$libdigidocpp\libdigidocpp.wxs
if($sign) {
& 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"
}