before-build.ps1 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. $python = "C:\\Python27\\python.exe"
  2. function Download-Url
  3. {
  4. param([string]$url, [string]$output)
  5. (New-Object Net.WebClient).DownloadFile($url, $output)
  6. }
  7. function LS
  8. {
  9. param([string]$path)
  10. Get-ChildItem $path | get-acl
  11. }
  12. function Download-Deps
  13. {
  14. $json = Get-Content -Raw -Path "$env:APPVEYOR_BUILD_FOLDER/external/config.json" | ConvertFrom-Json
  15. $version = $json.version
  16. $url = "https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/archive/$version.zip"
  17. $output = "$env:APPVEYOR_BUILD_FOLDER/$version.zip"
  18. Write-Host "downloading $url"
  19. Download-Url $url $output
  20. Write-Host "finish downloading $url"
  21. Write-Host "unzip $url"
  22. $zipfile = $output
  23. $output = $env:APPVEYOR_BUILD_FOLDER
  24. Add-Type -AssemblyName System.IO.Compression.FileSystem
  25. [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $output)
  26. $file_subffix = $version.Substring(1)
  27. Copy-Item -Path "$output/cocos2d-x-3rd-party-libs-bin-$file_subffix/*" -Destination "$env:APPVEYOR_BUILD_FOLDER/external" -Recurse
  28. Write-Host "finish unziping $url"
  29. }
  30. function Download-NDK
  31. {
  32. $url = "http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86.exe"
  33. $output = "$env:APPVEYOR_BUILD_FOLDER/../android-ndk-r10d-windows-x86.exe"
  34. Write-Host "downloading $url"
  35. Download-Url $url $output
  36. Write-Host "finish downloading $url"
  37. Write-Host "installing NDK"
  38. Push-Location "$env:APPVEYOR_BUILD_FOLDER/../"
  39. & $output > $null
  40. Pop-Location
  41. Write-Host "finish installing NDK"
  42. $env:NDK_ROOT = "$env:APPVEYOR_BUILD_FOLDER/../android-ndk-r10d"
  43. Write-Host "set environment NDK_ROOT to $env:NDK_ROOT"
  44. }
  45. function Generate-Binding-Codes
  46. {
  47. # install python module
  48. & pip install PyYAML Cheetah
  49. Write-Host "generating binding codes"
  50. $env:PYTHON_BIN = $python
  51. Write-Host "set environment viriable PYTHON_BIN to $env:PYTHON_BIN"
  52. Push-Location $env:APPVEYOR_BUILD_FOLDER\tools\tolua
  53. & $python $env:APPVEYOR_BUILD_FOLDER\tools\tolua\genbindings.py
  54. Pop-Location
  55. Push-Location $env:APPVEYOR_BUILD_FOLDER\tools\tojs
  56. & $python $env:APPVEYOR_BUILD_FOLDER\tools\tojs\genbindings.py
  57. Pop-Location
  58. }
  59. function Update-SubModule
  60. {
  61. Push-Location $env:APPVEYOR_BUILD_FOLDER
  62. & git submodule init
  63. & git submodule update --recursive
  64. Pop-Location
  65. }
  66. Update-SubModule
  67. Download-Deps
  68. Download-NDK
  69. Generate-Binding-Codes