Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / extlibs / sqlite3 / SConscript
1 ##
2 # Scons script to install SQLite sources if not present
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 = ['linux', 'android', 'msys_nt', 'windows', 'ios']
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 sqlite_package= 'sqlite-amalgamation-3081101'
20 sqlite_url = 'https://www.sqlite.org/2015/' + sqlite_package + '.zip'
21
22 sqlite_dir = os.path.join(src_dir, 'extlibs', 'sqlite3')
23 sqlite_c = os.path.join(sqlite_dir, 'sqlite3.c')
24 sqlite_h = os.path.join(sqlite_dir, 'sqlite3.h')
25 sqlite_tmp_dir = os.path.join(sqlite_dir, sqlite_package)
26 sqlite_zip_file = sqlite_tmp_dir + '.zip'
27 sqlite_c_tmp = os.path.join(sqlite_tmp_dir, 'sqlite3.c')
28 sqlite_h_tmp = os.path.join(sqlite_tmp_dir, 'sqlite3.h')
29
30 if target_os in targets_need_sqlite:
31     print('*** Checking for presence of %s ***' % sqlite_package)
32     os.listdir(sqlite_dir)
33     if not os.path.exists(sqlite_c) or not os.path.exists(sqlite_h):
34         if not os.path.exists(sqlite_zip_file):
35             sqlite_zip_file = sqlite_env.Download(sqlite_zip_file, sqlite_url)
36         sqlite_env.UnpackAll(sqlite_tmp_dir, sqlite_zip_file)
37         os.rename(sqlite_c_tmp, sqlite_c)
38         os.rename(sqlite_h_tmp, sqlite_h)
39 #        os.remove(sqlite_zip_file)
40         shutil.rmtree(sqlite_tmp_dir)