Skip to content

Commit

Permalink
Update waf to version 2.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
hedayat committed Oct 1, 2023
1 parent d10ae12 commit c66ccdf
Show file tree
Hide file tree
Showing 52 changed files with 2,210 additions and 447 deletions.
21 changes: 14 additions & 7 deletions waf

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions waflib/Build.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,12 @@ def tgpost(tg):
else:
ln = self.launch_node()
if ln.is_child_of(self.bldnode):
Logs.warn('Building from the build directory, forcing --targets=*')
if Logs.verbose > 1:
Logs.warn('Building from the build directory, forcing --targets=*')
ln = self.srcnode
elif not ln.is_child_of(self.srcnode):
Logs.warn('CWD %s is not under %s, forcing --targets=* (run distclean?)', ln.abspath(), self.srcnode.abspath())
if Logs.verbose > 1:
Logs.warn('CWD %s is not under %s, forcing --targets=* (run distclean?)', ln.abspath(), self.srcnode.abspath())
ln = self.srcnode

def is_post(tg, ln):
Expand Down Expand Up @@ -1064,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
36 changes: 21 additions & 15 deletions waflib/Configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def find_program(self, filename, **kw):

var = kw.get('var', '')
if not var:
var = re.sub(r'[-.]', '_', filename[0].upper())
var = re.sub(r'\W', '_', filename[0].upper())

path_list = kw.get('path_list', '')
if path_list:
Expand Down Expand Up @@ -508,23 +508,27 @@ def find_binary(self, filenames, exts, paths):
@conf
def run_build(self, *k, **kw):
"""
Create a temporary build context to execute a build. A reference to that build
context is kept on self.test_bld for debugging purposes, and you should not rely
on it too much (read the note on the cache below).
The parameters given in the arguments to this function are passed as arguments for
a single task generator created in the build. Only three parameters are obligatory:
Create a temporary build context to execute a build. A temporary reference to that build
context is kept on self.test_bld for debugging purposes.
The arguments to this function are passed to a single task generator for that build.
Only three parameters are mandatory:
:param features: features to pass to a task generator created in the build
:type features: list of string
:param compile_filename: file to create for the compilation (default: *test.c*)
:type compile_filename: string
:param code: code to write in the filename to compile
:param code: input file contents
:type code: string
Though this function returns *0* by default, the build may set an attribute named *retval* on the
Though this function returns *0* by default, the build may bind attribute named *retval* on the
build context object to return a particular value. See :py:func:`waflib.Tools.c_config.test_exec_fun` for example.
This function also features a cache which can be enabled by the following option::
The temporary builds creates a temporary folder; the name of that folder is calculated
by hashing input arguments to this function, with the exception of :py:class:`waflib.ConfigSet.ConfigSet`
objects which are used for both reading and writing values.
This function also features a cache which is disabled by default; that cache relies
on the hash value calculated as indicated above::
def options(opt):
opt.add_option('--confcache', dest='confcache', default=0,
Expand All @@ -537,12 +541,14 @@ def options(opt):
"""
buf = []
for key in sorted(kw.keys()):
if key != 'env':
v = kw[key]
if hasattr(v, '__call__'):
buf.append(Utils.h_fun(v))
else:
buf.append(str(v))
v = kw[key]
if isinstance(v, ConfigSet.ConfigSet):
# values are being written to, so they are excluded from contributing to the hash
continue
elif hasattr(v, '__call__'):
buf.append(Utils.h_fun(v))
else:
buf.append(str(v))
h = Utils.h_list(buf)
dir = self.bldnode.abspath() + os.sep + (not Utils.is_win32 and '.' or '') + 'conf_check_' + Utils.to_hex(h)

Expand Down
22 changes: 16 additions & 6 deletions waflib/Context.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@
Classes and functions enabling the command system
"""

import os, re, imp, sys
import os, re, sys
from waflib import Utils, Errors, Logs
import waflib.Node

if sys.hexversion > 0x3040000:
import types
class imp(object):
new_module = lambda x: types.ModuleType(x)
else:
import imp

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

WAFVERSION="2.0.17"
WAFVERSION="2.0.26"
"""Constant updated on new releases"""

WAFREVISION="6bc6cb599c702e985780e9f705b291b812123693"
WAFREVISION="0fb985ce1932c6f3e7533f435e4ee209d673776e"
"""Git revision when the waf version is updated"""

WAFNAME="waf"
"""Application name displayed on --help"""

ABI = 20
"""Version of the build data cache file format (used in :py:const:`waflib.Context.DBFILE`)"""

Expand Down Expand Up @@ -134,7 +144,7 @@ def foo(ctx):
:type fun: string
.. inheritance-diagram:: waflib.Context.Context waflib.Build.BuildContext waflib.Build.InstallContext waflib.Build.UninstallContext waflib.Build.StepContext waflib.Build.ListContext waflib.Configure.ConfigurationContext waflib.Scripting.Dist waflib.Scripting.DistCheck waflib.Build.CleanContext
:top-classes: waflib.Context.Context
"""

errors = Errors
Expand Down Expand Up @@ -520,7 +530,7 @@ def msg(self, *k, **kw):
"""
Prints a configuration message of the form ``msg: result``.
The second part of the message will be in colors. The output
can be disabled easly by setting ``in_msg`` to a positive value::
can be disabled easily by setting ``in_msg`` to a positive value::
def configure(conf):
self.in_msg = 1
Expand Down
25 changes: 0 additions & 25 deletions waflib/LICENSE.txt

This file was deleted.

31 changes: 24 additions & 7 deletions waflib/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class opt_parser(optparse.OptionParser):
"""
def __init__(self, ctx, allow_unknown=False):
optparse.OptionParser.__init__(self, conflict_handler='resolve', add_help_option=False,
version='waf %s (%s)' % (Context.WAFVERSION, Context.WAFREVISION))
version='%s %s (%s)' % (Context.WAFNAME, Context.WAFVERSION, Context.WAFREVISION))
self.formatter.width = Logs.get_term_cols()
self.ctx = ctx
self.allow_unknown = allow_unknown
Expand All @@ -62,6 +62,21 @@ def _process_args(self, largs, rargs, values):
else:
self.error(str(e))

def _process_long_opt(self, rargs, values):
# --custom-option=-ftxyz is interpreted as -f -t... see #2280
if self.allow_unknown:
back = [] + rargs
try:
optparse.OptionParser._process_long_opt(self, rargs, values)
except optparse.BadOptionError:
while rargs:
rargs.pop()
rargs.extend(back)
rargs.pop(0)
raise
else:
optparse.OptionParser._process_long_opt(self, rargs, values)

def print_usage(self, file=None):
return self.print_help(file)

Expand Down Expand Up @@ -96,11 +111,11 @@ def get_usage(self):
lst.sort()
ret = '\n'.join(lst)

return '''waf [commands] [options]
return '''%s [commands] [options]
Main commands (example: ./waf build -j4)
Main commands (example: ./%s build -j4)
%s
''' % ret
''' % (Context.WAFNAME, Context.WAFNAME, ret)


class OptionsContext(Context.Context):
Expand Down Expand Up @@ -141,9 +156,9 @@ def __init__(self, **kw):
gr.add_option('-o', '--out', action='store', default='', help='build dir for the project', dest='out')
gr.add_option('-t', '--top', action='store', default='', help='src dir for the project', dest='top')

gr.add_option('--no-lock-in-run', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_run')
gr.add_option('--no-lock-in-out', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_out')
gr.add_option('--no-lock-in-top', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_top')
gr.add_option('--no-lock-in-run', action='store_true', default=os.environ.get('NO_LOCK_IN_RUN', ''), help=optparse.SUPPRESS_HELP, dest='no_lock_in_run')
gr.add_option('--no-lock-in-out', action='store_true', default=os.environ.get('NO_LOCK_IN_OUT', ''), help=optparse.SUPPRESS_HELP, dest='no_lock_in_out')
gr.add_option('--no-lock-in-top', action='store_true', default=os.environ.get('NO_LOCK_IN_TOP', ''), help=optparse.SUPPRESS_HELP, dest='no_lock_in_top')

default_prefix = getattr(Context.g_module, 'default_prefix', os.environ.get('PREFIX'))
if not default_prefix:
Expand Down Expand Up @@ -282,6 +297,8 @@ def parse_cmd_args(self, _args=None, cwd=None, allow_unknown=False):
elif arg != 'options':
commands.append(arg)

if options.jobs < 1:
options.jobs = 1
for name in 'top out destdir prefix bindir libdir'.split():
# those paths are usually expanded from Context.launch_dir
if getattr(options, name, None):
Expand Down
4 changes: 2 additions & 2 deletions waflib/Runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, spawner, task):
"""Task to execute"""
self.spawner = spawner
"""Coordinator object"""
self.setDaemon(1)
self.daemon = True
self.start()
def run(self):
"""
Expand All @@ -98,7 +98,7 @@ def __init__(self, master):
""":py:class:`waflib.Runner.Parallel` producer instance"""
self.sem = Utils.threading.Semaphore(master.numjobs)
"""Bounded semaphore that prevents spawning more than *n* concurrent consumers"""
self.setDaemon(1)
self.daemon = True
self.start()
def run(self):
"""
Expand Down
14 changes: 10 additions & 4 deletions waflib/Scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def remove_and_log(k, fun):

# remove a build folder, if any
cur = '.'
if ctx.options.no_lock_in_top:
if os.environ.get('NO_LOCK_IN_TOP') or ctx.options.no_lock_in_top:
cur = ctx.options.out

try:
Expand All @@ -333,9 +333,9 @@ def remove_and_log(k, fun):
remove_and_log(env.out_dir, shutil.rmtree)

env_dirs = [env.out_dir]
if not ctx.options.no_lock_in_top:
if not (os.environ.get('NO_LOCK_IN_TOP') or ctx.options.no_lock_in_top):
env_dirs.append(env.top_dir)
if not ctx.options.no_lock_in_run:
if not (os.environ.get('NO_LOCK_IN_RUN') or ctx.options.no_lock_in_run):
env_dirs.append(env.run_dir)
for k in env_dirs:
p = os.path.join(k, Options.lockfile)
Expand Down Expand Up @@ -388,7 +388,11 @@ def archive(self):

for x in files:
archive_name = self.get_base_name() + '/' + x.path_from(self.base_path)
zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED)
if os.environ.get('SOURCE_DATE_EPOCH'):
# TODO: parse that timestamp
zip.writestr(zipfile.ZipInfo(archive_name), x.read(), zipfile.ZIP_DEFLATED)
else:
zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED)
zip.close()
else:
self.fatal('Valid algo types are tar.bz2, tar.gz, tar.xz or zip')
Expand Down Expand Up @@ -425,6 +429,8 @@ def add_tar_file(self, x, tar):
tinfo.gid = 0
tinfo.uname = 'root'
tinfo.gname = 'root'
if os.environ.get('SOURCE_DATE_EPOCH'):
tinfo.mtime = int(os.environ.get('SOURCE_DATE_EPOCH'))

if os.path.isfile(p):
with open(p, 'rb') as f:
Expand Down
10 changes: 3 additions & 7 deletions waflib/TaskGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def feature(*k):
Decorator that registers a task generator method that will be executed when the
object attribute ``feature`` contains the corresponding key(s)::
from waflib.Task import feature
from waflib.TaskGen import feature
@feature('myfeature')
def myfunction(self):
print('that is my feature!')
Expand Down Expand Up @@ -631,12 +631,8 @@ def chmod_fun(tsk):
cls.scan = self.scan
elif has_deps:
def scan(self):
nodes = []
for x in self.generator.to_list(getattr(self.generator, 'deps', None)):
node = self.generator.path.find_resource(x)
if not node:
self.generator.bld.fatal('Could not find %r (was it declared?)' % x)
nodes.append(node)
deps = getattr(self.generator, 'deps', None)
nodes = self.generator.to_nodes(deps)
return [nodes, []]
cls.scan = scan

Expand Down
5 changes: 2 additions & 3 deletions waflib/Tools/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ class asm(Task.Task):
Compiles asm files by gas/nasm/yasm/...
"""
color = 'BLUE'
run_str = '${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
run_str = '${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${ASMDEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'

def scan(self):
if self.env.ASM_NAME == 'gas':
return c_preproc.scan(self)
Logs.warn('There is no dependency scanner for Nasm!')
return [[], []]
elif self.env.ASM_NAME == 'nasm':
Logs.warn('The Nasm dependency scanner is incomplete!')

Expand Down Expand Up @@ -106,3 +104,4 @@ class asmstlib(stlink_task):

def configure(conf):
conf.env.ASMPATH_ST = '-I%s'
conf.env.ASMDEFINES_ST = '-D%s'
4 changes: 2 additions & 2 deletions waflib/Tools/c_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def sniff_features(**kw):
:return: the list of features for a task generator processing the source files
:rtype: list of string
"""
exts = get_extensions(kw['source'])
exts = get_extensions(kw.get('source', []))
typ = kw['typ']
feats = []

Expand Down Expand Up @@ -72,7 +72,7 @@ def sniff_features(**kw):
feats.append(x + typ)
will_link = True
if not will_link and not kw.get('features', []):
raise Errors.WafError('Cannot link from %r, try passing eg: features="c cprogram"?' % kw)
raise Errors.WafError('Unable to determine how to link %r, try adding eg: features="c cshlib"?' % kw)
return feats

def set_features(kw, typ):
Expand Down
Loading

0 comments on commit c66ccdf

Please sign in to comment.