Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / service / resource-container / android / SConscript
1 import os
2 import platform
3 Import('env')
4
5 android_home = env.get('ANDROID_HOME')
6
7 ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
8 if env.get('RELEASE'):
9         ANDROID_RELEASE="release"
10 else:
11         ANDROID_RELEASE="debug"
12
13 os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
14 os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
15
16 if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
17     print('''
18 ***************************************** Info ********************************
19 *   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
20 *   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
21 *   be sure to deselect all options, then select the following 2 packages:    *
22 *       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
23 *       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
24 *       3. Continue by selecting "Install 2 Packages"                         *
25 *                                                                             *
26 *   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
27 *         the following file in your $HOME directory as follows:              *
28 *                                                                             *
29 * Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
30 *                                                                             *
31 *    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
32 *    sdkman.monitor.density=108                                               *
33 *    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
34 *    sdkman.show.update.only=true                                             *
35 *    sdkman.ask.adb.restart=false                                             *
36 *    sdkman.force.http=true                                                   *
37 *    sdkman.show.updateonly=true                                              *
38 *                                                                             *
39 *******************************************************************************
40
41 ...Opening Android SDK Manager now. Once you are finished, the build will continue.
42 ''')
43     os.system(android_home + '/tools/android')
44     
45 def ensure_libs(target, source, env):
46     return target, [source, env.get('BUILD_DIR') + 'librcs_container.so']
47
48 jdk_env = Environment(ENV=os.environ)
49 jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') +
50     ' build -bservice/resource-container/android/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
51     emitter = ensure_libs)
52 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
53
54 jdk_env.Gradle(target="resource-container/objs",
55     source="resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java")