Handling changed files in a WAF script
Is it possible to write a WAF function in a wscript file that will be called each time a modified file is created?
I want to be able to do the following:
- Process all input files
.hpp
with a custom Python function and output them to create a folder. If such a file has changed, I want to process it and update its definition in the output folder. - Process all input files by
.hpp
external script and output resutls file for build.
UPDATE:
To explain: I want a function fun1(file)
to be executed for every file that is changed that will read the file, modify it, and return the modified version, which should output to the target directory.
source to share
Handling only changed files is one of the main features of WAF ^^
To execute your python function, you can do something like this:
top = '.'
out = 'build'
def configure(conf):
pass
def build(bld):
def fun1(input_file):
# whatever
return output_file_content_as_string
def process(task):
for src_node in task.inputs:
src = src_node.abspath()
tgt = src_node.get_bld()
out = fun1(src)
tgt.write(out)
return 0 # everything ok
bld(
rule = process,
source = ['myfile.hpp', 'myfile2.hpp', ],
)
This will call fun1 on myfile.hpp etc. and will output the build file only in the modified files.
By default, waf manages the signature for each origin to detect any changes and only processes it if the signature change ...
source to share