From 0f4c67905e05054fa66779713ec76995db192ded Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Wed, 30 Sep 2015 13:28:11 -0700 Subject: [PATCH] Android: fixing scons build for the examples The issue in scons script introduced in https://gerrit.iotivity.org/gerrit/#/c/3135/ and consequently in https://gerrit.iotivity.org/gerrit/#/c/3287/ has caused the long build times for the Android examples by rebuilding it multiple times. Change-Id: I978ac3459dbd0e42e231f8d70a0374558e85f9e8 Signed-off-by: Tim Kourt Reviewed-on: https://gerrit.iotivity.org/gerrit/3329 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- android/android_api/SConscript | 53 +++-------------------------------- android/android_api/base/build.gradle | 11 ++------ android/examples/gradle.properties | 6 ++-- 3 files changed, 9 insertions(+), 61 deletions(-) diff --git a/android/android_api/SConscript b/android/android_api/SConscript index 5dfe91d..38fd526 100644 --- a/android/android_api/SConscript +++ b/android/android_api/SConscript @@ -52,54 +52,9 @@ jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' b jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java") -# build examples only once - this is to reduce build time on the Jenkins server -if not os.path.exists(os.getcwd()+'../examples/devicediscoveryserver/build/outputs/apk'): - jdk_env1 = Environment(ENV=os.environ) - jdk_env1['BUILD_DIR'] = env.get('BUILD_DIR') +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED)) +cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java") - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/devicediscoveryclient/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd1=jdk_env1.Gradle1(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java") +# android examples require android api to be built before being invoked +Depends(cmdBuildExamples, cmdBuildApi) - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/devicediscoveryserver/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd2=jdk_env1.Gradle1(target="../examples/devicediscoveryserver/apk", source="../examples/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/presenceclient/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd3=jdk_env1.Gradle1(target="../examples/presenceclient/apk", source="../examples/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/presenceserver/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd4=jdk_env1.Gradle1(target="../examples/presenceserver/apk", source="../examples/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/provisioningclient/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd5=jdk_env1.Gradle1(target="../examples/provisioningclient/apk", source="../examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/groupclient/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd6=jdk_env1.Gradle1(target="../examples/groupclient/apk", source="../examples/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/groupserver/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd7=jdk_env1.Gradle1(target="../examples/groupserver/apk", source="../examples/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/simpleclient/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd8=jdk_env1.Gradle1(target="../examples/simpleclient/apk", source="../examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java") - - jdk_env1['BUILDERS']['Gradle1'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/simpleserver/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), - emitter = ensure_libs) - cmd9=jdk_env1.Gradle1(target="../examples/simpleserver/apk", source="../examples/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java") - - # android examples require android api to be built before being invoked - Depends(cmd1, cmdBuildApi) - Depends(cmd2, cmdBuildApi) - Depends(cmd3, cmdBuildApi) - Depends(cmd4, cmdBuildApi) - Depends(cmd5, cmdBuildApi) - Depends(cmd6, cmdBuildApi) - Depends(cmd7, cmdBuildApi) - Depends(cmd8, cmdBuildApi) - Depends(cmd9, cmdBuildApi) diff --git a/android/android_api/base/build.gradle b/android/android_api/base/build.gradle index b4286f3..82fb651 100755 --- a/android/android_api/base/build.gradle +++ b/android/android_api/base/build.gradle @@ -25,13 +25,13 @@ apply plugin: 'com.android.library' android { compileSdkVersion 21 buildToolsVersion "20.0.0" - archivesBaseName = "iotivity" + archivesBaseName = "iotivity-base" libraryVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.aar')) { - def fileName = "${archivesBaseName}-base-${TARGET_ARCH}-${RELEASE}.aar" + def fileName = "${archivesBaseName}-${TARGET_ARCH}-${RELEASE}.aar" output.outputFile = new File(outputFile.parent, fileName) } } @@ -80,14 +80,7 @@ task copyNativeLibs(type: Copy, dependsOn: 'buildNative') { into new File(buildDir, 'native-libs') } -task copyToJniLibs(type: Copy, dependsOn: 'buildNative') { - dependsOn 'buildNative' - from(new File('obj/local')) { include '**/*.so' } - into new File(buildDir, 'jniLibs') -} - tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs } -tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyToJniLibs } clean.dependsOn 'cleanCopyNativeLibs' diff --git a/android/examples/gradle.properties b/android/examples/gradle.properties index ee503bb..9046951 100644 --- a/android/examples/gradle.properties +++ b/android/examples/gradle.properties @@ -38,9 +38,9 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -TARGET_ARCH="armeabi" -RELEASE="release" -SECURED="1" +TARGET_ARCH=armeabi +RELEASE=release +SECURED=1 ERROR_MSG="if building examples from android-studio, you might need to modify the default TARGET_ARCH\ and RELEASE in /android/examples/gradle.properties,\ if your aar file has different values for TARGET_ARCH and RELEASE" -- 2.7.4