2023-03-18 00:25:35 +08:00
|
|
|
$VER=$args[0]
|
2023-08-13 23:56:58 +08:00
|
|
|
|
|
|
|
function println($msg) {
|
|
|
|
Write-Host $msg
|
|
|
|
}
|
|
|
|
|
|
|
|
println "VER=$VER"
|
2023-03-18 00:25:35 +08:00
|
|
|
|
|
|
|
$AX_ROOT=(Resolve-Path "$PSScriptRoot/../..").Path
|
2023-08-13 23:56:58 +08:00
|
|
|
println "AX_ROOT=$AX_ROOT"
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
$pwsh_ver = $PSVersionTable.PSVersion.ToString()
|
|
|
|
|
|
|
|
function mkdirs([string]$path) {
|
|
|
|
if (!(Test-Path $path -PathType Container)) {
|
|
|
|
New-Item $path -ItemType Directory 1>$null
|
2023-08-13 00:24:35 +08:00
|
|
|
}
|
2023-08-13 22:09:02 +08:00
|
|
|
}
|
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
function download_file($url, $out, $force = $false) {
|
|
|
|
if(Test-Path $out -PathType Leaf) {
|
|
|
|
if (!$force) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
Remove-Item $out
|
|
|
|
}
|
|
|
|
Write-Host "Downloading $url to $out ..."
|
|
|
|
if ($pwsh_ver -ge '7.0') {
|
|
|
|
curl -L $url -o $out
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Invoke-WebRequest -Uri $url -OutFile $out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_and_expand($url, $out, $dest) {
|
|
|
|
download_file $url $out
|
|
|
|
if($out.EndsWith('.zip')) {
|
|
|
|
Expand-Archive -Path $out -DestinationPath $dest
|
|
|
|
} elseif($out.EndsWith('.tar.gz')) {
|
|
|
|
if (!$dest.EndsWith('/')) {
|
|
|
|
mkdirs $dest
|
|
|
|
}
|
|
|
|
tar xvf "$out" -C $dest
|
|
|
|
} elseif($out.EndsWith('.sh')) {
|
|
|
|
chmod 'u+x' "$out"
|
|
|
|
mkdirs $dest
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# download version manifest
|
2023-08-13 23:58:18 +08:00
|
|
|
cd $AX_ROOT
|
2023-08-13 23:56:58 +08:00
|
|
|
|
|
|
|
$cwd = $(Get-Location).Path
|
|
|
|
|
|
|
|
$prefix = Join-Path $cwd "tmp/1kdist_$VER"
|
|
|
|
|
|
|
|
mkdirs $prefix
|
2023-08-13 22:09:02 +08:00
|
|
|
|
2023-08-13 23:58:18 +08:00
|
|
|
# ensure yaml parser module
|
|
|
|
if ($null -eq (Get-Module -ListAvailable -Name powershell-yaml)) {
|
|
|
|
Install-Module -Name powershell-yaml -Force -Repository PSGallery -Scope CurrentUser
|
|
|
|
}
|
2023-08-13 22:09:02 +08:00
|
|
|
|
2023-08-13 23:58:18 +08:00
|
|
|
# check upstream prebuilts version
|
2023-08-13 23:56:58 +08:00
|
|
|
download_file "https://github.com/axmolengine/buildware/releases/download/$VER/verlist.yml" "./tmp/verlist.yml" $true
|
|
|
|
$newVerList = ConvertFrom-Yaml -Yaml (Get-Content './tmp/verlist.yml' -raw)
|
|
|
|
if ($newVerList.GetType() -eq [string]) {
|
|
|
|
throw "Download version manifest file verlist.yml fail"
|
2023-08-13 22:09:02 +08:00
|
|
|
}
|
|
|
|
|
2023-08-13 23:58:18 +08:00
|
|
|
$myVerList = ConvertFrom-Yaml -Yaml (Get-Content './thirdparty/prebuilts.yml' -raw)
|
2023-08-13 22:09:02 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
function update_lib
|
2023-08-13 22:09:02 +08:00
|
|
|
{
|
2023-08-13 23:56:58 +08:00
|
|
|
$lib_name=$args[0]
|
|
|
|
$lib_folder=$args[1]
|
2023-08-13 22:09:02 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
$myVer = $myVerList[$lib_name]
|
|
|
|
if (($newVerList[$lib_name] -eq $myVer) -and ("$env:FORCE_UPDATE" -ne 'true')) {
|
|
|
|
println "No update for lib: $lib_name, version: $myVer, skip it"
|
|
|
|
return 0
|
|
|
|
}
|
2023-08-13 22:09:02 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
$lib_dir="./thirdparty/$lib_folder$lib_name"
|
|
|
|
$prebuilt_dir="$lib_dir/prebuilt"
|
|
|
|
$inc_dir="$lib_dir/include"
|
|
|
|
|
|
|
|
println "Updating lib files for ${lib_dir} from $prefix/$lib_name ..."
|
2023-08-13 23:58:18 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
# https://github.com/axmolengine/build1k/releases/download/v57/angle.zip
|
|
|
|
download_and_expand "https://github.com/axmolengine/build1k/releases/download/$VER/$lib_name.zip" "$prefix/$lib_name.zip" "$prefix"
|
2023-08-13 23:58:18 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
Remove-Item $prebuilt_dir -Recurse -Force
|
|
|
|
Copy-Item $prefix/$lib_name/prebuilt $lib_dir/ -Container -Recurse
|
|
|
|
|
|
|
|
if (Test-Path "$prefix/$lib_name/include" -PathType Container) {
|
|
|
|
println "Update inc files for ${lib_dir}"
|
|
|
|
Remove-Item $inc_dir -Recurse -Force
|
|
|
|
Copy-Item $prefix/$lib_name/include $lib_dir/ -Container -Recurse
|
2023-08-13 23:58:18 +08:00
|
|
|
}
|
2023-08-13 23:56:58 +08:00
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
println "Updating libs ..."
|
|
|
|
|
|
|
|
$libs_list = @('angle', 'curl', 'jpeg-turbo', 'openssl', 'zlib')
|
|
|
|
|
|
|
|
# update libs
|
|
|
|
$updateCount = 0
|
|
|
|
foreach($lib_name in $libs_list) {
|
|
|
|
$updateCount += $(update_lib $lib_name)
|
|
|
|
}
|
|
|
|
|
|
|
|
$updateCount += $(update_lib luajit lua/)
|
|
|
|
|
|
|
|
# update README.md
|
|
|
|
$content = $(Get-Content -Path ./thirdparty/README.md.in -raw)
|
|
|
|
foreach ($item in $newVerList.GetEnumerator() )
|
|
|
|
{
|
|
|
|
$key = ([Regex]::Replace($item.Name, '-', '_')).ToUpper()
|
|
|
|
$key = "${key}_VERSION"
|
|
|
|
$content = $content -replace "\$\{$key\}",$item.Value
|
|
|
|
}
|
|
|
|
Set-Content -Path ./thirdparty/README.md -Value "$content"
|
|
|
|
Copy-Item -Path './tmp/verlist.yml' './thirdparty/prebuilts.yml' -Force
|
|
|
|
|
|
|
|
println "Total update lib count $updateCount"
|
|
|
|
|
|
|
|
if ($updateCount -eq 0) {
|
2023-03-18 00:25:35 +08:00
|
|
|
if ("$env.RUNNER_OS" -ne "") {
|
2023-08-13 23:56:58 +08:00
|
|
|
Write-Output "AX_PREBUILTS_NO_UPDATE=true" >> $GITHUB_ENV
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
|
|
|
}
|