build: update waf to version 2.0.6

Major cleanup of all build scripts

Change-Id: I6904f034d40adc66366fdf08749900ffb31c68d9
diff --git a/.waf-tools/coverage.py b/.waf-tools/coverage.py
index ce92883..cc58165 100644
--- a/.waf-tools/coverage.py
+++ b/.waf-tools/coverage.py
@@ -1,15 +1,15 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-from waflib import TaskGen, Logs
+from waflib import TaskGen
 
 def options(opt):
-    opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
-                   help='''Set compiler flags for gcc to enable code coverage information''')
+    opt.add_option('--with-coverage', action='store_true', default=False,
+                   help='Add compiler flags to enable code coverage information')
 
 def configure(conf):
     if conf.options.with_coverage:
         if not conf.options.debug:
-            conf.fatal("Code coverage flags require debug mode compilation (add --debug)")
+            conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
         conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
                        linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
 
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index bba2b1e..54db7ea 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -1,16 +1,17 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-from waflib import Logs, Configure, Utils
+from waflib import Configure, Logs, Utils
 
 def options(opt):
-    opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
-                   help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
+    opt.add_option('--debug', '--with-debug', action='store_true', default=False,
+                   help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
 
 def configure(conf):
     conf.start_msg('Checking C++ compiler version')
 
-    cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
-    ccver = tuple(int(i) for i in conf.env['CC_VERSION'])
+    cxx = conf.env.CXX_NAME # generic name of the compiler
+    ccver = tuple(int(i) for i in conf.env.CC_VERSION)
+    ccverstr = '.'.join(conf.env.CC_VERSION)
     errmsg = ''
     warnmsg = ''
     if cxx == 'gcc':
@@ -28,13 +29,13 @@
         conf.flags = CompilerFlags()
 
     if errmsg:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
+        conf.end_msg(ccverstr, color='RED')
         conf.fatal(errmsg)
     elif warnmsg:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
+        conf.end_msg(ccverstr, color='YELLOW')
         Logs.warn(warnmsg)
     else:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']))
+        conf.end_msg(ccverstr)
 
     conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
 
@@ -53,10 +54,10 @@
         extraFlags = conf.flags.getDebugFlags(conf)
         if conf.areCustomCxxflagsPresent:
             missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
-            if len(missingFlags) > 0:
-                Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
-                          % " ".join(conf.env.CXXFLAGS))
-                Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
+            if missingFlags:
+                Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
+                          % ' '.join(conf.env.CXXFLAGS))
+                Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
     else:
         extraFlags = conf.flags.getOptimizedFlags(conf)
 
@@ -106,6 +107,9 @@
 
 
 class CompilerFlags(object):
+    def getCompilerVersion(self, conf):
+        return tuple(int(i) for i in conf.env.CC_VERSION)
+
     def getGeneralFlags(self, conf):
         """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
         return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
@@ -160,16 +164,14 @@
 class GccFlags(GccBasicFlags):
     def getDebugFlags(self, conf):
         flags = super(GccFlags, self).getDebugFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if version < (5, 1, 0):
+        if self.getCompilerVersion(conf) < (5, 1, 0):
             flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
         flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
         return flags
 
     def getOptimizedFlags(self, conf):
         flags = super(GccFlags, self).getOptimizedFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if version < (5, 1, 0):
+        if self.getCompilerVersion(conf) < (5, 1, 0):
             flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
         flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
         return flags
@@ -177,8 +179,8 @@
 class ClangFlags(GccBasicFlags):
     def getGeneralFlags(self, conf):
         flags = super(ClangFlags, self).getGeneralFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if Utils.unversioned_sys_platform() == 'darwin' and version >= (9, 0, 0): # Bug #4296
+        if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
+            # Bug #4296
             flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
                                   ['-isystem', '/opt/local/include']] # for MacPorts
         return flags
@@ -194,7 +196,7 @@
                               '-Wno-error=unneeded-internal-declaration', # Bug #1588
                               '-Wno-unused-local-typedef', # Bugs #2657 and #3209
                               ]
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
+        version = self.getCompilerVersion(conf)
         if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
             flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
         return flags
@@ -206,7 +208,7 @@
                               '-Wundefined-func-template',
                               '-Wno-unused-local-typedef', # Bugs #2657 and #3209
                               ]
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
+        version = self.getCompilerVersion(conf)
         if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
             flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
         return flags
diff --git a/.waf-tools/dependency-checker.py b/.waf-tools/dependency-checker.py
index 629fbfd..63199a5 100644
--- a/.waf-tools/dependency-checker.py
+++ b/.waf-tools/dependency-checker.py
@@ -4,10 +4,10 @@
 from waflib.Configure import conf
 
 def addDependencyOptions(self, opt, name, extraHelp=''):
-    opt.add_option('--with-%s' % name, type='string', default=None,
-                   dest='with_%s' % name,
+    opt.add_option('--with-%s' % name, metavar='PATH',
                    help='Path to %s, e.g., /usr/local %s' % (name, extraHelp))
-setattr(Options.OptionsContext, "addDependencyOptions", addDependencyOptions)
+
+setattr(Options.OptionsContext, 'addDependencyOptions', addDependencyOptions)
 
 @conf
 def checkDependency(self, name, **kw):
@@ -18,8 +18,8 @@
     kw['mandatory'] = kw.get('mandatory', True)
 
     if root:
-        isOk = self.check_cxx(includes="%s/include" % root,
-                              libpath="%s/lib" % root,
+        isOk = self.check_cxx(includes='%s/include' % root,
+                              libpath='%s/lib' % root,
                               **kw)
     else:
         isOk = self.check_cxx(**kw)
diff --git a/.waf-tools/pch.py b/.waf-tools/pch.py
index 3df299f..103e752 100644
--- a/.waf-tools/pch.py
+++ b/.waf-tools/pch.py
@@ -52,7 +52,7 @@
 """
 
 import os
