2023-03-18 00:25:35 +08:00
|
|
|
$VER=$args[0]
|
2023-08-11 20:13:50 +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-11 20:13:50 +08:00
|
|
|
println "AX_ROOT=$AX_ROOT"
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:20:20 +08:00
|
|
|
$pwsh_ver = $PSVersionTable.PSVersion.ToString()
|
|
|
|
|
|
|
|
function mkdirs([string]$path) {
|
|
|
|
if (!(Test-Path $path -PathType Container)) {
|
|
|
|
New-Item $path -ItemType Directory 1>$null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
cd $AX_ROOT
|
|
|
|
mkdirs ./tmp
|
|
|
|
|
|
|
|
# ensure yaml parser module
|
|
|
|
if ($null -eq (Get-Module -ListAvailable -Name powershell-yaml)) {
|
|
|
|
Install-Module -Name powershell-yaml -Force -Repository PSGallery -Scope CurrentUser
|
|
|
|
}
|
|
|
|
|
|
|
|
# check upstream prebuilts version
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
$myVerList = ConvertFrom-Yaml -Yaml (Get-Content './thirdparty/prebuilts.yml' -raw)
|
|
|
|
|
2023-03-18 00:25:35 +08:00
|
|
|
function update_lib
|
|
|
|
{
|
|
|
|
$lib_name=$args[0]
|
|
|
|
$lib_folder=$args[1]
|
2023-08-11 18:20:20 +08:00
|
|
|
|
|
|
|
$myVer = $myVerList[$lib_name]
|
|
|
|
if ($newVerList[$lib_name] -eq $myVer) {
|
2023-08-11 20:13:50 +08:00
|
|
|
println "No update for lib: $lib_name, version: $myVer, skip it"
|
|
|
|
return 0
|
2023-08-11 18:20:20 +08:00
|
|
|
}
|
|
|
|
|
2023-03-18 00:25:35 +08:00
|
|
|
$lib_dir="./thirdparty/$lib_folder$lib_name"
|
|
|
|
$prebuilt_dir="$lib_dir/prebuilt"
|
|
|
|
$inc_dir="$lib_dir/include"
|
|
|
|
|
2023-08-11 20:13:50 +08:00
|
|
|
println "Updating lib files for ${lib_dir} from ./tmp/package_$VER/$lib_name ..."
|
2023-08-11 18:20:20 +08:00
|
|
|
|
2023-08-11 18:32:04 +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" "./tmp/package_$VER/$lib_name.zip" "./tmp/package_$VER"
|
2023-08-11 18:20:20 +08:00
|
|
|
|
2023-08-11 18:32:04 +08:00
|
|
|
Remove-Item $prebuilt_dir -Recurse -Force
|
2023-08-11 20:04:55 +08:00
|
|
|
Copy-Item ./tmp/package_$VER/$lib_name/prebuilt $lib_dir/ -Container -Recurse
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:32:04 +08:00
|
|
|
if (Test-Path "./tmp/package_$VER/$lib_name/include" -PathType Container) {
|
2023-08-11 20:13:50 +08:00
|
|
|
println "Update inc files for ${lib_dir}"
|
2023-08-11 18:32:04 +08:00
|
|
|
Remove-Item $inc_dir -Recurse -Force
|
2023-08-11 20:04:55 +08:00
|
|
|
Copy-Item ./tmp/package_$VER/$lib_name/include $lib_dir/ -Container -Recurse
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
2023-08-11 18:20:20 +08:00
|
|
|
|
2023-08-11 20:13:50 +08:00
|
|
|
return 1
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
|
|
|
|
2023-08-11 20:13:50 +08:00
|
|
|
println "Updating libs ..."
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:20:20 +08:00
|
|
|
$libs_list = @('angle', 'curl', 'jpeg-turbo', 'openssl', 'zlib')
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:20:20 +08:00
|
|
|
# update libs
|
2023-08-11 20:13:50 +08:00
|
|
|
$updateCount = 0
|
2023-08-11 18:20:20 +08:00
|
|
|
foreach($lib_name in $libs_list) {
|
2023-08-11 20:13:50 +08:00
|
|
|
$updateCount += $(update_lib $lib_name)
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
|
|
|
|
2023-08-11 20:13:50 +08:00
|
|
|
$updateCount += $(update_lib luajit lua/)
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:20:20 +08:00
|
|
|
# update README.md
|
|
|
|
$content = $(Get-Content -Path ./thirdparty/README.md.in -raw)
|
|
|
|
foreach ($item in $newVerList.GetEnumerator() )
|
2023-03-18 00:25:35 +08:00
|
|
|
{
|
2023-08-11 18:20:20 +08:00
|
|
|
$key = ([Regex]::Replace($item.Name, '-', '_')).ToUpper()
|
|
|
|
$key = "${key}_VERSION"
|
|
|
|
$content = $content -replace "\$\{$key\}",$item.Value
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
2023-08-11 18:20:20 +08:00
|
|
|
Set-Content -Path ./thirdparty/README.md -Value "$content"
|
|
|
|
Copy-Item -Path './tmp/verlist.yml' './thirdparty/prebuilts.yml' -Force
|
2023-03-18 00:25:35 +08:00
|
|
|
|
2023-08-11 18:20:20 +08:00
|
|
|
if ($updateCount -eq 0) {
|
2023-08-11 20:13:50 +08:00
|
|
|
println "No any lib need update."
|
2023-03-18 00:25:35 +08:00
|
|
|
if ("$env.RUNNER_OS" -ne "") {
|
2023-08-11 20:13:50 +08:00
|
|
|
Write-Output "AX_PREBUILTS_NO_UPDATE=true" >> $GITHUB_ENV
|
2023-03-18 00:25:35 +08:00
|
|
|
}
|
|
|
|
}
|