Blame view

ios/cocos2d/tools/appveyor-scripts/build.ps1 4.08 KB
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  Set-PSDebug -Trace 1
  $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"
  
  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.'
      }
  }
  
  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\
      Retry-Command -ScriptBlock {
          & ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
      } -Maximum 5
      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"
      Retry-Command -ScriptBlock {
          & ./gradlew assembleDebug -PPROP_BUILD_TYPE=cmake --parallel --info
      } -Maximum 5
  
      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\
      Retry-Command -ScriptBlock {
          & ./gradlew assembleRelease
      } -Maximum 5
      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\
      Retry-Command -ScriptBlock {
          & ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --parallel --info
      } -Maximum 5
      
      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}
  
  } elseif ($env:build_type -eq "windows32_cmake_test") {
      Write-Host "Build tests project by cmake"
  
      $ENV:PATH="$env:APPVEYOR_BUILD_FOLDER\tools\cocos2d-console\bin;$ENV:PATH"
  
      & mkdir $env:APPVEYOR_BUILD_FOLDER\win32-build
      # if ($lastexitcode -ne 0) {throw} # mkdir return no-zero
  
      Push-Location $env:APPVEYOR_BUILD_FOLDER\win32-build
      & cmake -DCMAKE_BUILD_TYPE=Release ..
      if ($lastexitcode -ne 0) {throw}
  
      & cmake --build . --config Release
      if ($lastexitcode -ne 0) {throw}
  
      & 7z a release_win32.7z $env:APPVEYOR_BUILD_FOLDER\win32-build\bin\
      if ($lastexitcode -ne 0) {throw}
  
      Push-AppveyorArtifact release_win32.7z
      Pop-Location
  }
  Else {
  }