1From 931a55347a322f38eb82d5f387b2924e6c7a1746 Mon Sep 17 00:00:00 2001
2From: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
3Date: Thu, 9 Jan 2020 10:07:20 +0100
4Subject: [PATCH] Update SConstruct with new Python3 syntax: - new raise
5 keyword syntax - has_key deprecated method is now removed - commands
6 deprecated library is replaced by subprocess - print function fixes
7
8This should fix FTBFS against new scons 3.1.2
9https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=947584
10---
11 SConstruct | 45 +++++++++++++++++++++++----------------------
12 1 file changed, 23 insertions(+), 22 deletions(-)
13
14diff --git a/SConstruct b/SConstruct
15index ae3df10b..9d1c8914 100644
16--- a/SConstruct
17+++ b/SConstruct
18@@ -1,18 +1,19 @@
19-import os, sys, commands
20+import os, sys
21+from subprocess import check_output
22 env = Environment(ENV = os.environ)
23
24 # figure out a better way to configure this
25-if os.environ.has_key('CXX'):
26+if 'CXX' in os.environ:
27     env['CXX'] = os.environ['CXX']
28
29-if os.environ.has_key('DEBUG'):
30+if 'DEBUG' in os.environ:
31     env['DEBUG'] = os.environ['DEBUG']
32
33-if os.environ.has_key('CXXFLAGS'):
34+if 'CXXFLAGS' in os.environ:
35     #env['CXXFLAGS'] = os.environ['CXXFLAGS']
36     env.Append(CXXFLAGS = os.environ['CXXFLAGS'])
37
38-if os.environ.has_key('LINKFLAGS'):
39+if 'LINKFLAGS' in os.environ:
40     #env['LDFLAGS'] = os.environ['LDFLAGS']
41     env.Append(LINKFLAGS = os.environ['LINKFLAGS'])
42
43@@ -22,24 +23,24 @@ if os.environ.has_key('LINKFLAGS'):
44 ## or set BOOST_INCLUDES and BOOST_LIBS if Boost comes with your OS distro e.g. and
45 ## needs BOOST_INCLUDES=/usr/include/boost and BOOST_LIBS=/usr/lib like Ubuntu.
46 ##
47-if os.environ.has_key('BOOSTROOT'):
48+if 'BOOSTROOT' in os.environ:
49     os.environ['BOOST_ROOT'] = os.environ['BOOSTROOT']
50
51-if os.environ.has_key('BOOST_ROOT'):
52+if 'BOOST_ROOT' in os.environ:
53    env['BOOST_INCLUDES'] = os.environ['BOOST_ROOT']
54    env['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT'], 'stage', 'lib')
55-elif os.environ.has_key('BOOST_INCLUDES') and os.environ.has_key('BOOST_LIBS'):
56+elif 'BOOST_INCLUDES' in os.environ and 'BOOST_LIBS' in os.environ:
57    env['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES']
58    env['BOOST_LIBS'] = os.environ['BOOST_LIBS']
59 else:
60-   raise SCons.Errors.UserError, "Neither BOOST_ROOT, nor BOOST_INCLUDES + BOOST_LIBS was set!"
61+   raise SCons.Errors.UserError("Neither BOOST_ROOT, nor BOOST_INCLUDES + BOOST_LIBS were set!")
62
63 ## Custom OpenSSL
64-if os.environ.has_key('OPENSSL_PATH'):
65+if 'OPENSSL_PATH' in os.environ:
66    env.Append(CPPPATH = os.path.join(os.environ['OPENSSL_PATH'], 'include'))
67    env.Append(LIBPATH = os.environ['OPENSSL_PATH'])
68
69-if os.environ.has_key('WSPP_ENABLE_CPP11'):
70+if 'WSPP_ENABLE_CPP11' in os.environ:
71    env['WSPP_ENABLE_CPP11'] = True
72 else:
73    env['WSPP_ENABLE_CPP11'] = False
74@@ -76,7 +77,7 @@ if env['PLATFORM'].startswith('win'):
75    env['CCFLAGS'] = '%s /EHsc /GR /GS- /MD /nologo %s %s' % (warn_flags, arch_flags, opt_flags)
76    env['LINKFLAGS'] = '/INCREMENTAL:NO /MANIFEST /NOLOGO /OPT:REF /OPT:ICF /MACHINE:X86'
77 elif env['PLATFORM'] == 'posix':
78-   if env.has_key('DEBUG'):
79+   if 'DEBUG' in env:
80       env.Append(CCFLAGS = ['-g', '-O0'])
81    else:
82       env.Append(CPPDEFINES = ['NDEBUG'])
83@@ -84,9 +85,9 @@ elif env['PLATFORM'] == 'posix':
84    env.Append(CCFLAGS = ['-Wall'])
85    #env['LINKFLAGS'] = ''
86 elif env['PLATFORM'] == 'darwin':
87-   if not os.environ.has_key('CXX'):
88+   if not 'CXX' in os.environ:
89       env['CXX'] = "clang++"
90-   if env.has_key('DEBUG'):
91+   if 'DEBUG' in env:
92       env.Append(CCFLAGS = ['-g', '-O0'])
93    else:
94       env.Append(CPPDEFINES = ['NDEBUG'])
95@@ -157,29 +158,29 @@ env_cpp11 = env.Clone ()
96
97 if env_cpp11['CXX'].startswith('g++'):
98    # TODO: check g++ version
99-   GCC_VERSION = commands.getoutput(env_cpp11['CXX'] + ' -dumpversion')
100+   GCC_VERSION = check_output([env_cpp11['CXX'], '-dumpversion'])
101
102-   if GCC_VERSION > "4.4.0":
103-      print "C++11 build environment partially enabled"
104+   if GCC_VERSION.decode('utf-8') > "4.4.0":
105+      print("C++11 build environment partially enabled")
106       env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x'],TOOLSET = ['g++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
107    else:
108-      print "C++11 build environment is not supported on this version of G++"
109+      print("C++11 build environment is not supported on this version of G++")
110 elif env_cpp11['CXX'].startswith('clang++'):
111-   print "C++11 build environment enabled"
112+   print("C++11 build environment enabled")
113    env.Append(CXXFLANGS = ['-stdlib=libc++'],LINKFLAGS=['-stdlib=libc++'])
114    env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x','-stdlib=libc++'],LINKFLAGS = ['-stdlib=libc++'],TOOLSET = ['clang++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
115
116    # look for optional second boostroot compiled with clang's libc++ STL library
117    # this prevents warnings/errors when linking code built with two different
118    # incompatible STL libraries.
119-   if os.environ.has_key('BOOST_ROOT_CPP11'):
120+   if 'BOOST_ROOT_CPP11' in os.environ:
121       env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_ROOT_CPP11']
122       env_cpp11['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT_CPP11'], 'stage', 'lib')
123-   elif os.environ.has_key('BOOST_INCLUDES_CPP11') and os.environ.has_key('BOOST_LIBS_CPP11'):
124+   elif 'BOOST_INCLUDES_CPP11' in os.environ and 'BOOST_LIBS_CPP11' in os.environ:
125       env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES_CPP11']
126       env_cpp11['BOOST_LIBS'] = os.environ['BOOST_LIBS_CPP11']
127 else:
128-   print "C++11 build environment disabled"
129+   print("C++11 build environment disabled")
130
131 # if the build system is known to allow the isystem modifier for library include
132 # values then use it for the boost libraries. Otherwise just add them to the
133