mirror of https://gitlab.com/ita1024/waf.git
Remove update_outputs from the documentation
This commit is contained in:
parent
4991120891
commit
ef48d49260
|
@ -126,9 +126,3 @@ def c_hook(self, node):
|
|||
# re-bind the extension to this new class
|
||||
return self.create_compiled_task('c2', node)
|
||||
|
||||
# modify the existing class to output the targets in the same directory as the original files
|
||||
Task.update_outputs(c2)
|
||||
Task.update_outputs(waflib.Tools.c.cprogram)
|
||||
Task.update_outputs(waflib.Tools.c.cshlib)
|
||||
Task.update_outputs(waflib.Tools.c.cstlib)
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ def build(bld):
|
|||
#rule = '''echo -e "#include <stdio.h>\\nint main(){ printf(\\"%%d\\", $$RANDOM); return 0;}" > ${TGT}''',
|
||||
rule = fun,
|
||||
target = node,
|
||||
always = True,
|
||||
update_outputs = True)
|
||||
always = True)
|
||||
|
||||
bld.program(
|
||||
source = 'precious.c',
|
||||
|
|
|
@ -594,35 +594,3 @@ def build(ctx):
|
|||
)
|
||||
---------------
|
||||
|
||||
===== File hashes and dependencies
|
||||
|
||||
Nodes created by tasks during the build inherit the signature of the task that created them.
|
||||
Tasks consuming such nodes as inputs will be executed whenever the first tasks are executed.
|
||||
This is usually a desirable behaviour, as the tasks will propagate the dependencies in a transitive manner.
|
||||
|
||||
In a few contexts though, there can be an excess of downstream rebuilds even if the output files content have not changed.
|
||||
This will also cause build files in the source directory to be rebuild whenever a new build is initiated (files in the source directory are hashed).
|
||||
The function 'waflib.Task.update_outputs' is used to enable file hashes in task classes, it is used in the same way as 'waflib.Task.always_run'.
|
||||
|
||||
For convenience, rule-based task generators can provide the *update_outputs* attribute to simplify the declaration:
|
||||
|
||||
[source,python]
|
||||
---------------
|
||||
def build(ctx):
|
||||
ctx(
|
||||
rule = 'touch ${TGT}',
|
||||
source = 'wscript',
|
||||
target = ctx.path.make_node('wscript2'),
|
||||
update_outputs = True
|
||||
)
|
||||
ctx(
|
||||
rule = 'cp ${SRC} ${TGT}',
|
||||
source = ctx.path.make_node('wscript2'),
|
||||
target = 'wscript3'
|
||||
)
|
||||
---------------
|
||||
|
||||
In this example, the file *wscript2* is created in the source directory.
|
||||
The *update_outputs* keyword is therefore necessary to prevent unnecessary rebuilds.
|
||||
Additionally, *wscript3* is only rebuilt when the contents of *wscript2* change.
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ def build(bld):
|
|||
bld(rule=try_compress, target=ini, always=True, kind=kind, frompath=node, files=rels)
|
||||
|
||||
# for the same reason, count_result will be executed each time
|
||||
bld(rule=count_result, target=dist, source=ini, always=True, update_outputs=True)
|
||||
bld(rule=count_result, target=dist, source=ini, always=True)
|
||||
bld(rule=write_template, target=plot, triplet=[png, kind, dist], always=True)
|
||||
bld(rule='${GNUPLOT} < ${SRC[1].abspath()}', target=png, source=[dist, plot])
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ def build(bld):
|
|||
tmp_dir = bld.bldnode.make_node('external_lib')
|
||||
|
||||
# build the external library through an external process
|
||||
# the "update_outputs" is unnecessary unless an external folder is given, for example tmp_dir = bld.root.make_node('/tmp/aaa')
|
||||
bld(rule=some_fun, target=tmp_dir.make_node('flag.lock'), update_outputs=True)
|
||||
bld(rule=some_fun, target=tmp_dir.make_node('flag.lock'))
|
||||
|
||||
# once it is done create a second build group
|
||||
bld.add_group()
|
||||
|
|
|
@ -18,7 +18,7 @@ def configure(conf):
|
|||
|
||||
def build(bld):
|
||||
|
||||
bld(rule='echo "int ko = $$RANDOM;" > ${TGT}', target='faa.h', always=True, update_outputs=True, shell=True, name='z2')
|
||||
bld(rule='echo "int ko = $$RANDOM;" > ${TGT}', target='faa.h', always=True, shell=True, name='z2')
|
||||
bld.program(source='a.c main.c', target='foo', includes='.')
|
||||
|
||||
# sort the tasks in reverse order to force the 'faa.h' creation in last position
|
||||
|
|
|
@ -22,7 +22,6 @@ def build(bld):
|
|||
|
||||
def xxx(**kw):
|
||||
# this is just an alias, but aliases are convenient, use them!
|
||||
kw['update_outputs'] = True
|
||||
if not 'rule' in kw:
|
||||
kw['rule'] = 'cp ${SRC} ${TGT}'
|
||||
return bld(**kw)
|
||||
|
|
|
@ -232,9 +232,6 @@ run
|
|||
source=['%s.ncd' % fn, '%s.ut' % fn],
|
||||
)
|
||||
|
||||
for tgen in bld.get_all_task_gen():
|
||||
tgen.update_outputs=True
|
||||
|
||||
if bld.cmd == 'clean':
|
||||
for tgen in bld.get_all_task_gen():
|
||||
for tgt in waflib.Utils.to_list(tgen.target):
|
||||
|
|
|
@ -151,7 +151,7 @@ class ConfigurationContext(Context.Context):
|
|||
self.msg('Setting out to', self.bldnode.abspath())
|
||||
|
||||
if id(self.srcnode) == id(self.bldnode):
|
||||
Logs.warn('Setting top == out (remember to use "update_outputs")')
|
||||
Logs.warn('Setting top == out')
|
||||
elif id(self.path) != id(self.srcnode):
|
||||
if self.srcnode.is_child_of(self.path):
|
||||
Logs.warn('Are you certain that you do not want to set top="." ?')
|
||||
|
|
|
@ -586,9 +586,6 @@ def process_rule(self):
|
|||
return [nodes, []]
|
||||
cls.scan = scan
|
||||
|
||||
if getattr(self, 'update_outputs', None):
|
||||
Task.update_outputs(cls)
|
||||
|
||||
if getattr(self, 'always', None):
|
||||
cls.always_run = True
|
||||
|
||||
|
|
|
@ -265,7 +265,6 @@ class trans_update(Task.Task):
|
|||
"""Update a .ts files from a list of C++ files"""
|
||||
run_str = '${QT_LUPDATE} ${SRC} -ts ${TGT}'
|
||||
color = 'BLUE'
|
||||
Task.update_outputs(trans_update)
|
||||
|
||||
class XMLHandler(ContentHandler):
|
||||
"""
|
||||
|
|
|
@ -15,7 +15,7 @@ from waflib.Configure import conf
|
|||
|
||||
class valac(Task.Task):
|
||||
"""
|
||||
Task to compile vala files.
|
||||
Compiles vala files
|
||||
"""
|
||||
#run_str = "${VALAC} ${VALAFLAGS}" # ideally
|
||||
#vars = ['VALAC_VERSION']
|
||||
|
@ -36,8 +36,6 @@ class valac(Task.Task):
|
|||
|
||||
return ret
|
||||
|
||||
valac = Task.update_outputs(valac) # no decorators for python2 classes
|
||||
|
||||
@taskgen_method
|
||||
def init_vala_task(self):
|
||||
"""
|
||||
|
|
|
@ -12,7 +12,7 @@ from waflib.Tools import c_preproc
|
|||
@extension('.rc')
|
||||
def rc_file(self, node):
|
||||
"""
|
||||
Bind the .rc extension to a winrc task
|
||||
Binds the .rc extension to a winrc task
|
||||
"""
|
||||
obj_ext = '.rc.o'
|
||||
if self.env.WINRC_TGT_F == '/fo':
|
||||
|
@ -29,7 +29,13 @@ re_lines = re.compile(
|
|||
re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
class rc_parser(c_preproc.c_parser):
|
||||
"""
|
||||
Calculates dependencies in .rc files
|
||||
"""
|
||||
def filter_comments(self, node):
|
||||
"""
|
||||
Overrides :py:meth:`waflib.Tools.c_preproc.c_parser.filter_comments`
|
||||
"""
|
||||
code = node.read()
|
||||
if c_preproc.use_trigraphs:
|
||||
for (a, b) in c_preproc.trig_def: code = code.split(a).join(b)
|
||||
|
@ -45,11 +51,10 @@ class rc_parser(c_preproc.c_parser):
|
|||
|
||||
class winrc(Task.Task):
|
||||
"""
|
||||
Task for compiling resource files
|
||||
Compiles resource files
|
||||
"""
|
||||
run_str = '${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}'
|
||||
color = 'BLUE'
|
||||
|
||||
def scan(self):
|
||||
tmp = rc_parser(self.generator.includes_nodes)
|
||||
tmp.start(self.inputs[0], self.env)
|
||||
|
@ -57,7 +62,7 @@ class winrc(Task.Task):
|
|||
|
||||
def configure(conf):
|
||||
"""
|
||||
Detect the programs RC or windres, depending on the C/C++ compiler in use
|
||||
Detects the programs RC or windres, depending on the C/C++ compiler in use
|
||||
"""
|
||||
v = conf.env
|
||||
v.WINRC_TGT_F = '-o'
|
||||
|
|
|
@ -8,7 +8,7 @@ want to use this to force partial rebuilds, see playground/track_output_files/ f
|
|||
|
||||
Note that there is a variety of ways to implement this, one may want use timestamps on source files too for example,
|
||||
or one may want to hash the files in the source directory only under certain conditions (md5_tstamp tool)
|
||||
or to hash the file in the build directory with its timestamp (similar to 'update_outputs')
|
||||
or to hash the file in the build directory with its timestamp
|
||||
"""
|
||||
|
||||
import os
|
||||
|
@ -24,6 +24,5 @@ def get_bld_sig(self):
|
|||
except AttributeError:
|
||||
return None
|
||||
|
||||
|
||||
Node.Node.get_bld_sig = get_bld_sig
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ class trans_update(Task.Task):
|
|||
"""Update a .ts files from a list of C++ files"""
|
||||
run_str = '${QT_LUPDATE} ${SRC} -ts ${TGT}'
|
||||
color = 'BLUE'
|
||||
Task.update_outputs(trans_update)
|
||||
|
||||
class XMLHandler(ContentHandler):
|
||||
"""
|
||||
|
|
|
@ -69,7 +69,6 @@ Else:\n
|
|||
ctx.env.STATAFLAGS = STATAFLAGS
|
||||
ctx.env.STATAENCODING = STATAENCODING
|
||||
|
||||
@Task.update_outputs
|
||||
class run_do_script_base(Task.Task):
|
||||
"""Run a Stata do-script from the bldnode directory."""
|
||||
run_str = '"${STATACMD}" ${STATAFLAGS} "${SRC[0].abspath()}" "${DOFILETRUNK}"'
|
||||
|
|
|
@ -36,7 +36,6 @@ Else:\n
|
|||
Do not load the 'run_m_script' tool in the main wscript.\n\n""" % MATLAB_COMMANDS)
|
||||
ctx.env.MATLABFLAGS = '-wait -nojvm -nosplash -minimize'
|
||||
|
||||
@Task.update_outputs
|
||||
class run_m_script_base(Task.Task):
|
||||
"""Run a Matlab script."""
|
||||
run_str = '"${MATLABCMD}" ${MATLABFLAGS} -logfile "${LOGFILEPATH}" -r "try, ${MSCRIPTTRUNK}, exit(0), catch err, disp(err.getReport()), exit(1), end"'
|
||||
|
|
|
@ -35,13 +35,11 @@ def configure(conf):
|
|||
if not conf.env.PY2CMD and not conf.env.PY3CMD:
|
||||
conf.fatal("No Python interpreter found!")
|
||||
|
||||
@Task.update_outputs
|
||||
class run_py_2_script(Task.Task):
|
||||
"""Run a Python 2 script."""
|
||||
run_str = '${PY2CMD} ${SRC[0].abspath()}'
|
||||
shell=True
|
||||
|
||||
@Task.update_outputs
|
||||
class run_py_3_script(Task.Task):
|
||||
"""Run a Python 3 script."""
|
||||
run_str = '${PY3CMD} ${SRC[0].abspath()}'
|
||||
|
|
|
@ -34,7 +34,6 @@ Else:\n
|
|||
Do not load the 'run_r_script' tool in the main wscript.\n\n""" % R_COMMANDS)
|
||||
ctx.env.RFLAGS = 'CMD BATCH --slave'
|
||||
|
||||
@Task.update_outputs
|
||||
class run_r_script_base(Task.Task):
|
||||
"""Run a R script."""
|
||||
run_str = '"${RCMD}" ${RFLAGS} "${SRC[0].abspath()}" "${LOGFILEPATH}"'
|
||||
|
|
|
@ -34,12 +34,8 @@ this tool will make the process much easier, for example::
|
|||
def build(bld):
|
||||
def myfun(tsk):
|
||||
tsk.outputs[0].write("data")
|
||||
bld(rule=myfun, update_outputs=True,
|
||||
source='wscript',
|
||||
target='\\\\COMPUTER\\share\\test.txt')
|
||||
bld(rule=myfun, update_outputs=True,
|
||||
source='\\\\COMPUTER\\share\\test.txt',
|
||||
target='\\\\COMPUTER\\share\\test2.txt')
|
||||
bld(rule=myfun, source='wscript', target='\\\\COMPUTER\\share\\test.txt')
|
||||
bld(rule=myfun, source='\\\\COMPUTER\\share\\test.txt', target='\\\\COMPUTER\\share\\test2.txt')
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
Loading…
Reference in New Issue