forked from SharpGenTools/SharpGenTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
114 lines (94 loc) · 3.15 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
Param(
[string] $Configuration = "Debug",
[switch] $NugetPublish = $false,
[switch] $SkipUnitTests = $false,
[switch] $SkipOuterloopTests = $false
)
$env:MSBuildEnableWorkloadResolver=$false
$PackageVersion = git describe --tags --abbrev=0
if (!$NugetPublish) {
$PackageVersion = $PackageVersion + "-local"
}
dotnet dotnet-TagToVersion -t $PackageVersion
dotnet pack -c $Configuration
if ($LastExitCode -ne 0) {
exit 1
}
$RepoRoot = Split-Path -parent $PSCommandPath
mkdir $RepoRoot/artifacts/coverage -ErrorAction SilentlyContinue
if (!$SkipUnitTests) {
Write-Debug "Running Unit Tests"
if (!(./build/Run-UnitTest -Target "$RepoRoot/SharpGen.UnitTests/SharpGen.UnitTests.csproj" -Name "UnitTests" -Configuration $Configuration -RepoRoot $RepoRoot)) {
Write-Error "Unit Tests Failed"
exit 1
}
}
if (!$SkipOuterloopTests -and !($Configuration -eq "Release")) {
Write-Debug "Deploying test packages"
if (!(./build/deploy-test-packages -PackedConfiguration $Configuration -Project "SdkTests")) {
Write-Error "Failed to deploy test packages"
exit 1
}
Write-Debug "Building outerloop native libraries"
if (!(./build/build-outerloop-native -RepoRoot $RepoRoot)) {
Write-Error "Failed to build outerloop native projects"
exit 1
}
$SdkVersion = & "$RepoRoot/build/Get-SharpGenToolsVersion"
# Peter Franta, CC BY-SA 3.0, https://stackoverflow.com/a/10242325
function CartesianProduct-Lists
{
[Diagnostics.CodeAnalysis.SuppressMessage("PSUseApprovedVerbs", "", Scope="function")]
param($Lists)
function Make-List
{
param($Head, $Tail)
if ($Head -is [Object[]])
{
# List already so just extend
$Result = $Head + $Tail
}
else
{
# Create List
$Result = @($Head, $Tail)
}
,$Result
}
# if Head..Tail
if (@($Lists).Count -gt 1)
{
$Head = $Lists[0]
$Next = $Lists[1]
$Result = @()
foreach ($HeadItem in $Head)
{
foreach ($NextItem in $Next)
{
$Result += ,(Make-List $HeadItem $NextItem)
}
}
if (@($Lists).Count -gt 2)
{
$Index = $Lists.Count - 1
$Tail = $Lists[2..$Index]
$Result = ,$Result + $Tail
$Result = CartesianProduct-Lists $Result
}
,$Result
}
}
$managedTests = "Interface", "Struct", "Functions"
$tfms = "net6.0"
$platforms = "x86", "x64"
$matrix = CartesianProduct-Lists @($tfms, $platforms)
Write-Debug "Building and running outerloop tests"
foreach ($testArgs in $matrix) {
$tfm = $testArgs[0]
$platform = $testArgs[1]
if (!(./build/run-outerloop-tests -Projects $managedTests -TargetFramework $tfm -Platform $platform -Version $SdkVersion -RepoRoot $RepoRoot)) {
Write-Error "Outerloop tests failed"
exit 1
}
}
}