Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / extlibs / libstrophe / SConscript
1 ######################################################################
2 # ref. raxmpp 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 build_path = Dir('.').abspath
14
15 with_ra_ibb = env.get('WITH_RA_IBB')
16 PKG_NAME = 'strophe'
17 SRC_NAME = 'libstrophe'
18 EXT_NAME = 'libstrophe'
19 EXT_BASE = 'extlibs/' + EXT_NAME
20 EXT_PATH = EXT_BASE + '/' + SRC_NAME
21 SRC_PATH = base_dir + '/' + EXT_PATH
22 INC_PATH = SRC_PATH
23 LIB_PATH = SRC_PATH + '/' + '.libs'
24 LIBSTROPHY_LIBS = ['strophe', 'ssl', 'crypto', 'resolv']
25
26 if with_ra_ibb:
27         # check 'libstrophe' library, if it doesn't exits, ask user to download it
28         if not os.path.exists(SRC_NAME):
29                 raxmpp_env = Environment(ENV = os.environ)
30                 c = raxmpp_env.Action(['git clone https://github.com/strophe/libstrophe.git ' + SRC_NAME,
31                         'cd ' + SRC_NAME + ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
32                         ])
33
34                 print('Downloading xmpp library ...')
35                 if raxmpp_env.Execute(c):
36                         print('''
37         *********************************** Error: ***********************************************
38         * Please download ra_xmpp as following:
39         *     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
40         *     $ cd  extlibs/libstrophe/libstrophe
41         *     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
42         ******************************************************************************************
43         ''')
44                         Exit(1)
45                 else:
46                         print('Download xmpp library complete')
47
48         if not env.GetOption('clean'):
49                 print('Building with ' + SRC_NAME)
50                 #print 'base_dir', base_dir
51                 #print 'target_os', target_os
52                 #print 'target_arch', target_arch
53         
54                 foo=subprocess.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
55                 print(foo)
56                 os.chdir(SRC_NAME)
57                 #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
58                 if not os.path.exists('configure') :
59                         foo=subprocess.getoutput('./bootstrap.sh')
60                         print(foo)
61                 if not os.path.exists('config.status') :
62                         foo=subprocess.getoutput('./configure')
63                         print(foo)
64                 if not os.path.exists('.libs/libstrophe.a') :
65                         foo=subprocess.getoutput('make libstrophe.la')
66                         print(foo)
67                 if not os.path.exists('.libs/libstrophe.a') :
68                         print('Building with ' + SRC_NAME + ' failed.')
69                         Exit(2)
70                 else:
71                         foo = subprocess.getoutput('cp .libs/libstrophe.a ' + env.get('BUILD_DIR'))
72                         foo = subprocess.getoutput('cp .libs/libstrophe.so* ' + env.get('BUILD_DIR'))
73                         print(foo)
74
75                 print('Building with ' + SRC_NAME + ' Completely.')
76         env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = LIBSTROPHY_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
77         env.AppendUnique(LIBS= LIBSTROPHY_LIBS, LIBPATH = [LIB_PATH])
78
79 if env.GetOption('clean'):
80         act = env.Action(['cd ' + SRC_PATH, 'make clean'])
81         env.Execute(act)
82         if os.path.isfile(env.get('BUILD_DIR') + '/libstrophe.a'):
83                 act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libstrophe.*'])
84                 env.Execute(act2)