build.ps1 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Set-PSDebug -Trace 1
  2. $python = "C:\\Python27\\python.exe"
  3. Write-Host "Set environment"
  4. # gradlew
  5. $env:ANDROID_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
  6. $env:ANDROID_NDK_HOME=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
  7. # gen-libs
  8. $env:ANDROID_SDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-sdk"
  9. $env:NDK_ROOT=$env:APPVEYOR_BUILD_FOLDER + "\..\android-ndk-r16b"
  10. function PushAndroidArtifacts
  11. {
  12. # https://www.appveyor.com/docs/packaging-artifacts/
  13. $root = Resolve-Path app\build\outputs\apk; [IO.Directory]::GetFiles($root.Path, '*.*', 'AllDirectories') | % { Push-AppveyorArtifact $_ -FileName $_.Substring($root.Path.Length + 1) -DeploymentName to-publish }
  14. }
  15. If ($env:build_type -eq "android_cpp_tests") {
  16. Write-Host "Build tests\cpp-tests"
  17. Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-tests\proj.android\
  18. & ./gradlew build
  19. if ($lastexitcode -ne 0) {throw}
  20. PushAndroidArtifacts
  21. Pop-Location
  22. } elseif ($env:build_type -eq "android_cpp_empty_test") {
  23. Write-Host "Build tests\cpp-empty-test"
  24. Push-Location $env:APPVEYOR_BUILD_FOLDER\tests\cpp-empty-test\proj.android\
  25. & ./gradlew build
  26. if ($lastexitcode -ne 0) {throw}
  27. PushAndroidArtifacts
  28. Pop-Location
  29. } elseif ($env:build_type -eq "android_cocos_new_test") {
  30. Write-Host "Create new project cocos_new_test"
  31. & $python -u tools\cocos2d-console\bin\cocos.py --agreement n new -l cpp -p my.pack.qqqq cocos_new_test
  32. if ($lastexitcode -ne 0) {throw}
  33. Write-Host "Build cocos_new_test"
  34. Push-Location $env:APPVEYOR_BUILD_FOLDER\cocos_new_test\proj.android\
  35. & ./gradlew build
  36. if ($lastexitcode -ne 0) {throw}
  37. PushAndroidArtifacts
  38. Pop-Location
  39. # TODO: uncomment when fixed
  40. # } elseif ($env:build_type -eq "android_gen_libs") {
  41. # Write-Host "Build cocos gen-libs"
  42. # & $python -u tools\cocos2d-console\bin\cocos.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n
  43. # if ($lastexitcode -ne 0) {throw}
  44. } elseif ($env:build_type -eq "windows32_cocos_new_test") {
  45. Write-Host "Create new project windows32_cocos_new_test"
  46. & $python -u tools\cocos2d-console\bin\cocos.py --agreement n new -l cpp -p my.pack.qqqq cocos_new_test
  47. if ($lastexitcode -ne 0) {throw}
  48. & msbuild $env:APPVEYOR_BUILD_FOLDER\cocos_new_test\proj.win32\cocos_new_test.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m /consoleloggerparameters:"PerformanceSummary;NoSummary"
  49. if ($lastexitcode -ne 0) {throw}
  50. & 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\cocos_new_test\proj.win32\Release.win32\
  51. if ($lastexitcode -ne 0) {throw}
  52. Push-AppveyorArtifact release_win32.7z
  53. }
  54. Else {
  55. & msbuild $env:APPVEYOR_BUILD_FOLDER\build\cocos2d-win32.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m /consoleloggerparameters:"PerformanceSummary;NoSummary"
  56. if ($lastexitcode -ne 0) {throw}
  57. & 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\build\Release.win32\
  58. if ($lastexitcode -ne 0) {throw}
  59. Push-AppveyorArtifact release_win32.7z
  60. }