-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathPowershellNative.ps1
85 lines (66 loc) · 3.33 KB
/
PowershellNative.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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
[CmdletBinding()]
param (
[Parameter(Mandatory, ParameterSetName = 'Build')]
[ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm', 'linux-arm64', 'linux-musl-x64', 'linux-musl-arm64')]
[string]
$Arch,
[Parameter(Mandatory, ParameterSetName = 'Build')]
[ValidateSet('Release', 'Debug')]
[string]
$Configuration,
[switch] $Symbols,
[Parameter(Mandatory, ParameterSetName = 'Build')]
$RepoRoot,
[Parameter(Mandatory, ParameterSetName = 'Build')]
$TargetLocation
)
end {
Write-Verbose -Verbose "Starting PowerShellNative.ps1 Arch: $Arch, Config: $Configuration, Repo: $RepoRoot, Target: $TargetLocation"
Import-Module $RepoRoot/build.psm1 -Force
#$binOut = New-Item -Path $TargetLocation/$Arch -ItemType Directory -Force
$binOut = New-Item -Path $TargetLocation -ItemType Directory -Force
Write-Verbose "Created output directory: $binOut" -Verbose
if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx' -or $Arch -eq 'linux-musl-x64') {
Write-Verbose "Starting Build for: $Arch" -Verbose
Start-PSBootstrap
Start-BuildNativeUnixBinaries
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
$testResultPath = Join-Path $RepoRoot -ChildPath 'src/libpsl-native/test/native-tests.xml'
if (Test-Path $testResultPath) {
Copy-Item $testResultPath -Destination $TargetLocation -Verbose -Force
}
}
elseif ($Arch -eq 'linux-arm') {
Start-PSBootstrap -BuildLinuxArm
Start-BuildNativeUnixBinaries -BuildLinuxArm
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
}
elseif ($Arch -eq 'linux-arm64') {
Start-PSBootstrap -BuildLinuxArm64
Start-BuildNativeUnixBinaries -BuildLinuxArm64
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
}
elseif ($Arch -eq 'linux-musl-arm64') {
Start-PSBootstrap
Start-BuildNativeUnixBinaries -BuildAlpineArm64
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
}
else {
Write-Verbose "Starting Start-PSBootstrap" -Verbose
Start-PSBootstrap -BuildWindowsNative
Write-Verbose "Starting Start-BuildNativeWindowsBinaries" -Verbose
Start-BuildNativeWindowsBinaries -Configuration $Configuration -Arch $Arch -Clean
Write-Verbose "Completed Start-BuildNativeWindowsBinaries" -Verbose
$buildOutputPath = Join-Path $RepoRoot "src/powershell-win-core"
Compress-Archive -Path "$buildOutputPath/*.dll" -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
if ($Symbols.IsPresent) {
Compress-Archive -Path "$buildOutputPath/*.pdb" -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Update -Verbose
}
}
}