/
build.ps1
114 lines (103 loc) · 4.9 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
try {
cd $env:APPVEYOR_BUILD_FOLDER
$vcpkg_toolchain = ""
$vcpkg_triplet = ""
if ($env:CC_SHORTNAME -eq "vs2008" -or $env:CC_SHORTNAME -eq "vs2013") {
# on VS2008 mbedtls can not be built since it includes stdint.h which is not available there
$build_encryption = "OFF"
Write-Host -ForegroundColor Green "`n## Building without encryption on VS2008 or VS2013 #####`n"
} else {
$build_encryption = "MBEDTLS"
}
$vcpkg_toolchain = '-DCMAKE_TOOLCHAIN_FILE="C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake"'
$vcpkg_triplet = '-DVCPKG_TARGET_TRIPLET="x86-windows-static"'
# since https://github.com/Microsoft/vcpkg/commit/0334365f516c5f229ff4fcf038c7d0190979a38a#diff-464a170117fa96bf98b2f8d224bf503c
# vcpkg need to have "C:\Tools\vcpkg\installed\x86-windows-static"
New-Item -Force -ItemType directory -Path "C:\Tools\vcpkg\installed\x86-windows-static"
$cmake_cnf="$vcpkg_toolchain", "$vcpkg_triplet", "-G`"$env:GENERATOR`"", "-DUA_FORCE_CPP:BOOL=$env:FORCE_CXX"
# Collect files for .zip packing
New-Item -ItemType directory -Path pack
Copy-Item LICENSE pack
Copy-Item AUTHORS pack
Copy-Item README.md pack
Write-Host -ForegroundColor Green "`n###################################################################"
Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with PubSub #####`n"
New-Item -ItemType directory -Path "build"
cd build
& cmake $cmake_cnf `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DUA_BUILD_EXAMPLES:BOOL=ON `
-DUA_ENABLE_DA:BOOL=ON `
-DUA_ENABLE_JSON_ENCODING:BOOL=ON `
-DUA_ENABLE_PUBSUB:BOOL=ON `
-DUA_ENABLE_PUBSUB_DELTAFRAMES:BOOL=ON `
-DUA_ENABLE_PUBSUB_INFORMATIONMODEL:BOOL=ON `
-DUA_ENABLE_SUBSCRIPTIONS_EVENTS:BOOL=ON `
-DUA_ENABLE_PUBSUB_MQTT:BOOL=ON `
-DUA_NAMESPACE_ZERO:STRING=REDUCED ..
& cmake --build . --config RelWithDebInfo
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
exit $LASTEXITCODE
}
cd ..
Remove-Item -Path build -Recurse -Force
Write-Host -ForegroundColor Green "`n###################################################################"
Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME without amalgamation #####`n"
New-Item -ItemType directory -Path "build"
cd build
& cmake $cmake_cnf `
-DBUILD_SHARED_LIBS:BOOL=OFF `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER-$env:CC_SHORTNAME-static" `
-DUA_BUILD_EXAMPLES:BOOL=ON `
-DUA_ENABLE_AMALGAMATION:BOOL=OFF ..
& cmake --build . --target install --config RelWithDebInfo
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0)
{
Write-Host -ForegroundColor Red "`n`n*** Make install failed. Exiting ... ***"
exit $LASTEXITCODE
}
cd ..
& 7z a -tzip open62541-$env:CC_SHORTNAME-static.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER-$env:CC_SHORTNAME-static\*"
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0)
{
Write-Host -ForegroundColor Red "`n`n*** Zipping failed. Exiting ... ***"
exit $LASTEXITCODE
}
Remove-Item -Path build -Recurse -Force
Write-Host -ForegroundColor Green "`n###################################################################"
Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME (.dll) #####`n"
New-Item -ItemType directory -Path "build"
cd build
& cmake $cmake_cnf `
-DBUILD_SHARED_LIBS:BOOL=ON `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER-$env:CC_SHORTNAME-dynamic" `
-DUA_BUILD_EXAMPLES:BOOL=ON `
-DUA_ENABLE_AMALGAMATION:BOOL=OFF ..
& cmake --build . --target install --config RelWithDebInfo
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0)
{
Write-Host -ForegroundColor Red "`n`n*** Make install failed. Exiting ... ***"
exit $LASTEXITCODE
}
cd ..
& 7z a -tzip open62541-$env:CC_SHORTNAME-dynamic.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER-$env:CC_SHORTNAME-static\*"
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0)
{
Write-Host -ForegroundColor Red "`n`n*** Zipping failed. Exiting ... ***"
exit $LASTEXITCODE
}
Remove-Item -Path build -Recurse -Force
# # do not cache log
# Remove-Item -Path c:\miktex\texmfs\data\miktex\log -Recurse -Force
} catch {
# Print a detailed error message
$FullException = ($_.Exception|format-list -force) | Out-String
Write-Host -ForegroundColor Red "`n------------------ Exception ------------------`n$FullException`n"
[Console]::Out.Flush()
# Wait a bit to make sure appveyor shows the error message
Start-Sleep 10
throw
}