forked from Crockan/MercuryToolbox
chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
function Get-ToolboxCommandNames {
|
||||
return @(
|
||||
'cjson',
|
||||
'ison',
|
||||
'isonl',
|
||||
'zon',
|
||||
'tonl',
|
||||
'mhash',
|
||||
'jsonlgrep',
|
||||
'jsonshape',
|
||||
'recent',
|
||||
'pathshadow',
|
||||
'portping',
|
||||
'portunlock',
|
||||
'msudo',
|
||||
'asmtype',
|
||||
'asmmember',
|
||||
'asmref',
|
||||
'asmapi',
|
||||
'asmflow',
|
||||
'llvmobjdump',
|
||||
'llvmreadobj',
|
||||
'llvmnm',
|
||||
'peexports',
|
||||
'peimports',
|
||||
'pecalls',
|
||||
'pesig',
|
||||
'pestrrefs',
|
||||
'drvshape',
|
||||
'ioctlscan',
|
||||
'binmeta',
|
||||
'fileprobe',
|
||||
'outline',
|
||||
'codeshape',
|
||||
'refs',
|
||||
'snip',
|
||||
'defsnip',
|
||||
'ctxpack',
|
||||
'chunkcat',
|
||||
'hitsnip',
|
||||
'diagpick',
|
||||
'logshape',
|
||||
'stringscan',
|
||||
'toon',
|
||||
'csvshape',
|
||||
'sqliteshape',
|
||||
'sqlshape',
|
||||
'unityasset',
|
||||
'unityprobe',
|
||||
'unitydiag',
|
||||
'envdiff',
|
||||
'proctree',
|
||||
'sysshape',
|
||||
'runprobe',
|
||||
'await',
|
||||
'argv',
|
||||
'config',
|
||||
'gitshape',
|
||||
'reposhape',
|
||||
'dotnetshape',
|
||||
'unlock'
|
||||
)
|
||||
}
|
||||
|
||||
function Get-ToolboxSlimBuildCommandNames {
|
||||
return @(
|
||||
'codeshape',
|
||||
'refs',
|
||||
'defsnip'
|
||||
)
|
||||
}
|
||||
|
||||
function Resolve-ToolboxProfileName {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Configuration
|
||||
)
|
||||
|
||||
switch ($Configuration) {
|
||||
'Debug' { return 'debug' }
|
||||
'Release' { return 'release' }
|
||||
'ReleaseFast' { return 'release-fast' }
|
||||
'ReleaseSize' { return 'release-size' }
|
||||
default { throw "Unsupported configuration: $Configuration" }
|
||||
}
|
||||
}
|
||||
|
||||
function Get-ToolboxBuildArguments {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Configuration,
|
||||
[string[]]$Packages = @()
|
||||
)
|
||||
|
||||
$arguments = @('build')
|
||||
if ($Packages.Count -gt 0) {
|
||||
foreach ($package in $Packages) {
|
||||
$arguments += @('-p', $package)
|
||||
}
|
||||
}
|
||||
else {
|
||||
$arguments += '--workspace'
|
||||
}
|
||||
|
||||
switch ($Configuration) {
|
||||
'Release' {
|
||||
$arguments += '--release'
|
||||
}
|
||||
'ReleaseFast' {
|
||||
$arguments += @('--profile', 'release-fast')
|
||||
}
|
||||
'ReleaseSize' {
|
||||
$arguments += @('--profile', 'release-size')
|
||||
}
|
||||
}
|
||||
|
||||
return $arguments
|
||||
}
|
||||
|
||||
function Format-ToolboxNativeCommand {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$FilePath,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string[]]$ArgumentList
|
||||
)
|
||||
|
||||
$parts = [System.Collections.Generic.List[string]]::new()
|
||||
foreach ($part in @($FilePath) + $ArgumentList) {
|
||||
if ([string]::IsNullOrEmpty($part)) {
|
||||
$parts.Add("''")
|
||||
continue
|
||||
}
|
||||
|
||||
if ($part.IndexOfAny([char[]]" `t`r`n'`"") -ge 0) {
|
||||
$parts.Add("'" + $part.Replace("'", "''") + "'")
|
||||
continue
|
||||
}
|
||||
|
||||
$parts.Add($part)
|
||||
}
|
||||
|
||||
return ($parts -join ' ')
|
||||
}
|
||||
|
||||
function Invoke-StrictToolboxNative {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$FilePath,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string[]]$ArgumentList
|
||||
)
|
||||
|
||||
& $FilePath @ArgumentList
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$commandLine = Format-ToolboxNativeCommand -FilePath $FilePath -ArgumentList $ArgumentList
|
||||
throw "Command failed with exit code ${LASTEXITCODE} in '$((Get-Location).Path)': $commandLine"
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-ToolboxBuild {
|
||||
param(
|
||||
[string]$CargoPath = 'cargo',
|
||||
[ValidateSet('Debug', 'Release', 'ReleaseFast', 'ReleaseSize')]
|
||||
[string]$Configuration = 'ReleaseFast',
|
||||
[switch]$SkipSlimBinaryRebuild
|
||||
)
|
||||
|
||||
Invoke-StrictToolboxNative -FilePath $CargoPath -ArgumentList (Get-ToolboxBuildArguments -Configuration $Configuration)
|
||||
|
||||
if ($SkipSlimBinaryRebuild -or $Configuration -eq 'Debug') {
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($commandName in Get-ToolboxSlimBuildCommandNames) {
|
||||
Invoke-StrictToolboxNative -FilePath $CargoPath -ArgumentList (
|
||||
Get-ToolboxBuildArguments -Configuration $Configuration -Packages @($commandName)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user