build.gradle 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. apply plugin: 'com.android.library'
  2. /*
  3. * UVCCamera
  4. * library and sample to access to UVC web camera on non-rooted Android device
  5. *
  6. * Copyright (c) 2014-2017 saki t_saki@serenegiant.com
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * All files in the folder are under this Apache License, Version 2.0.
  21. * Files in the libjpeg-turbo, libusb, libuvc, rapidjson folder
  22. * may have a different license, see the respective files.
  23. */
  24. import org.apache.tools.ant.taskdefs.condition.Os
  25. android {
  26. compileSdkVersion versionCompiler
  27. buildToolsVersion versionBuildTool
  28. compileOptions {
  29. sourceCompatibility javaSourceCompatibility
  30. targetCompatibility javaTargetCompatibility
  31. }
  32. defaultConfig {
  33. minSdkVersion 14
  34. targetSdkVersion versionTarget
  35. }
  36. buildTypes {
  37. release {
  38. minifyEnabled false
  39. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  40. }
  41. }
  42. sourceSets {
  43. main {
  44. jniLibs.srcDir 'src/main/libs'
  45. jni.srcDirs = []
  46. }
  47. }
  48. }
  49. tasks.withType(JavaCompile) {
  50. compileTask -> compileTask.dependsOn ndkBuild
  51. }
  52. String getNdkBuildPath() {
  53. Properties properties = new Properties()
  54. properties.load(project.rootProject.file('local.properties').newDataInputStream())
  55. def ndkBuildingDir = properties.getProperty("ndk.dir")
  56. def ndkBuildPath = ndkBuildingDir
  57. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  58. ndkBuildPath = ndkBuildingDir + '/ndk-build.cmd'
  59. } else {
  60. ndkBuildPath = ndkBuildingDir + '/ndk-build'
  61. }
  62. return ndkBuildPath
  63. }
  64. task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
  65. println('executing ndkBuild')
  66. def ndkBuildPath = getNdkBuildPath();
  67. commandLine ndkBuildPath, '-j8', '-C', file('src/main').absolutePath
  68. }
  69. task ndkClean(type: Exec, description: 'clean JNI libraries') {
  70. println('executing ndkBuild clean')
  71. def ndkBuildPath = getNdkBuildPath();
  72. commandLine ndkBuildPath, 'clean', '-C', file('src/main').absolutePath
  73. }
  74. clean.dependsOn 'ndkClean'
  75. dependencies {
  76. implementation fileTree(include: ['*.jar'], dir: 'libs')
  77. implementation "com.android.support:support-v4:${supportLibVersion}"
  78. implementation "com.android.support:support-annotations:${supportLibVersion}"
  79. implementation("com.serenegiant:common:${commonLibVersion}") {
  80. exclude module: 'support-v4'
  81. }
  82. }