-from waflib import Task, TaskGen, Logs, Utils
+from waflib import Task, TaskGen, Utils
 from waflib.Tools import c_preproc, cxx
 
 
@@ -67,11 +67,6 @@
 
 def configure(conf):
 	if (conf.options.with_pch and conf.env['COMPILER_CXX'] in PCH_COMPILER_OPTIONS.keys()):
-		if Utils.unversioned_sys_platform() == "darwin" and conf.env['CXX_NAME'] == 'clang':
-			version = tuple(int(i) for i in conf.env['CC_VERSION'])
-			if version < (6, 1, 0):
-				# Issue #2804
-				return
 		conf.env.WITH_PCH = True
 		flags = PCH_COMPILER_OPTIONS[conf.env['COMPILER_CXX']]
 		conf.env.CXXPCH_F = flags[0]
@@ -95,8 +90,8 @@
 
 	if getattr(self, 'name', None):
 		try:
-			task = self.bld.pch_tasks[self.name]
-			self.bld.fatal("Duplicated 'pch' task with name %r" % self.name)
+			task = self.bld.pch_tasks["%s.%s" % (self.name, self.idx)]
+			self.bld.fatal("Duplicated 'pch' task with name %r" % "%s.%s" % (self.name, self.idx))
 		except KeyError:
 			pass
 
@@ -109,7 +104,7 @@
 
 	self.pch_task = task
 	if getattr(self, 'name', None):
-		self.bld.pch_tasks[self.name] = task
+		self.bld.pch_tasks["%s.%s" % (self.name, self.idx)] = task
 
 @TaskGen.feature('cxx')
 @TaskGen.after_method('process_source', 'propagate_uselib_vars')
@@ -134,7 +129,7 @@
 			x.env.append_value('CXXFLAGS', self.env['CXXPCH_F'] + [pch.target])
 
 class gchx(Task.Task):
-	run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${CXXPCH_FLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXXPCH_F:SRC} ${CXX_SRC_F}${SRC[0].abspath()} ${CXX_TGT_F}${TGT[0].abspath()}'
+	run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CXXPCH_FLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXXPCH_F:SRC} ${CXX_SRC_F}${SRC[0].abspath()} ${CXX_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
 	scan    = c_preproc.scan
 	color   = 'BLUE'
 	ext_out=['.h']
diff --git a/.waf-tools/unix-socket.py b/.waf-tools/unix-socket.py
index 52e038a..07d1e9e 100644
--- a/.waf-tools/unix-socket.py
+++ b/.waf-tools/unix-socket.py
@@ -1,6 +1,6 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 #
-# Copyright (c) 2014, Regents of the University of California
+# Copyright (c) 2014-2018, Regents of the University of California
 #
 # GPL 3.0 license, see the COPYING.md file for more information
 
@@ -15,8 +15,9 @@
 
 def addUnixOptions(self, opt):
     opt.add_option('--force-unix-socket', action='store_true', default=False,
-                   dest='force_unix_socket', help='''Forcefully enable Unix sockets support''')
-setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions)
+                   help='Forcefully enable Unix sockets support')
+
+setattr(Options.OptionsContext, 'addUnixOptions', addUnixOptions)
 
 def configure(conf):
     def boost_asio_has_local_sockets():
