5 android_home = env.get('ANDROID_HOME')
7 ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
9 ANDROID_RELEASE="release"
11 ANDROID_RELEASE="debug"
12 ANDROID_SECURED = env.get('SECURED')
14 os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
15 os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
17 if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
19 ***************************************** Info ********************************
20 * Either 'Android API 21' is not installed or 'Android SDK Build Tools *
21 * 20.0.0' is not installed. The Android SDK Manager will now open. Please *
22 * be sure to deselect all options, then select the following 2 packages: *
23 * 1. Under "Tools" select "Android SDK Build-tools" Revision 20. *
24 * 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" *
25 * 3. Continue by selecting "Install 2 Packages" *
27 * NOTE: If you have an http proxy, please press ctrl+c now and edit/create *
28 * the following file in your $HOME directory as follows: *
30 * Edit/Create file: "$HOME/.android/androidtool.cfg" *
32 * http.proxyPort=<YOUR_PORT_NUMBER> *
33 * sdkman.monitor.density=108 *
34 * http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS> *
35 * sdkman.show.update.only=true *
36 * sdkman.ask.adb.restart=false *
37 * sdkman.force.http=true *
38 * sdkman.show.updateonly=true *
40 *******************************************************************************
42 ...Opening Android SDK Manager now. Once you are finished, the build will continue.
44 os.system(android_home + '/tools/android')
46 def ensure_libs(target, source, env):
47 return target, [source, env.get('BUILD_DIR') + 'liboc.so', env.get('BUILD_DIR') + 'liboc_logger.so']
50 jdk_env = Environment(ENV=os.environ)
51 jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), emitter = ensure_libs)
52 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
53 cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")
55 # build examples only once - this is to reduce build time on the Jenkins server
56 if not os.path.exists(os.getcwd()+'../examples/devicediscoveryserver/build/outputs/apk'):
57 jdk_env1 = Environment(ENV=os.environ)
58 jdk_env1['BUILD_DIR'] = env.get('BUILD_DIR')
60 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),
61 emitter = ensure_libs)
62 cmd1=jdk_env1.Gradle1(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java")
64 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),
65 emitter = ensure_libs)
66 cmd2=jdk_env1.Gradle1(target="../examples/devicediscoveryserver/apk", source="../examples/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java")
68 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),
69 emitter = ensure_libs)
70 cmd3=jdk_env1.Gradle1(target="../examples/presenceclient/apk", source="../examples/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java")
72 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),
73 emitter = ensure_libs)
74 cmd4=jdk_env1.Gradle1(target="../examples/presenceserver/apk", source="../examples/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java")
76 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),
77 emitter = ensure_libs)
78 cmd5=jdk_env1.Gradle1(target="../examples/provisioningclient/apk", source="../examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java")
80 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),
81 emitter = ensure_libs)
82 cmd6=jdk_env1.Gradle1(target="../examples/groupclient/apk", source="../examples/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java")
84 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),
85 emitter = ensure_libs)
86 cmd7=jdk_env1.Gradle1(target="../examples/groupserver/apk", source="../examples/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java")
88 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),
89 emitter = ensure_libs)
90 cmd8=jdk_env1.Gradle1(target="../examples/simpleclient/apk", source="../examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java")
92 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),
93 emitter = ensure_libs)
94 cmd9=jdk_env1.Gradle1(target="../examples/simpleserver/apk", source="../examples/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java")
96 # android examples require android api to be built before being invoked
97 Depends(cmd1, cmdBuildApi)
98 Depends(cmd2, cmdBuildApi)
99 Depends(cmd3, cmdBuildApi)
100 Depends(cmd4, cmdBuildApi)
101 Depends(cmd5, cmdBuildApi)
102 Depends(cmd6, cmdBuildApi)
103 Depends(cmd7, cmdBuildApi)
104 Depends(cmd8, cmdBuildApi)
105 Depends(cmd9, cmdBuildApi)