forked from microsoft/msquic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-buildconfig.ps1
More file actions
144 lines (122 loc) · 3.79 KB
/
Copy pathget-buildconfig.ps1
File metadata and controls
144 lines (122 loc) · 3.79 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<#
.SYNOPSIS
This script provides a build config helper used by multiple build scripts.
.PARAMETER Config
The debug or release configuration to build for.
.PARAMETER Arch
The CPU architecture to build for.
.PARAMETER Platform
Specify which platform to build for
.PARAMETER Tls
The TLS library to use.
.PARAMETER ExtraArtifactDir
Add an extra classifier to the artifact directory to allow publishing alternate builds of same base library
#>
param (
[Parameter(Mandatory = $false)]
[ValidateSet("Debug", "Release")]
[string]$Config = "Debug",
[Parameter(Mandatory = $false)]
[ValidateSet("x86", "x64", "arm", "arm64", "arm64ec", "universal", "")]
[string]$Arch = "",
[Parameter(Mandatory = $false)]
[ValidateSet("gamecore_console", "uwp", "windows", "linux", "macos", "android", "ios", "")] # For future expansion
[string]$Platform = "",
[Parameter(Mandatory = $false)]
[ValidateSet("schannel", "openssl", "openssl3", "")]
[string]$Tls = "",
[Parameter(Mandatory = $false)]
[string]$ExtraArtifactDir = ""
)
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
if ($Platform -eq "android") {
if (!$IsLinux) {
Write-Error "Can only build android on linux"
}
if ($Arch -eq "") {
$Arch = "arm64"
}
}
if ($Platform -eq "ios") {
if (!$IsMacOS) {
Write-Error "Can only build ios on macOS"
}
if ($Arch -eq "") {
$Arch = "arm64"
}
}
if ("" -eq $Arch) {
if ($IsMacOS) {
$RunningArch = uname -m
if ("x86_64" -eq $RunningArch) {
$IsTranslated = sysctl -in sysctl.proc_translated
if ($IsTranslated) {
$Arch = "arm64"
} else {
$Arch = "x64"
}
} elseif ("arm64" -eq $RunningArch) {
$Arch = "arm64"
} else {
Write-Error "Unknown architecture"
}
} elseif ($IsLinux) {
$Arch = "$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)".ToLower()
} else {
$Arch = "x64"
}
}
# Default TLS based on current platform.
if ("" -eq $Tls) {
if ($IsWindows) {
$Tls = "schannel"
} else {
$Tls = "openssl"
try {
# If no Tls was specified, try to guess it based on default OpenSSL version
# This is more complicated in attempt to silently deal with missing openssl executable
#
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "openssl"
$pinfo.Arguments = "version"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$version = $p.StandardOutput.ReadToEnd()
if ($version -like "OpenSSL 3*")
{
$Tls = "openssl3"
}
} catch { }
}
}
if ("" -eq $Platform) {
if ($IsWindows) {
$Platform = "windows"
} elseif ($IsLinux) {
$Platform = "linux"
} elseif ($IsMacOS) {
$Platform = "macos"
} else {
Write-Error "Unsupported platform type!"
}
}
$RootDir = Split-Path $PSScriptRoot -Parent
$BaseArtifactsDir = Join-Path $RootDir "artifacts"
$ArtifactsDir = Join-Path $BaseArtifactsDir "bin" $Platform
if ([string]::IsNullOrWhitespace($ExtraArtifactDir)) {
$ArtifactsDir = Join-Path $ArtifactsDir "$($Arch)_$($Config)_$($Tls)"
} else {
$ArtifactsDir = Join-Path $ArtifactsDir "$($Arch)_$($Config)_$($Tls)_$($ExtraArtifactDir)"
}
return @{
Platform = $Platform
Tls = $Tls
Arch = $Arch
ArtifactsDir = $ArtifactsDir
}