Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / extlibs / android / sdk / SConscript
1 ##
2 # Script to install (if they do not exist) the Android SDK library (ie. Android JDK)
3 ##
4
5 import os, subprocess, struct
6 import urllib2, urlparse
7 import SCons.Errors
8 import shutil
9
10 Import('env')
11
12 target_os = env.get('TARGET_OS')
13 src_dir = env.get('SRC_DIR')
14
15 SConscript(src_dir + '/build_common/tools/UnpackAll.py')
16 SConscript(src_dir + '/build_common/external_libs.scons')
17
18 # Download
19 if target_os == 'android':
20         android_home = env.get('ANDROID_HOME')
21         if not android_home:
22                 print 'Creating ANDROID_HOME for Android SDK'
23
24                 androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk_r24.2'
25
26                 if not os.path.exists(androidlib_dir):
27                         from sys import platform as _platform
28                         if _platform == "linux" or _platform == "linux2":
29                                 androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-linux.tgz'
30                                 androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-linux.tgz'
31                         elif _platform == "darwin":
32                                 androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-macosx.zip'
33                                 androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-macosx.zip'
34                         elif _platform == "win32":
35                                 androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-windows.zip'
36                                 androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-windows.zip'
37
38                         # If the zip file is not already present, download it
39                         if not os.path.exists(androidlib_zip_file):
40                                 androidlib_zip = env.Download(androidlib_zip_file, androidlib_url)
41                         else:
42                                 androidlib_zip = androidlib_zip_file
43
44                         # Unzip the lib
45                         print 'Unzipping android lib...'
46                         env.UnpackAll(androidlib_dir, androidlib_zip)
47                         print 'Unzipping android lib complete'
48
49                         # Remove downloaded file
50 #                       os.remove(androidlib_zip_file)
51         else:
52                 androidlib_dir = env.get('ANDROID_HOME')
53
54 # Set the ANDROID_HOME
55 env.Replace(ANDROID_HOME = androidlib_dir)
56 print 'ANDROID_HOME = ' + env.get('ANDROID_HOME')
57
58