forked from microsoft/msquic
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper script for grabbing build config and artifact directory fo…
…r local machine (microsoft#1650) * Add helper script for grabbing build config and artifact directory for local machine * Make script only a single purpose * Allow empty parameter * Don't pass a default for platform
- Loading branch information
Showing
4 changed files
with
120 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<# | ||
.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")] | ||
[string]$Arch = "", | ||
|
||
[Parameter(Mandatory = $false)] | ||
[ValidateSet("uwp", "windows", "linux", "macos", "")] # For future expansion | ||
[string]$Platform = "", | ||
|
||
[Parameter(Mandatory = $false)] | ||
[ValidateSet("schannel", "openssl")] | ||
[string]$Tls = "", | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$ExtraArtifactDir = "" | ||
) | ||
|
||
Set-StrictMode -Version 'Latest' | ||
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' | ||
|
||
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" | ||
} | ||
} else { | ||
$Arch = "x64" | ||
} | ||
} | ||
|
||
# Default TLS based on current platform. | ||
if ("" -eq $Tls) { | ||
if ($IsWindows) { | ||
$Tls = "schannel" | ||
} else { | ||
$Tls = "openssl" | ||
} | ||
} | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters