Skip to content

Commit

Permalink
third_party: Update waf to version 2.0.22
Browse files Browse the repository at this point in the history
New in waf 2.0.22

* Fix stdin propagation with faulty vcvarsall scripts #2315
* Enable mixing Unix-style paths with destdir on Windows platforms #2337
* Fix shell escaping unit test parameters #2314
* Improve extras/clang_compilation_database and extras/swig compatibility #2336
* Propagate C++ flags to the Cuda compiler in extras/cuda #2311
* Fix detection of Qt 5.0.0 (preparation for Qt6) #2331
* Enable Haxe processing #2308
* Fix regression in MACOSX_DEPLOYMENT_TARGET caused by distutils #2330
* Fix extras/wafcache concurrent trimming issues #2312
* Fix extras/wafcache symlink handling #2327

The import was done like this:

./third_party/waf/update.sh

Then changing buildtools/bin/waf and buildtools/wafsamba/wafsamba.py
by hand.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Sep  2 21:22:17 UTC 2021 on sn-devel-184
  • Loading branch information
cryptomilk authored and abartlet committed Sep 2, 2021
1 parent e41bc0f commit 59ed099
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 44 deletions.
2 changes: 1 addition & 1 deletion buildtools/bin/waf
Expand Up @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.

import os, sys, inspect

VERSION="2.0.21"
VERSION="2.0.22"
REVISION="x"
GIT="x"
INSTALL="x"
Expand Down
2 changes: 1 addition & 1 deletion buildtools/wafsamba/wafsamba.py
Expand Up @@ -38,7 +38,7 @@

os.environ['PYTHONUNBUFFERED'] = '1'

if Context.HEXVERSION not in (0x2001500,):
if Context.HEXVERSION not in (0x2001600,):
Logs.error('''
Please use the version of waf that comes with Samba, not
a system installed version. See http://wiki.samba.org/index.php/Waf
Expand Down
4 changes: 2 additions & 2 deletions third_party/waf/waflib/Build.py
Expand Up @@ -1066,9 +1066,9 @@ def get_install_path(self, destdir=True):
else:
dest = os.path.normpath(Utils.subst_vars(self.install_to, self.env))
if not os.path.isabs(dest):
dest = os.path.join(self.env.PREFIX, dest)
dest = os.path.join(self.env.PREFIX, dest)
if destdir and Options.options.destdir:
dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep))
dest = Options.options.destdir.rstrip(os.sep) + os.sep + os.path.splitdrive(dest)[1].lstrip(os.sep)
return dest

def copy_fun(self, src, tgt):
Expand Down
6 changes: 3 additions & 3 deletions third_party/waf/waflib/Context.py
Expand Up @@ -18,13 +18,13 @@ class imp(object):
import imp

# the following 3 constants are updated on each new release (do not touch)
HEXVERSION=0x2001500
HEXVERSION=0x2001600
"""Constant updated on new releases"""

WAFVERSION="2.0.21"
WAFVERSION="2.0.22"
"""Constant updated on new releases"""

WAFREVISION="edde20a6425a5c3eb6b47d5f3f5c4fbc93fed5f4"
WAFREVISION="816d5bc48ba2abc4ac22f2b44d94d322bf992b9c"
"""Git revision when the waf version is updated"""

WAFNAME="waf"
Expand Down
2 changes: 1 addition & 1 deletion third_party/waf/waflib/Tools/msvc.py
Expand Up @@ -193,7 +193,7 @@ def get_msvc_version(conf, compiler, version, target, vcvars):
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%;%%LIBPATH%%
""" % (vcvars,target))
sout = conf.cmd_and_log(['cmd.exe', '/E:on', '/V:on', '/C', batfile.abspath()])
sout = conf.cmd_and_log(['cmd.exe', '/E:on', '/V:on', '/C', batfile.abspath()], stdin=getattr(Utils.subprocess, 'DEVNULL', None))
lines = sout.splitlines()

if not lines[0]:
Expand Down
2 changes: 1 addition & 1 deletion third_party/waf/waflib/Tools/python.py
Expand Up @@ -327,7 +327,7 @@ def check_python_headers(conf, features='pyembed pyext'):
dct = dict(zip(v, lst))
x = 'MACOSX_DEPLOYMENT_TARGET'
if dct[x]:
env[x] = conf.environ[x] = dct[x]
env[x] = conf.environ[x] = str(dct[x])
env.pyext_PATTERN = '%s' + dct['SO'] # not a mistake


Expand Down
6 changes: 3 additions & 3 deletions third_party/waf/waflib/Tools/qt5.py
Expand Up @@ -566,7 +566,7 @@ def find_qt5_binaries(self):
# at the end, try to find qmake in the paths given
# keep the one with the highest version
cand = None
prev_ver = ['5', '0', '0']
prev_ver = ['0', '0', '0']
for qmk in ('qmake-qt5', 'qmake5', 'qmake'):
try:
qmake = self.find_program(qmk, path_list=paths)
Expand All @@ -580,7 +580,7 @@ def find_qt5_binaries(self):
else:
if version:
new_ver = version.split('.')
if new_ver > prev_ver:
if new_ver[0] == '5' and new_ver > prev_ver:
cand = qmake
prev_ver = new_ver

Expand Down Expand Up @@ -783,7 +783,7 @@ def set_qt5_libs_to_check(self):
pat = self.env.cxxstlib_PATTERN
if Utils.unversioned_sys_platform() == 'darwin':
pat = r"%s\.framework"
re_qt = re.compile(pat%'Qt5?(?P<name>.*)'+'$')
re_qt = re.compile(pat % 'Qt5?(?P<name>\\D+)' + '$')
for x in dirlst:
m = re_qt.match(x)
if m:
Expand Down
2 changes: 1 addition & 1 deletion third_party/waf/waflib/Tools/waf_unit_test.py
Expand Up @@ -206,7 +206,7 @@ def run(self):
self.ut_exec = getattr(self.generator, 'ut_exec', [self.inputs[0].abspath()])
ut_cmd = getattr(self.generator, 'ut_cmd', False)
if ut_cmd:
self.ut_exec = shlex.split(ut_cmd % ' '.join(self.ut_exec))
self.ut_exec = shlex.split(ut_cmd % Utils.shell_escape(self.ut_exec))

return self.exec_command(self.ut_exec)

Expand Down
15 changes: 9 additions & 6 deletions third_party/waf/waflib/Utils.py
Expand Up @@ -11,7 +11,7 @@

from __future__ import with_statement

import atexit, os, sys, errno, inspect, re, datetime, platform, base64, signal, functools, time
import atexit, os, sys, errno, inspect, re, datetime, platform, base64, signal, functools, time, shlex

try:
import cPickle
Expand Down Expand Up @@ -577,10 +577,13 @@ def quote_define_name(s):
fu = fu.upper()
return fu

re_sh = re.compile('\\s|\'|"')
"""
Regexp used for shell_escape below
"""
# shlex.quote didn't exist until python 3.3. Prior to that it was a non-documented
# function in pipes.
try:
shell_quote = shlex.quote
except AttributeError:
import pipes
shell_quote = pipes.quote

def shell_escape(cmd):
"""
Expand All @@ -589,7 +592,7 @@ def shell_escape(cmd):
"""
if isinstance(cmd, str):
return cmd
return ' '.join(repr(x) if re_sh.search(x) else x for x in cmd)
return ' '.join(shell_quote(x) for x in cmd)

def h_list(lst):
"""
Expand Down
28 changes: 15 additions & 13 deletions third_party/waf/waflib/extras/clang_compilation_database.py
Expand Up @@ -29,22 +29,9 @@ def configure(conf):

Task.Task.keep_last_cmd = True

@TaskGen.feature('c', 'cxx')
@TaskGen.after_method('process_use')
def collect_compilation_db_tasks(self):
"Add a compilation database entry for compiled tasks"
if not isinstance(self.bld, ClangDbContext):
return

tup = tuple(y for y in [Task.classes.get(x) for x in ('c', 'cxx')] if y)
for task in getattr(self, 'compiled_tasks', []):
if isinstance(task, tup):
self.bld.clang_compilation_database_tasks.append(task)

class ClangDbContext(Build.BuildContext):
'''generates compile_commands.json by request'''
cmd = 'clangdb'
clang_compilation_database_tasks = []

def write_compilation_database(self):
"""
Expand Down Expand Up @@ -78,6 +65,8 @@ def execute(self):
Build dry run
"""
self.restore()
self.cur_tasks = []
self.clang_compilation_database_tasks = []

if not self.all_envs:
self.load_envs()
Expand All @@ -103,8 +92,21 @@ def exec_command(self, *k, **kw):
lst = [tg]
else: lst = tg.tasks
for tsk in lst:
if tsk.__class__.__name__ == "swig":
tsk.runnable_status()
if hasattr(tsk, 'more_tasks'):
lst.extend(tsk.more_tasks)
# Not all dynamic tasks can be processed, in some cases
# one may have to call the method "run()" like this:
#elif tsk.__class__.__name__ == 'src2c':
# tsk.run()
# if hasattr(tsk, 'more_tasks'):
# lst.extend(tsk.more_tasks)

tup = tuple(y for y in [Task.classes.get(x) for x in ('c', 'cxx')] if y)
if isinstance(tsk, tup):
self.clang_compilation_database_tasks.append(tsk)
tsk.nocache = True
old_exec = tsk.exec_command
tsk.exec_command = exec_command
tsk.run()
Expand Down
131 changes: 131 additions & 0 deletions third_party/waf/waflib/extras/haxe.py
@@ -0,0 +1,131 @@
import os, re
from waflib import Utils, Task, Errors
from waflib.TaskGen import extension, taskgen_method, feature
from waflib.Configure import conf

@conf
def libname_haxe(self, libname):
return libname

@conf
def check_lib_haxe(self, libname, uselib_store=None):
haxe_libs = [node.name for node in self.root.find_node('haxe_libraries').ant_glob()]
changed = False
self.start_msg('Checking for library %s' % libname)
if libname + '.hxml' in haxe_libs:
self.end_msg('yes')
else:
changed = True
try:
cmd = self.env.LIX + ['+lib', libname]
res = self.cmd_and_log(cmd)
if (res):
raise Errors.WafError(res)
else:
self.end_msg('downloaded', color = 'YELLOW')
except Errors.WafError as e:
self.end_msg('no', color = 'RED')
self.fatal('Getting %s has failed' % libname)

postfix = uselib_store if uselib_store else libname.upper()
self.env['LIB_' + postfix] += [self.libname_haxe(libname)]
return changed

@conf
def check_libs_haxe(self, libnames, uselib_store=None):
changed = False
for libname in Utils.to_list(libnames):
if self.check_lib_haxe(libname, uselib_store):
changed = True
return changed

@conf
def ensure_lix_pkg(self, *k, **kw):
if kw.get('compiler') == 'hx':
if isinstance(kw.get('libs'), list) and len(kw.get('libs')):
changed = self.check_libs_haxe(kw.get('libs'), kw.get('uselib_store'))
if changed:
try:
cmd = self.env.LIX + ['download']
res = self.cmd_and_log(cmd)
if (res):
raise Errors.WafError(res)
except Errors.WafError as e:
self.fatal('lix download has failed')
else:
self.check_lib_haxe(kw.get('lib'), kw.get('uselib_store'))

@conf
def haxe(bld, *k, **kw):
task_gen = bld(*k, **kw)

class haxe(Task.Task):
vars = ['HAXE', 'HAXE_VERSION', 'HAXEFLAGS']
ext_out = ['.hl', '.c', '.h']

def run(self):
cmd = self.env.HAXE + self.env.HAXEFLAGS
return self.exec_command(cmd, stdout = open(os.devnull, 'w'))

@taskgen_method
def init_haxe_task(self, node):
def addflags(flags):
self.env.append_value('HAXEFLAGS', flags)

if node.suffix() == '.hxml':
addflags(self.path.abspath() + '/' + node.name)
else:
addflags(['-main', node.name])
addflags(['-hl', self.path.get_bld().make_node(self.target).abspath()])
addflags(['-cp', self.path.abspath()])
addflags(['-D', 'resourcesPath=%s' % getattr(self, 'res', '')])
if hasattr(self, 'use'):
for dep in self.use:
if self.env['LIB_' + dep]:
for lib in self.env['LIB_' + dep]: addflags(['-lib', lib])

@extension('.hx', '.hxml')
def haxe_file(self, node):
if len(self.source) > 1:
self.bld.fatal('Use separate task generators for multiple files')

try:
haxetask = self.haxetask
except AttributeError:
haxetask = self.haxetask = self.create_task('haxe')
self.init_haxe_task(node)

haxetask.inputs.append(node)
haxetask.outputs.append(self.path.get_bld().make_node(self.target))

@conf
def find_haxe(self, min_version):
npx = self.env.NPX = self.find_program('npx')
self.env.LIX = npx + ['lix']
npx_haxe = self.env.HAXE = npx + ['haxe']
try:
output = self.cmd_and_log(npx_haxe + ['-version'])
except Errors.WafError:
haxe_version = None
else:
ver = re.search(r'\d+.\d+.\d+', output).group().split('.')
haxe_version = tuple([int(x) for x in ver])

self.msg('Checking for haxe version',
haxe_version, haxe_version and haxe_version >= min_version)
if npx_haxe and haxe_version < min_version:
self.fatal('haxe version %r is too old, need >= %r' % (haxe_version, min_version))

self.env.HAXE_VERSION = haxe_version
return npx_haxe

@conf
def check_haxe(self, min_version=(4,1,4)):
if self.env.HAXE_MINVER:
min_version = self.env.HAXE_MINVER
find_haxe(self, min_version)

def configure(self):
self.env.HAXEFLAGS = []
self.check_haxe()
self.add_os_flags('HAXEFLAGS', dup = False)

0 comments on commit 59ed099

Please sign in to comment.