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
30 classpath 'com.android.tools.build:gradle:1.3.0'
\r
32 // NOTE: Do not place your application dependencies here; they belong
\r
33 // in the individual module build.gradle files
\r
44 apply plugin: 'com.android.library'
\r
50 srcDirs 'src/main/java', '../common/src/main/java'
\r
52 manifest.srcFile 'src/main/AndroidManifest.xml'
\r
53 jniLibs.srcDir "$buildDir/native-libs"
\r
54 jni.srcDirs = [] //disable automatic ndk-build call
\r
58 compileSdkVersion 21
\r
59 buildToolsVersion "20.0.0"
\r
60 archivesBaseName = "iotivity-base"
\r
62 libraryVariants.all { variant ->
\r
63 variant.outputs.each { output ->
\r
64 def outputFile = output.outputFile
\r
65 if (outputFile != null && outputFile.name.endsWith('.aar')) {
\r
66 def fileName = "${archivesBaseName}-${TARGET_ARCH}-${RELEASE}.aar"
\r
67 output.outputFile = new File(outputFile.parent, fileName)
\r
76 versionName PROJECT_VERSION
\r
77 buildConfigField 'int', 'SECURED', SECURED
\r
78 buildConfigField 'int', 'WITH_TCP', WITH_TCP
\r
79 buildConfigField 'int', 'WITH_CLOUD', WITH_CLOUD
\r
80 buildConfigField "int", 'WITH_MQ_PUB', WITH_MQ_PUB
\r
81 buildConfigField "int", 'WITH_MQ_SUB', WITH_MQ_SUB
\r
82 buildConfigField "int", 'WITH_MQ_BROKER', WITH_MQ_BROKER
\r
83 buildConfigField "String", 'RD_MODE', "\"RD_MODE\""
\r
84 buildConfigField "int", 'WITH_TRANSPORT_EDR', WITH_TRANSPORT_EDR
\r
85 buildConfigField "int", 'WITH_TRANSPORT_BLE', WITH_TRANSPORT_BLE
\r
86 buildConfigField "int", 'WITH_TRANSPORT_NFC', WITH_TRANSPORT_NFC
\r
87 buildConfigField "int", 'MULTIPLE_OWNER', MULTIPLE_OWNER
\r
91 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
\r
101 manifest.srcFile 'src/main/AndroidManifest.xml'
\r
102 jniLibs.srcDir '$buildDir/native-libs'
\r
103 jni.srcDirs = [] //disable automatic ndk-build call
\r
105 if (WITH_TRANSPORT_EDR == "0") {
\r
106 exclude "**/ca/CaBtPairingInterface.java"
\r
107 exclude "**/ca/CaEdrInterface.java"
\r
108 println 'excluded EDR interface'
\r
110 if (WITH_TRANSPORT_BLE == "0") {
\r
111 exclude "**/ca/CaLeClientInterface.java"
\r
112 exclude "**/ca/CaLeServerInterface.java"
\r
113 println 'excluded BLE interface'
\r
115 if (WITH_TRANSPORT_NFC == "0") {
\r
116 exclude "**/ca/CaNfcInterface.java"
\r
117 println 'excluded NFC interface'
\r
119 if (WITH_TCP == "0" || SECURED == "0") {
\r
120 exclude "**/base/OcCloudProvisioning.java"
\r
121 println 'excluded secure files'
\r
129 compile fileTree(dir: 'libs', include: ['*.jar'])
\r
132 task copyNativeLibs(type: Copy) {
\r
133 String[] libraries = [
\r
134 'libgnustl_shared.so',
\r
135 'libconnectivity_abstraction.so',
\r
136 'libca-interface.so',
\r
140 'libresource_directory.so',
\r
141 'libocstack-jni.so'
\r
143 if ("$SECURED" == '1')
\r
145 'libocprovision.so',
\r
148 from(new File("../../out/$TARGET_OS/$TARGET_ARCH/$RELEASE")) { include libraries }
\r
149 into new File(buildDir, "native-libs/$TARGET_ARCH")
\r
152 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
\r
154 tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
\r
155 pkgTask.jniFolders = new HashSet<File>()
\r
156 pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
\r
159 task buildNative(type: Exec) {
\r
160 if (System.env.ANDROID_NDK_HOME != null) {
\r
161 //for windows use 'ndk-build.cmd'
\r
162 //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
\r
163 def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
\r
164 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","MULTIPLE_OWNER=$MULTIPLE_OWNER"
\r
166 println '##################'
\r
167 println 'Skipping NDK build'
\r
168 println 'Reason: ANDROID_NDK_HOME not set.'
\r
169 println '##################'
\r