2018-01-30 09:20:44 +08:00
|
|
|
Set-PSDebug -Trace 1
|
2018-01-15 14:38:09 +08:00
|
|
|
$python = "C:\\Python27\\python.exe"
|
|
|
|
|
|
|
|
Write-Host "Set environment"
|
|
|
|
# gradlew
|
|
|
|
$env:ANDROID_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
|
|
|
|
$env:ANDROID_NDK_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
|
|
|
|
# gen-libs
|
|
|
|
$env:ANDROID_SDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
|
|
|
|
$env:NDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
|
|
|
|
|
2018-10-19 18:10:54 +08:00
|
|
|
function Retry-Command {
|
|
|
|
[CmdletBinding()]
|
|
|
|
Param(
|
|
|
|
[Parameter(Position=0, Mandatory=$true)]
|
|
|
|
[scriptblock]$ScriptBlock,
|
|
|
|
|
|
|
|
[Parameter(Position=1, Mandatory=$false)]
|
|
|
|
[int]$Maximum = 5
|
|
|
|
)
|
|
|
|
|
|
|
|
Begin {
|
|
|
|
$cnt = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
Process {
|
|
|
|
do {
|
|
|
|
$cnt++
|
|
|
|
try {
|
|
|
|
$ScriptBlock.Invoke()
|
|
|
|
return
|
|
|
|
} catch {
|
|
|
|
Write-Error $_.Exception.InnerException.Message -ErrorAction Continue
|
|
|
|
}
|
|
|
|
} while ($cnt -lt $Maximum)
|
|
|
|
|
|
|
|
# Throw an error after $Maximum unsuccessful invocations. Doesn't need
|
|
|
|
# a condition, since the function returns upon successful invocation.
|
|
|
|
throw 'Execution failed.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-15 14:38:09 +08:00
|
|
|
function PushAndroidArtifacts
|
|
|
|
{
|
|
|
|
# https://www.appveyor.com/docs/packaging-artifacts/
|
|
|
|
$root = Resolve-Path app\build\outputs\apk; [IO.Directory]::GetFiles($root.Path, '*.*', 'AllDirectories') | % { Push-AppveyorArtifact $_ -FileName $_.Substring($root.Path.Length + 1) -DeploymentName to-publish }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
If ($env:build_type -eq "android_cpp_tests") {
|
|
|
|
Write-Host "Build tests\cpp-tests"
|
|
|
|
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-tests\proj.android\
|
2018-10-19 18:10:54 +08:00
|
|
|
Retry-Command -ScriptBlock {
|
|
|
|
& ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
|
|
|
|
} -Maximum 5
|
2018-09-25 11:16:04 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
PushAndroidArtifacts
|
|
|
|
Pop-Location
|
|
|
|
|
|
|
|
} elseif ($env:build_type -eq "android_lua_tests") {
|
|
|
|
Write-Host "Build tests\lua-test"
|
|
|
|
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\lua-tests\project\proj.android\
|
|
|
|
# tocheck, release mode failed on "LuaTests:mergeReleaseAssets"
|
2018-10-19 18:10:54 +08:00
|
|
|
Retry-Command -ScriptBlock {
|
|
|
|
& ./gradlew assembleDebug -PPROP_BUILD_TYPE=ndk-build --parallel --info
|
|
|
|
} -Maximum 5
|
|
|
|
|
2018-01-15 14:38:09 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
PushAndroidArtifacts
|
|
|
|
Pop-Location
|
|
|
|
|
|
|
|
} elseif ($env:build_type -eq "android_cpp_empty_test") {
|
|
|
|
Write-Host "Build tests\cpp-empty-test"
|
|
|
|
Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-empty-test\proj.android\
|
2018-10-19 18:10:54 +08:00
|
|
|
Retry-Command -ScriptBlock {
|
|
|
|
& ./gradlew assembleRelease
|
|
|
|
} -Maximum 5
|
2018-01-15 14:38:09 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
PushAndroidArtifacts
|
|
|
|
Pop-Location
|
|
|
|
|
|
|
|
} elseif ($env:build_type -eq "android_cocos_new_test") {
|
|
|
|
Write-Host "Create new project cocos_new_test"
|
|
|
|
& $python -u tools\cocos2d-console\bin\cocos.py --agreement n new -l cpp -p my.pack.qqqq cocos_new_test
|
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
|
|
|
Write-Host "Build cocos_new_test"
|
|
|
|
Push-Location $env:APPVEYOR_BUILD_FOLDER\cocos_new_test\proj.android\
|
2018-10-19 18:10:54 +08:00
|
|
|
Retry-Command -ScriptBlock {
|
|
|
|
& ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
|
|
|
|
} -Maximum 5
|
|
|
|
|
2018-01-15 14:38:09 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
PushAndroidArtifacts
|
|
|
|
Pop-Location
|
|
|
|
# TODO: uncomment when fixed
|
|
|
|
# } elseif ($env:build_type -eq "android_gen_libs") {
|
|
|
|
# Write-Host "Build cocos gen-libs"
|
|
|
|
# & $python -u tools\cocos2d-console\bin\cocos.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n
|
|
|
|
# if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
2018-09-25 11:16:04 +08:00
|
|
|
} elseif ($env:build_type -eq "windows32_cmake_test") {
|
|
|
|
Write-Host "Build tests project by cmake"
|
2018-01-30 09:20:44 +08:00
|
|
|
|
2018-09-25 11:16:04 +08:00
|
|
|
& mkdir $env:APPVEYOR_BUILD_FOLDER\win32-build
|
|
|
|
# if ($lastexitcode -ne 0) {throw} # mkdir return no-zero
|
2018-01-30 09:20:44 +08:00
|
|
|
|
2018-09-25 11:16:04 +08:00
|
|
|
Push-Location $env:APPVEYOR_BUILD_FOLDER\win32-build
|
2018-07-25 10:08:53 +08:00
|
|
|
& cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
|
|
|
& cmake --build . --config Release
|
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
2018-09-25 11:16:04 +08:00
|
|
|
& 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\win32-build\bin\
|
2018-01-30 09:20:44 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
|
|
|
Push-AppveyorArtifact release_win32.7z
|
2018-09-25 11:16:04 +08:00
|
|
|
Pop-Location
|
2018-01-15 14:38:09 +08:00
|
|
|
}
|
|
|
|
Else {
|
2018-09-25 11:16:04 +08:00
|
|
|
# default, windows32_sln_test
|
2018-01-30 09:20:44 +08:00
|
|
|
& msbuild $env:APPVEYOR_BUILD_FOLDER\build\cocos2d-win32.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m /consoleloggerparameters:"PerformanceSummary;NoSummary"
|
|
|
|
|
2018-01-15 14:38:09 +08:00
|
|
|
if ($lastexitcode -ne 0) {throw}
|
2018-01-30 09:20:44 +08:00
|
|
|
& 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\build\Release.win32\
|
|
|
|
if ($lastexitcode -ne 0) {throw}
|
|
|
|
|
|
|
|
Push-AppveyorArtifact release_win32.7z
|
2018-01-15 14:38:09 +08:00
|
|
|
}
|