linux: Use sqlite from system like Tizen does
[platform/upstream/iotivity.git] / extlibs / sqlite3 / SConscript
1 ##
2 # Script to install (if they do not exist) the SQLite library
3 ##
4
5 import os
6 import shutil
7
8 Import('env')
9 sqlite_env = env.Clone()
10
11 target_os = sqlite_env.get('TARGET_OS')
12 src_dir = sqlite_env.get('SRC_DIR')
13
14 targets_need_sqlite = ['android', 'msys_nt', 'windows']
15 sqlite_dir      = src_dir + '/extlibs/sqlite3/'
16 sqlite_build_dir      = src_dir + '/extlibs/sqlite3/sqlite-amalgamation-3081101/'
17 sqlite_zip_file = src_dir + '/extlibs/sqlite3/sqlite-amalgamation-3081101.zip'
18 sqlite_url      = 'https://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip'
19
20 # Download
21 if target_os in targets_need_sqlite:
22         if sqlite_env.get('SECURED') == '1':
23                 print '*** Checking for installation of SQLite 3.8.11.1 (extlib/sqlite3) ***'
24                 if not os.path.exists(sqlite_dir + 'sqlite3.c') or not os.path.exists(sqlite_dir + 'sqlite3.h'):
25
26                     # If the zip file is not already present, download it
27                         if not os.path.exists(sqlite_zip_file):
28                                 sqlite_zip = sqlite_env.Download(sqlite_zip_file, sqlite_url)
29                         else:
30                                 sqlite_zip = sqlite_zip_file
31
32                         # Unzip the lib
33                         print 'Unzipping SQLite amalgamation src...'
34                         sqlite_env.UnpackAll(sqlite_build_dir, sqlite_zip)
35                         print 'Unzipping SQLite amalgamation src complete'
36
37                         # Move requried src and header
38                         os.rename(sqlite_build_dir + 'sqlite3.c', sqlite_dir + 'sqlite3.c')
39                         os.rename(sqlite_build_dir + 'sqlite3.h', sqlite_dir + 'sqlite3.h')
40                         os.remove(sqlite_zip_file)
41                         shutil.rmtree(sqlite_build_dir)
42
43 # Build will be done with provisioning manager module.