forked from microsoft/msquic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge-darwin.ps1
71 lines (51 loc) · 1.77 KB
/
merge-darwin.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
<#
.SYNOPSIS
This script merges all darwin artifacts into universal binaries
.PARAMETER Config
The debug or release configuration to merge.
.PARAMETER Tls
The TLS library to of the binaries to merge.
.EXAMPLE
build.ps1
#>
param (
[Parameter(Mandatory = $false)]
[ValidateSet("Debug", "Release")]
[string]$Config = "Debug",
[Parameter(Mandatory = $false)]
[ValidateSet("schannel", "openssl")]
[string]$Tls = "",
[Parameter(Mandatory = $false)]
[switch]$DeleteSource = $false
)
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
if (!$IsMacOS) {
Write-Error "This script can only be ran on macOS"
}
if ("" -eq $Tls) {
$Tls = "openssl"
}
# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent
# Important directory paths.
$BaseArtifactsDir = Join-Path $RootDir "artifacts"
$ArtifactsDir = Join-Path $BaseArtifactsDir "bin" "macos"
$X64ArtifactsDir = Join-Path $ArtifactsDir "x64_$($Config)_$($Tls)"
$Arm64ArtifactsDir = Join-Path $ArtifactsDir "arm64_$($Config)_$($Tls)"
$UniversalArtifactsDir = Join-Path $ArtifactsDir "universal_$($Config)_$($Tls)"
New-Item $UniversalArtifactsDir -ItemType Directory -Force | Out-Null
$X64Artifacts = Get-ChildItem -Path $X64ArtifactsDir
foreach ($X64Artifact in $X64Artifacts) {
$ArmArtifact = Join-Path $Arm64ArtifactsDir $X64Artifact.Name
if (!(Test-Path $ArmArtifact)) {
Write-Output "Missing $($X64Artifact.Name). Skipping"
continue
}
$UniversalArtifact = Join-Path $UniversalArtifactsDir $X64Artifact.Name
lipo -create -output $UniversalArtifact $X64Artifact $ArmArtifact
}
if ($DeleteSource) {
Remove-Item -Path $X64ArtifactsDir -Recurse -Force
Remove-Item -Path $Arm64ArtifactsDir -Recurse -Force
}