Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / extlibs / libstrophe / SConscript
index f774ecd..c8e0b65 100644 (file)
@@ -3,7 +3,7 @@
 #
 ######################################################################
 import os
-import commands
+import subprocess
 
 Import('env')
 
@@ -21,6 +21,7 @@ EXT_PATH = EXT_BASE + '/' + SRC_NAME
 SRC_PATH = base_dir + '/' + EXT_PATH
 INC_PATH = SRC_PATH
 LIB_PATH = SRC_PATH + '/' + '.libs'
+LIBSTROPHY_LIBS = ['strophe', 'ssl', 'crypto', 'resolv']
 
 if with_ra_ibb:
        # check 'libstrophe' library, if it doesn't exits, ask user to download it
@@ -30,46 +31,54 @@ if with_ra_ibb:
                        'cd ' + SRC_NAME + ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
                        ])
 
-               print 'Downloading xmpp library ...'
+               print('Downloading xmpp library ...')
                if raxmpp_env.Execute(c):
-                       print '''
+                       print('''
        *********************************** Error: ***********************************************
        * Please download ra_xmpp as following:
        *     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
        *     $ cd  extlibs/libstrophe/libstrophe
        *     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
        ******************************************************************************************
-       '''
+       ''')
                        Exit(1)
                else:
-                       print 'Download xmpp library complete'
+                       print('Download xmpp library complete')
 
-       print 'Building with ' + SRC_NAME
-       #print 'base_dir', base_dir
-       #print 'target_os', target_os
-       #print 'target_arch', target_arch
-
-       foo=commands.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
-       print foo
-
-       os.chdir(SRC_NAME)
-       #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
-       if not os.path.exists('configure') :
-               foo=commands.getoutput('./bootstrap.sh')
-               print foo
-       if not os.path.exists('config.status') :
-               foo=commands.getoutput('./configure')
-               print foo
-       if not os.path.exists('.libs/libstrophe.a') :
-               foo=commands.getoutput('make libstrophe.la')
-               print foo
-       if not os.path.exists('.libs/libstrophe.a') :
-               print 'Building with ' + SRC_NAME + ' failed.'
-               Exit(2)
+       if not env.GetOption('clean'):
+               print('Building with ' + SRC_NAME)
+               #print 'base_dir', base_dir
+               #print 'target_os', target_os
+               #print 'target_arch', target_arch
+       
+               foo=subprocess.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
+               print(foo)
+               os.chdir(SRC_NAME)
+               #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
+               if not os.path.exists('configure') :
+                       foo=subprocess.getoutput('./bootstrap.sh')
+                       print(foo)
+               if not os.path.exists('config.status') :
+                       foo=subprocess.getoutput('./configure')
+                       print(foo)
+               if not os.path.exists('.libs/libstrophe.a') :
+                       foo=subprocess.getoutput('make libstrophe.la')
+                       print(foo)
+               if not os.path.exists('.libs/libstrophe.a') :
+                       print('Building with ' + SRC_NAME + ' failed.')
+                       Exit(2)
+               else:
+                       foo = subprocess.getoutput('cp .libs/libstrophe.a ' + env.get('BUILD_DIR'))
+                       foo = subprocess.getoutput('cp .libs/libstrophe.so* ' + env.get('BUILD_DIR'))
+                       print(foo)
 
-       print 'Building with ' + SRC_NAME + ' Completely.'
-       env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = ['strophe', 'ssl', 'crypto', 'resolv'], RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
+               print('Building with ' + SRC_NAME + ' Completely.')
+       env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = LIBSTROPHY_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
+       env.AppendUnique(LIBS= LIBSTROPHY_LIBS, LIBPATH = [LIB_PATH])
 
-if env.GetOption('clean') :
+if env.GetOption('clean'):
        act = env.Action(['cd ' + SRC_PATH, 'make clean'])
        env.Execute(act)
+       if os.path.isfile(env.get('BUILD_DIR') + '/libstrophe.a'):
+               act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libstrophe.*'])
+               env.Execute(act2)