Generating depfiles with custom tools #14125
-
I'm interested in building some tooling which will generate its own dependencies from an input file. As a toy kitchen example, I have the following project('meson-depfile')
worker = find_program('worker.py', native: true)
custom_target(
'output',
output: 'output.txt',
input: files('manifest.txt'),
command: [
worker,
'--emit-deps', '@DEPFILE@',
'--dir', meson.current_source_dir(),
'@INPUT@',
'@OUTPUT@',
],
depfile: '@[email protected]',
) The worker is some straightforward Python code (heavily simplified for brevity) #!/usr/bin/env python3
import re
import sys
def lower_snake(s):
# snip
def upper_snake(s):
# snip
[progname, emitdeps, depfile, dir, dir_arg, manifest, output] = sys.argv
deps = set([])
outlines = []
with open(manifest, "r", encoding="utf-8") as manifest_f:
# accept lines from manifest to apply a transformation to each line of a file
with open(depfile, "w", encoding="utf-8") as depfile_f:
depfile_f.write(f"{output}: {' '.join(deps)}")
with open(output, "w", encoding="utf-8") as output_f:
output_f.write("\n".join(outlines)) And my
While
However, output.txt: dep.txt Is there an element of the syntax that I am missing here? In this toy example, I could easily declare |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use |
Beta Was this translation helpful? Give feedback.
You can use
ninja -d keepdepfile
to see what is being written into the depfile, and thus why ninja is ignoring it. Usually when I get these wrong it's because I'm missing a subdir and so ninja is looking for$srcdir/depfile.d
instead of$srdir/subdir/depfile.d
.