@@ -26,4 +27,4 @@
 
     if conf.options.force_unix_socket or boost_asio_has_local_sockets():
         conf.define('HAVE_UNIX_SOCKETS', 1)
-        conf.env['HAVE_UNIX_SOCKETS'] = True
+        conf.env.HAVE_UNIX_SOCKETS = True
diff --git a/.waf-tools/websocket.py b/.waf-tools/websocket.py
index 2aee143..c30c48e 100644
--- a/.waf-tools/websocket.py
+++ b/.waf-tools/websocket.py
@@ -6,7 +6,8 @@
 def addWebsocketOptions(self, opt):
     opt.add_option('--without-websocket', action='store_false', default=True,
                    dest='with_websocket', help='Disable WebSocket face support')
-setattr(Options.OptionsContext, "addWebsocketOptions", addWebsocketOptions)
+
+setattr(Options.OptionsContext, 'addWebsocketOptions', addWebsocketOptions)
 
 @Configure.conf
 def checkWebsocket(self, **kw):
@@ -15,7 +16,7 @@
 
     isMandatory = kw.get('mandatory', True)
 
-    self.start_msg('Checking for WebSocket includes')
+    self.start_msg('Checking for WebSocket++ includes')
 
     try:
         websocketDir = self.path.find_dir('websocketpp/websocketpp')
@@ -24,40 +25,36 @@
 
         versionFile = websocketDir.find_node('version.hpp')
         if not websocketDir:
-            raise Errors.WafError('Corrupted: WebSocket version file not found')
+            raise Errors.WafError('WebSocket++ version file not found')
 
         try:
             txt = versionFile.read()
         except (OSError, IOError):
-            raise Errors.WafError('Corrupted: cannot read WebSocket version file')
+            raise Errors.WafError('Cannot read WebSocket++ version file')
 
+        version = [None, None, None]
         # Looking for the following:
         # static int const major_version = 0;
         # static int const minor_version = 7;
         # static int const patch_version = 0;
-
-        version = [None, None, None]
-
         majorVersion = re.compile('^static int const major_version = (\\d+);$', re.M)
         version[0] = majorVersion.search(txt)
-
         minorVersion = re.compile('^static int const minor_version = (\\d+);$', re.M)
         version[1] = minorVersion.search(txt)
-
         patchVersion = re.compile('^static int const patch_version = (\\d+);$', re.M)
         version[2] = patchVersion.search(txt)
 
         if not version[0] or not version[1] or not version[2]:
-            raise Errors.WafError('Corrupted: cannot detect websocket version')
+            raise Errors.WafError('Cannot detect WebSocket++ version')
 
-        self.env['WEBSOCKET_VERSION'] = [i.group(1) for i in version]
+        self.env.WEBSOCKET_VERSION = [i.group(1) for i in version]
 
         # todo: version checking, if necessary
 
-        self.end_msg('.'.join(self.env['WEBSOCKET_VERSION']))
+        self.end_msg('.'.join(self.env.WEBSOCKET_VERSION))
 
-        self.env['INCLUDES_WEBSOCKET'] = websocketDir.parent.abspath()
-        self.env['HAVE_WEBSOCKET'] = True
+        self.env.INCLUDES_WEBSOCKET = websocketDir.parent.abspath()
+        self.env.HAVE_WEBSOCKET = True
         self.define('HAVE_WEBSOCKET', 1)
         self.define('_WEBSOCKETPP_CPP11_STL_', 1)
 
@@ -71,6 +68,6 @@
             Logs.warn('    curl -L https://github.com/zaphoyd/websocketpp/archive/0.7.0.tar.gz > websocket.tar.gz')
             Logs.warn('    tar zxf websocket.tar.gz -C websocketpp/ --strip 1')
             Logs.warn('Alternatively, WebSocket support can be disabled with --without-websocket')
-            self.fatal("The configuration failed")
+            self.fatal('The configuration failed')
         else:
             self.end_msg(str(error))