aboutsummaryrefslogtreecommitdiffstats
path: root/Task.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-17 17:31:04 +0100
committerDavid Robillard <d@drobilla.net>2019-03-17 17:31:04 +0100
commit1c6fb2b3543d1229eadaa2af007383fbcf82289d (patch)
treed2dcbaf61f3749f73dc7a5e10d3fc6cd5e6e129a /Task.py
parent9ced2d582681fa87b78ed67f186ed94f4bec1178 (diff)
downloadserd-1c6fb2b3543d1229eadaa2af007383fbcf82289d.tar.gz
serd-1c6fb2b3543d1229eadaa2af007383fbcf82289d.tar.bz2
serd-1c6fb2b3543d1229eadaa2af007383fbcf82289d.zip
Squashed 'waflib/' changes from 915dcb17..e7a29b6b
e7a29b6b Upgrade to waf 2.0.15 8280f9de Add command for running executables from the build directory 8073c1ad Make make_simple_dox() safe in case of exception 70d03b82 Avoid use of global counter hacks for configuration display b7d689a4 Rewrite test framework 94deadf0 Automatically add options and move add_flags() to options context f4259ee4 Reduce system include path noise 927b6082 Automatically display configuration header c44b8f3b Set line justification from a constant in the wscript a48e26fd Automatically detect if wscript has a test hook ef66724d Save runtime variables in the environment 63bcbcd3 Clean up TestContext b1d95050 Add ExecutionContext for setting runtime environment 387c1dfa Add show_diff() and test_file_equals() utilities 29d4d293 Fix in-tree library paths 9fde01f4 Add custom configuration context 6d3612fd Add lib_path_name constant git-subtree-dir: waflib git-subtree-split: e7a29b6b9b2f842314244c23c14d8f8f560904e1
Diffstat (limited to 'Task.py')
-rw-r--r--Task.py58
1 files changed, 35 insertions, 23 deletions
diff --git a/Task.py b/Task.py
index 0fc449d4..cb49a739 100644
--- a/Task.py
+++ b/Task.py
@@ -50,6 +50,9 @@ def f(tsk):
bld = gen.bld
cwdx = tsk.get_cwd()
p = env.get_flat
+ def to_list(xx):
+ if isinstance(xx, str): return [xx]
+ return xx
tsk.last_cmd = cmd = \'\'\' %s \'\'\' % s
return tsk.exec_command(cmd, cwd=cwdx, env=env.env or None)
'''
@@ -77,7 +80,8 @@ def f(tsk):
COMPILE_TEMPLATE_SIG_VARS = '''
def f(tsk):
- super(tsk.__class__, tsk).sig_vars()
+ sig = tsk.generator.bld.hash_env_vars(tsk.env, tsk.vars)
+ tsk.m.update(sig)
env = tsk.env
gen = tsk.generator
bld = gen.bld
@@ -159,10 +163,10 @@ class Task(evil):
"""File extensions that objects of this task class may create"""
before = []
- """List of task class names to execute before instances of this class"""
+ """The instances of this class are executed before the instances of classes whose names are in this list"""
after = []
- """List of task class names to execute after instances of this class"""
+ """The instances of this class are executed after the instances of classes whose names are in this list"""
hcode = Utils.SIG_NIL
"""String representing an additional hash for the class representation"""
@@ -302,25 +306,31 @@ class Task(evil):
if hasattr(self, 'stderr'):
kw['stderr'] = self.stderr
- # workaround for command line length limit:
- # http://support.microsoft.com/kb/830473
- if not isinstance(cmd, str) and (len(repr(cmd)) >= 8192 if Utils.is_win32 else len(cmd) > 200000):
- cmd, args = self.split_argfile(cmd)
- try:
- (fd, tmp) = tempfile.mkstemp()
- os.write(fd, '\r\n'.join(args).encode())
- os.close(fd)
- if Logs.verbose:
- Logs.debug('argfile: @%r -> %r', tmp, args)
- return self.generator.bld.exec_command(cmd + ['@' + tmp], **kw)
- finally:
+ if not isinstance(cmd, str):
+ if Utils.is_win32:
+ # win32 compares the resulting length http://support.microsoft.com/kb/830473
+ too_long = sum([len(arg) for arg in cmd]) + len(cmd) > 8192
+ else:
+ # non-win32 counts the amount of arguments (200k)
+ too_long = len(cmd) > 200000
+
+ if too_long and getattr(self, 'allow_argsfile', True):
+ # Shunt arguments to a temporary file if the command is too long.
+ cmd, args = self.split_argfile(cmd)
try:
- os.remove(tmp)
- except OSError:
- # anti-virus and indexers can keep files open -_-
- pass
- else:
- return self.generator.bld.exec_command(cmd, **kw)
+ (fd, tmp) = tempfile.mkstemp()
+ os.write(fd, '\r\n'.join(args).encode())
+ os.close(fd)
+ if Logs.verbose:
+ Logs.debug('argfile: @%r -> %r', tmp, args)
+ return self.generator.bld.exec_command(cmd + ['@' + tmp], **kw)
+ finally:
+ try:
+ os.remove(tmp)
+ except OSError:
+ # anti-virus and indexers can keep files open -_-
+ pass
+ return self.generator.bld.exec_command(cmd, **kw)
def process(self):
"""
@@ -776,6 +786,8 @@ class Task(evil):
Used by :py:meth:`waflib.Task.Task.signature`; it hashes :py:attr:`waflib.Task.Task.env` variables/values
When overriding this method, and if scriptlet expressions are used, make sure to follow
the code in :py:meth:`waflib.Task.Task.compile_sig_vars` to enable dependencies on scriptlet results.
+
+ This method may be replaced on subclasses by the metaclass to force dependencies on scriptlet code.
"""
sig = self.generator.bld.hash_env_vars(self.env, self.vars)
self.m.update(sig)
@@ -1038,7 +1050,7 @@ def funex(c):
exec(c, dc)
return dc['f']
-re_cond = re.compile('(?P<var>\w+)|(?P<or>\|)|(?P<and>&)')
+re_cond = re.compile(r'(?P<var>\w+)|(?P<or>\|)|(?P<and>&)')
re_novar = re.compile(r'^(SRC|TGT)\W+.*?$')
reg_act = re.compile(r'(?P<backslash>\\)|(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})', re.M)
def compile_fun_shell(line):
@@ -1193,7 +1205,7 @@ def compile_fun_noshell(line):
# plain code such as ${tsk.inputs[0].abspath()}
call = '%s%s' % (var, code)
add_dvar(call)
- app('gen.to_list(%s)' % call)
+ app('to_list(%s)' % call)
else:
# a plain variable such as # a plain variable like ${AR}
app('to_list(env[%r])' % var)