Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / extlibs / wksxmppxep / SConscript
1 ######################################################################
2 # Ref. libstrophe library build script
3 #
4 ######################################################################
5 import os
6 import subprocess
7
8 Import('env')
9
10 base_dir = env.get('SRC_DIR')
11 target_os = env.get('TARGET_OS')
12 target_arch = env.get('TARGET_ARCH')
13
14 with_ra_ibb = env.get('WITH_RA_IBB')
15
16 SRC_NAME = 'wks_xep0047'
17 EXT_NAME = 'wksxmppxep'
18 EXT_BASE = 'extlibs/' + EXT_NAME
19 EXT_PATH = EXT_BASE + '/' + SRC_NAME
20 SRC_PATH = base_dir + '/' + EXT_PATH
21 INC_PATH = SRC_PATH + '/include'
22 LIB_PATH = SRC_PATH
23 WJSXMPPXEP_LIBS = ['wksxmppxep', 'm', 'crypto']
24
25 if with_ra_ibb:
26         env.SConscript(base_dir + '/extlibs/libstrophe/SConscript')
27         if not os.path.exists(SRC_NAME):
28                 raxmpp_env = Environment(ENV = os.environ)
29                 c = raxmpp_env.Action(['git clone https://github.com/WorksSystems/wks_xep0047.git ' + SRC_NAME,
30                         'cd ' + SRC_NAME + ' && git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14'
31         ])
32
33                 print('Downloading', SRC_NAME ,'library ...')
34                 if raxmpp_env.Execute(c):
35                         print('''
36         *********************************** Error: ***********************************************
37         * Please download ra_xmpp as following:
38         *     $ git clone https://github.com/WorksSystems/wksxmpp_chat.git extlibs/wksxmppxep/wksxmpp_chat
39         *     $ cd extlibs/wksxmppxep/wksxmpp_chat
40         *     $ git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14
41         ******************************************************************************************
42         ''')
43                         Exit(1)
44                 else:
45                         print('Download', SRC_NAME, 'library complete')
46
47         if not env.GetOption('clean'):
48                 print('Building with ' + SRC_NAME)
49                 os.chdir(SRC_NAME)
50                 if not os.path.exists('libwksxmppxep.so') :
51                         LIBSTROPHE_BASE=base_dir + '/extlibs/libstrophe/libstrophe'
52                         foo=subprocess.getoutput('make LIBSTROPHE_BASE=' + LIBSTROPHE_BASE + ' libraries')
53                         print(foo)
54                 if not os.path.exists('libwksxmppxep.so') :
55                         print('Building with ' + SRC_NAME + ' failed.')
56                         Exit(2)
57                 else:
58                         foo = subprocess.getoutput('cp libwksxmppxep.so ' + env.get('BUILD_DIR'))
59                         print(foo)
60                         foo = subprocess.getoutput('cp libwksxmppxep.a ' + env.get('BUILD_DIR'))
61                         print(foo)
62         
63                 print('Building with ' + SRC_NAME + ' Completely.')
64
65         env.PrependUnique(CPPPATH = [INC_PATH], RALIBS = WJSXMPPXEP_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
66         env.AppendUnique(LIBS = WJSXMPPXEP_LIBS, LIBPATH = [LIB_PATH])
67         env.AppendUnique(LIBS = ['boost_system', 'boost_thread'])
68
69 if env.GetOption('clean') :
70         act = env.Action(['cd ' + SRC_PATH, 'make clean'])
71         env.Execute(act)
72         if os.path.isfile(env.get('BUILD_DIR') + '/libwksxmppxep.so'):
73                 act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libwksxmppxep.*'])
74                 env.Execute(act2)