Android: fixing scons build for the examples
authorTim Kourt <tim.a.kourt@intel.com>
Wed, 30 Sep 2015 20:28:11 +0000 (13:28 -0700)
committerUze Choi <uzchoi@samsung.com>
Thu, 1 Oct 2015 05:13:00 +0000 (05:13 +0000)
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 <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3327
Reviewed-by: Rahul Rahul <rahul.rahul@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
android/android_api/SConscript
android/android_api/base/build.gradle
android/examples/gradle.properties

index 5dfe91d..38fd526 100644 (file)
@@ -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)
index b4286f3..82fb651 100755 (executable)
@@ -25,13 +25,13 @@ apply plugin: 'com.android.library'
 android {\r
     compileSdkVersion 21\r
     buildToolsVersion "20.0.0"\r
-    archivesBaseName = "iotivity"\r
+    archivesBaseName = "iotivity-base"\r
 \r
     libraryVariants.all { variant ->\r
         variant.outputs.each { output ->\r
             def outputFile = output.outputFile\r
             if (outputFile != null && outputFile.name.endsWith('.aar')) {\r
-                def fileName = "${archivesBaseName}-base-${TARGET_ARCH}-${RELEASE}.aar"\r
+                def fileName = "${archivesBaseName}-${TARGET_ARCH}-${RELEASE}.aar"\r
                 output.outputFile = new File(outputFile.parent, fileName)\r
             }\r
         }\r
@@ -80,14 +80,7 @@ task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
     into new File(buildDir, 'native-libs')\r
 }\r
 \r
-task copyToJniLibs(type: Copy, dependsOn: 'buildNative') {\r
-    dependsOn 'buildNative'\r
-    from(new File('obj/local')) { include '**/*.so' }\r
-    into new File(buildDir, 'jniLibs')\r
-}\r
-\r
 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }\r
-tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyToJniLibs }\r
 \r
 clean.dependsOn 'cleanCopyNativeLibs'\r
 \r
index ee503bb..9046951 100644 (file)
@@ -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 <iotivity>/android/examples/gradle.properties,\
    if your aar file has different values for TARGET_ARCH and RELEASE"