Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build.ps1] Set the default architecture using an environment variable #104474

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Param(
[switch]$coverage,
[string]$testscope,
[switch]$testnobuild,
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()),
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch,
[switch]$cross = $false,
[string][Alias('s')]$subset,
[ValidateSet("Debug","Release","Checked")][string][Alias('rc')]$runtimeConfiguration,
Expand All @@ -27,11 +27,19 @@ Param(
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)

function Get-Default-Arch() {
if ($env:DOTNET_RUNTIME_BUILD_PS1_DEFAULT_ARCH) {
return $env:DOTNET_RUNTIME_BUILD_PS1_DEFAULT_ARCH
}

return [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()
}

function Get-Help() {
Write-Host "Common settings:"
Write-Host " -arch (-a) Target platform: x86, x64, arm, arm64, or wasm."
Write-Host " Pass a comma-separated list to build for multiple architectures."
Write-Host (" [Default: {0} (Depends on your console's architecture.)]" -f [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())
Write-Host (" [Default: {0} (Depends on your console's architecture or the DOTNET_RUNTIME_BUILD_PS1_DEFAULT_ARCH environment variable.)]" -f @(Get-Default-Arch))
Write-Host " -binaryLog (-bl) Output binary log."
Write-Host " -configuration (-c) Build configuration: Debug, Release or Checked."
Write-Host " Checked is exclusive to the CLR subset. It is the same as Debug, except code is"
Expand Down Expand Up @@ -143,6 +151,10 @@ if ($subset -eq 'help') {
exit 0
}

if (-not $arch) {
$arch = Get-Default-Arch
}

# Lower-case the passed in OS string.
if ($os) {
$os = $os.ToLowerInvariant()
Expand Down