diff options
Diffstat (limited to 'xmake/scripts')
| -rwxr-xr-x | xmake/scripts/download.ps1 | 27 | ||||
| -rwxr-xr-x | xmake/scripts/unzip.ps1 | 24 |
2 files changed, 51 insertions, 0 deletions
diff --git a/xmake/scripts/download.ps1 b/xmake/scripts/download.ps1 new file mode 100755 index 000000000..c19983699 --- /dev/null +++ b/xmake/scripts/download.ps1 @@ -0,0 +1,27 @@ +#!/usr/bin/env pwsh +#Requires -version 5 + +param ( + [string]$url, + [string]$outputfile +) + +& { + function writeErrorTip($msg) { + Write-Host $msg -BackgroundColor Red -ForegroundColor White + } + + $temppath = ([System.IO.Path]::GetTempPath(), $env:TMP, $env:TEMP, "$(Get-Location)" -ne $null)[0] + [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" + + function download { + try { + Invoke-Webrequest $url -OutFile $outputfile -UseBasicParsing + } catch { + writeErrorTip 'Download failed!' + throw + } + } + + download +} diff --git a/xmake/scripts/unzip.ps1 b/xmake/scripts/unzip.ps1 new file mode 100755 index 000000000..46947bfd3 --- /dev/null +++ b/xmake/scripts/unzip.ps1 @@ -0,0 +1,24 @@ +#!/usr/bin/env pwsh +#Requires -version 5 + +param ( + [string]$archivefile, + [string]$outputdir +) + +& { + function writeErrorTip($msg) { + Write-Host $msg -BackgroundColor Red -ForegroundColor White + } + + function unzip { + try { + Expand-Archive -Path $archivefile -DestinationPath $outputdir + } catch { + writeErrorTip 'Unzip failed!' + throw + } + } + + unzip +} |
