axmol/tools/ci/genbindings.ps1

67 lines
1.9 KiB
PowerShell
Raw Normal View History

2023-09-26 10:32:53 +08:00
$myRoot = $PSScriptRoot
2023-09-26 09:50:25 +08:00
$llvm_ver = '15.0.7'
2023-09-26 10:32:53 +08:00
$AX_ROOT = (Resolve-Path $myRoot/../..).Path
# ensure prebuilt lib downloaded
Push-Location $AX_ROOT
$build_script = Join-Path $AX_ROOT 'build.ps1'
2024-01-08 22:55:15 +08:00
&$build_script -c
Pop-Location
(Get-Command python.exe).Path
2023-02-14 23:30:44 +08:00
pip install PyYAML Cheetah3
2023-09-26 10:32:53 +08:00
## setup ndk
$setup_script = (Resolve-Path $AX_ROOT/setup.ps1).Path
2023-09-26 12:47:28 +08:00
echo "before setup py_ver: $(python -V), PATH=$env:PATH"
2023-09-26 12:52:00 +08:00
. $setup_script -p android
2023-09-26 12:47:28 +08:00
echo "after setup py_ver: $(python -V), PATH=$env:PATH"
2023-09-26 10:46:22 +08:00
2023-09-26 10:32:53 +08:00
echo "$ndk_root=$ndk_root"
2024-02-02 00:42:42 +08:00
$prefix = Join-Path $AX_ROOT 'cache'
2023-09-26 10:32:53 +08:00
$llvm_out = Join-Path $prefix "llvmorg-$llvm_ver.zip"
2023-02-14 23:30:44 +08:00
## download win64 libclang.dll
2023-09-26 11:09:50 +08:00
$b1k.mkdirs($prefix)
2024-02-02 00:42:42 +08:00
download_and_expand -url "https://github.com/simdsoft/1kiss/releases/download/llvmorg-$llvm_ver/llvmorg-$llvm_ver.zip" -out "$llvm_out" -dest $prefix
2023-09-26 10:32:53 +08:00
Copy-Item "$prefix/llvmorg-$llvm_ver/llvm/prebuilt/windows/x64/libclang.dll" -Destination "$AX_ROOT/tools/bindings-generator/libclang"
2023-06-12 10:26:08 +08:00
## ensure $env:AX_ROOT/core/axmolver.h exists
2023-09-26 10:32:53 +08:00
echo "AX_ROOT=$AX_ROOT"
if (!(Test-Path "$AX_ROOT/core/axmolver.h" -PathType Leaf)) {
$content = [System.IO.File]::ReadAllText("$AX_ROOT/core/axmolver.h.in")
$content = $content.Replace('@AX_GIT_PRESENT@', '0')
[System.IO.File]::WriteAllText("$AX_ROOT/core/axmolver.h")
2023-06-12 10:26:08 +08:00
}
## run genbindings.py
2023-09-26 10:32:53 +08:00
Push-Location $AX_ROOT/tools/tolua
2023-02-14 23:30:44 +08:00
2022-08-09 09:48:03 +08:00
python genbindings.py --ndk_root "$ndk_root"
2024-02-02 00:15:06 +08:00
$succeed = $?
2022-01-01 21:56:55 +08:00
2023-09-26 10:32:53 +08:00
Pop-Location
Push-Location $AX_ROOT
2024-02-02 00:15:06 +08:00
if ($succeed -and $env:GITHUB_ACTIONS -eq 'true') {
$git_status = "$(git status)"
$no_changes = $git_status.IndexOf('modified:') -eq -1 # -and $git_status.IndexOf('deleted:') -eq -1 -and $git_status.IndexOf('Untracked', [StringComparison]::OrdinalIgnoreCase) -eq -1
if ($no_changes) {
echo "BINDING_NO_CHANGES=true" >> ${env:GITHUB_ENV}
} else {
echo "LAST_COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> ${env:GITHUB_ENV}
}
}
Pop-Location
2024-02-02 00:15:06 +08:00
if(!$succeed) {
throw "Generating lua bindings fails"
}