build_libraries.gradle 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. def checkExecResult(execResult) {
  2. if (execResult) {
  3. if (execResult.getExitValue() != 0) {
  4. throw new GradleException('Non-zero exit value: ' + execResult.getExitValue())
  5. }
  6. } else {
  7. throw new GradleException('Returned a null execResult object')
  8. }
  9. }
  10. task buildLibrariesForAndroid(type: Exec) {
  11. workingDir '../'
  12. def sdkDir = System.env.ANDROID_HOME
  13. def ndkDir = System.env.ANDROID_NDK_HOME
  14. if (rootProject.file("local.properties").exists()) {
  15. Properties properties = new Properties()
  16. properties.load(project.rootProject.file('local.properties').newDataInputStream())
  17. sdkDir = properties.getProperty('sdk.dir')
  18. ndkDir = properties.getProperty('ndk.dir')
  19. }
  20. def path = System.env.PATH
  21. def envMap = [
  22. 'ANDROID_HOME' : sdkDir,
  23. 'ANDROID_NDK_HOME': ndkDir,
  24. '_ARCH_' : 'armeabi',
  25. 'PATH' : ndkDir,
  26. ]
  27. environment envMap
  28. print envMap
  29. commandLine 'python', 'build_android.py', '2', 'armeabi'
  30. doLast {
  31. checkExecResult(execResult)
  32. }
  33. }