build: Clean build folders when using scons -c
authorGeorge Nash <george.nash@intel.com>
Wed, 1 Feb 2017 20:50:35 +0000 (12:50 -0800)
committerRick Bell <richard.s.bell@intel.com>
Mon, 6 Feb 2017 18:31:31 +0000 (18:31 +0000)
Since Android and Java code is built using gradle
the build output is not properly tracked by scons.
Scons' Clean method is used to add the build
output to the clean build.

This commit is limited to the `build` folders
generated when building TARGET_OS=android or
BUILD_JAVA=1.

Change-Id: I69965272e377494bd99731fbacb2cc6e06ff7815
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16977
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
SConstruct
java/SConscript
service/easy-setup/mediator/richsdk/android/SConscript
service/easy-setup/sampleapp/mediator/android/SConscript
service/notification/android/SConscript
service/notification/examples/android/NotiConsumerExample/SConscript
service/notification/examples/android/NotiProviderExample/SConscript
service/resource-container/android/SConscript

index 4bfe3b0..74b4589 100644 (file)
@@ -57,15 +57,13 @@ if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt', 'windows']:
        SConscript(build_dir + 'examples/OICMiddle/SConscript')
 
 java_build = None
-if env.get('BUILD_JAVA') == True or target_os == 'android':
-    if env.get('JAVA_HOME') != None:
+if (env.get('BUILD_JAVA') == True  and env.get('JAVA_HOME') != None) or target_os == 'android':
         java_build = SConscript(build_dir + 'java/SConscript')
 
 # Build 'service' sub-project
 service_build = SConscript(build_dir + 'service/SConscript')
 
-if env.get('BUILD_JAVA') == True or target_os == 'android':
-    if env.get('JAVA_HOME') != None:
+if (env.get('BUILD_JAVA') == True and env.get('JAVA_HOME') != None) or target_os == 'android':
         Depends(service_build, java_build)
 
 # Build "cloud" sub-project
index 5d4427c..b3b56d6 100644 (file)
@@ -101,10 +101,39 @@ jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' b
 #cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (examples_target, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (examples_target, ))
 cmdBuildExamples=jdk_env.Gradle(target="examples-%s/simpleclient/jar" % (examples_target, ), source="examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java" % (examples_target, ))
 
-exampleAclFiles = jdk_env.Install('#java/examples-java/simpleserver/build/libs/', 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat')
-exampleAclFiles += jdk_env.Install('#java/examples-java/simpleclientserver/build/libs/', 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat')
+if target_os != 'android':
+       exampleAclFiles = jdk_env.Install('#java/examples-java/simpleserver/build/libs/', 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat')
+       exampleAclFiles += jdk_env.Install('#java/examples-java/simpleclientserver/build/libs/', 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat')
+       Depends(exampleAclFiles, cmdBuildExamples)
 
-Depends(cmdBuildExamples, exampleAclFiles)
 Depends(cmdBuildExamples, cmdBuildApi)
 
+if target_os == 'android':
+       jdk_env.Clean(cmdBuildExamples, '#/java/iotivity-android/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/cloudprovisioningclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/devicediscoveryclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/devicediscoveryserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/DirectPairing/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/fridgeclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/fridgegroupclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/fridgegroupserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/fridgeserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/groupclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/groupserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/presenceclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/presenceserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/provisioningclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simplebase/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simpleclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simpleserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simpleclientserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simpleserver/build/')
+else:
+       jdk_env.Clean(cmdBuildExamples, '#/java/iotivity-linux/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/simpleclient/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/simpleclientserver/build/')
+       jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/simpleserver/build/')
+
 env.AppendUnique(baseAAR = cmdBuildApi)
index 653d60d..21b3c04 100755 (executable)
@@ -74,7 +74,8 @@ jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') +
 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 cmdBuildEasysetup=jdk_env.Gradle(target="EasySetupCore/objs",
     source="EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetup.java")
-jdk_env.Clean(cmdBuildEasysetup, './build')
+jdk_env.Clean(cmdBuildEasysetup, Dir('#/service/easy-setup/mediator/richsdk/android/build/'))
+jdk_env.Clean(cmdBuildEasysetup, Dir('#/service/easy-setup/mediator/richsdk/android/EasySetupCore/build/'))
 Depends(cmdBuildEasysetup, env.get('baseAAR'))
 
 env.AppendUnique(easysetupAAR = cmdBuildEasysetup)
\ No newline at end of file
index c41a9b5..eb79c7f 100644 (file)
@@ -75,4 +75,5 @@ jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 cmdBuildEasysetupApp=jdk_env.Gradle(target="EasySetup/app/apk", 
     source="EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java")
 jdk_env.Clean(cmdBuildEasysetupApp, '#/service/easy-setup/sampleapp/mediator/android/EasySetup/build')
+jdk_env.Clean(cmdBuildEasysetupApp, '#/service/easy-setup/sampleapp/mediator/android/EasySetup/app/build')
 Depends(cmdBuildEasysetupApp, env.get('easysetupAAR'))
\ No newline at end of file
index 09f14ff..531db6f 100755 (executable)
@@ -57,7 +57,9 @@ jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') +
 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 cmdBuildNotification = jdk_env.Gradle(target="notification-service/objs",
     source="notification-service/src/main/java/org/iotivity/service/ns/consumer/ConsumerService.java")
-jdk_env.Clean(cmdBuildNotification, './build')
+jdk_env.Clean(cmdBuildNotification, '#/service/notification/android/build')
+jdk_env.Clean(cmdBuildNotification, '#/service/notification/android/notification-service/build')
+
 Depends(cmdBuildNotification, env.get('baseAAR'))
 
 env.AppendUnique(notificationAAR = cmdBuildNotification)
index 4d7890c..e147b90 100644 (file)
@@ -80,4 +80,5 @@ cmdBuildNotificationConsumerApp=jdk_env.Gradle(target="app/apk",
     source=["app/src/main/java/org/iotivity/service/ns/sample/consumer/MainActivity.java",
             "app/src/main/java/org/iotivity/service/ns/sample/consumer/ConsumerSample.java"])
 jdk_env.Clean(cmdBuildNotificationConsumerApp, '#/service/notification/examples/android/NotiConsumerExample/build')
+jdk_env.Clean(cmdBuildNotificationConsumerApp, '#/service/notification/examples/android/NotiConsumerExample/app/build')
 Depends(cmdBuildNotificationConsumerApp, env.get('notificationAAR'))
index fa506be..36c77c1 100644 (file)
@@ -81,4 +81,5 @@ cmdBuildNotificationProviderApp=jdk_env.Gradle(target="app/apk",
             "app/src/main/java/org/iotivity/service/ns/sample/provider/NotiListener.java",
             "app/src/main/java/org/iotivity/service/ns/sample/provider/ProviderSample.java"])
 jdk_env.Clean(cmdBuildNotificationProviderApp, '#/service/notification/examples/android/NotiProviderExample/build')
+jdk_env.Clean(cmdBuildNotificationProviderApp, '#/service/notification/examples/android/NotiProviderExample/app/build')
 Depends(cmdBuildNotificationProviderApp, env.get('notificationAAR'))
index 81510e2..fb454aa 100644 (file)
@@ -53,4 +53,5 @@ jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 
 cmdResourceContainerApp = jdk_env.Gradle(target="resource-container/objs",
     source="resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java")
-jdk_env.Clean(cmdResourceContainerApp, '#/service/resource-container/android//build')
+jdk_env.Clean(cmdResourceContainerApp, '#/service/resource-container/android/build')
+jdk_env.Clean(cmdResourceContainerApp, '#/service/resource-container/android/resource-container/build')