build.gradle 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. apply plugin: 'com.android.application'
  2. import org.apache.tools.ant.taskdefs.condition.Os
  3. android {
  4. compileSdkVersion 22
  5. buildToolsVersion "23.0.2"
  6. defaultConfig {
  7. applicationId "com.garagegames.torque2d"
  8. minSdkVersion 22
  9. targetSdkVersion 22
  10. sourceSets.main {
  11. assets.srcDirs=[
  12. 'src/main/assets',
  13. 'src/main/game'
  14. ]
  15. jni.srcDirs = ['../../../source/']
  16. jniLibs.srcDir 'src/main/libs'
  17. }
  18. task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
  19. def ndkDir = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()
  20. def extension = (Os.isFamily(Os.FAMILY_WINDOWS))? '.cmd' : ''
  21. commandLine "$ndkDir/ndk-build" + extension,
  22. '-C', file('src/main/jni').absolutePath,
  23. '-j', Runtime.runtime.availableProcessors(),
  24. 'all',
  25. 'NDK_DEBUG=1'
  26. }
  27. task cleanNative(type: Exec, description: 'Clean JNI object files') {
  28. def ndkDir = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()
  29. def extension = (Os.isFamily(Os.FAMILY_WINDOWS))? '.cmd' : ''
  30. commandLine "$ndkDir/ndk-build" + extension,
  31. '-C', file('src/main/jni').absolutePath,
  32. 'clean'
  33. }
  34. task copyGame(type: Copy, description: 'Copy torque scripts and modules'){
  35. from('../../../../'){
  36. include '**'
  37. exclude 'engine/**'
  38. exclude 'tools/**'
  39. exclude 'tutorials/**'
  40. exclude '.**'
  41. exclude '*.dll'
  42. exclude 'preferences.cs'
  43. exclude '*.md'
  44. exclude '*.app'
  45. exclude '*.bat'
  46. exclude '*.log'
  47. exclude '*.torsion'
  48. }
  49. into 'src/main/game'
  50. includeEmptyDirs = false
  51. }
  52. task wipeGame(type: Delete, description: 'Wipe android-specific copy of torque scripts and modules'){
  53. delete 'src/main/game/'
  54. }
  55. clean.dependsOn 'cleanNative'
  56. clean.dependsOn 'wipeGame'
  57. tasks.withType(JavaCompile) {
  58. compileTask -> compileTask.dependsOn copyGame
  59. }
  60. tasks.withType(JavaCompile) {
  61. compileTask -> compileTask.dependsOn buildNative
  62. }
  63. tasks.withType(com.android.build.gradle.tasks.NdkCompile){task->
  64. task.enabled = false
  65. }
  66. }
  67. buildTypes {
  68. release {
  69. minifyEnabled false
  70. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  71. }
  72. }
  73. }