2 *******************************************************************
\r
4 * Copyright 2015 Intel Corporation.
\r
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
20 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
23 apply plugin: 'com.android.library'
\r
26 if (WITH_TRANSPORT_BLE == "0") {
\r
27 compileSdkVersion 21
\r
29 compileSdkVersion 22
\r
31 buildToolsVersion "20.0.0"
\r
32 archivesBaseName = "iotivity-base"
\r
34 libraryVariants.all { variant ->
\r
35 variant.outputs.each { output ->
\r
36 def outputFile = output.outputFile
\r
37 if (outputFile != null && outputFile.name.endsWith('.aar')) {
\r
38 def fileName = "${archivesBaseName}-${TARGET_ARCH}-${RELEASE}.aar"
\r
39 output.outputFile = new File(outputFile.parent, fileName)
\r
49 buildConfigField 'int', 'SECURED', SECURED
\r
50 buildConfigField 'int', 'WITH_TCP', WITH_TCP
\r
51 buildConfigField 'int', 'WITH_CLOUD', WITH_CLOUD
\r
52 buildConfigField "int", 'WITH_MQ_PUB', WITH_MQ_PUB
\r
53 buildConfigField "int", 'WITH_MQ_SUB', WITH_MQ_SUB
\r
54 buildConfigField "int", 'WITH_MQ_BROKER', WITH_MQ_BROKER
\r
55 buildConfigField "String", 'RD_MODE', "\"RD_MODE\""
\r
56 buildConfigField "int", 'WITH_TRANSPORT_EDR', WITH_TRANSPORT_EDR
\r
57 buildConfigField "int", 'WITH_TRANSPORT_BLE', WITH_TRANSPORT_BLE
\r
58 buildConfigField "int", 'WITH_TRANSPORT_NFC', WITH_TRANSPORT_NFC
\r
62 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
\r
72 manifest.srcFile 'src/main/AndroidManifest.xml'
\r
73 jniLibs.srcDir 'libs'
\r
74 jni.srcDirs = [] //disable automatic ndk-build call
\r
76 if (WITH_TRANSPORT_EDR == "0") {
\r
77 exclude "**/ca/CaBtPairingInterface.java"
\r
78 exclude "**/ca/CaEdrInterface.java"
\r
79 println 'excluded EDR interface'
\r
81 if (WITH_TRANSPORT_BLE == "0") {
\r
82 exclude "**/ca/CaLeClientInterface.java"
\r
83 exclude "**/ca/CaLeServerInterface.java"
\r
84 println 'excluded BLE interface'
\r
86 if (WITH_TRANSPORT_NFC == "0") {
\r
87 exclude "**/ca/CaNfcInterface.java"
\r
88 println 'excluded NFC interface'
\r
97 compile fileTree(dir: 'libs', include: ['*.jar'])
\r
103 //If using this, Android studio will fail run the following to set the environment variable for android studio:
\r
104 //launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e
\r
105 //otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
\r
107 task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
\r
108 dependsOn 'buildNative'
\r
109 from(new File('libs')) { include '**/*.so' }
\r
110 into new File(buildDir, 'native-libs')
\r
113 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
\r
115 clean.dependsOn 'cleanCopyNativeLibs'
\r
117 tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
\r
118 pkgTask.jniFolders = new HashSet<File>()
\r
119 pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
\r
122 task buildNative(type: Exec) {
\r
123 if (System.env.ANDROID_NDK_HOME != null) {
\r
124 //for windows use 'ndk-build.cmd'
\r
125 //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
\r
126 def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
127 commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE", "SECURE=$SECURED", "WITH_CLOUD=$WITH_CLOUD", "RD_MODE=$RD_MODE", "WITH_MQ_PUB=$WITH_MQ_PUB", "WITH_MQ_SUB=$WITH_MQ_SUB", "WITH_MQ_BROKER=$WITH_MQ_BROKER", "WITH_TCP=$WITH_TCP"
\r
129 println '##################'
\r
130 println 'Skipping NDK build'
\r
131 println 'Reason: ANDROID_NDK_HOME not set.'
\r
132 println '##################'
\r