Open gunechristensen opened 2 years ago
In the depfile, what is the path to shc_dep? Nothing.
It therefore depends on what directory you run meson from.
This has been the case since it was initially implemented in #5702 I guess... /cc @elmarco
Actually wait, no. This comes from #6023, which indeed assumes everything is an absolute path, an assumption which was not originally true.
Hi @eli-schwartz,
Thanks for the answer. Forgot I had this issue open.
What got me confused was the "test cases/common/14 configure file" example. I can make it work by doing 2 things:
1) Add the path to the depfile - as you described 2) But I also had to copy the example to a directory with no spaces
I did the testing on linux (Windows Subsystem for Linux).
Would you be interested in a pull request if I go for a deeper dive? Or do you have a good idea about the root cause?
Working example
meson.build
project('configure file test', 'c')
genprog = import('python3').find_python()
genscript2deps = '@0@/generator-deps.py'.format(meson.current_source_dir())
config = configure_file(
input : 'shc_dep',
output : 'config2deps.h',
depfile : 'depfile.d',
command : [genprog, genscript2deps, '@OUTPUT@', '@DEPFILE@']
)
generator-deps.py
#!/usr/bin/env python3
import sys, os
from pathlib import Path
if len(sys.argv) != 3:
print("Wrong amount of parameters.")
source_root = Path(os.environ['MESON_SOURCE_ROOT'])
output = Path(sys.argv[1])
with output.open('w') as ofile:
ofile.write("#define ZERO_RESULT 0\n")
depfile = Path(sys.argv[2])
with depfile.open('w') as ofile:
ofile.write(f"{output.name}: {source_root}/shc2_dep\n")
Would you be interested in a pull request if I go for a deeper dive?
Sure.
FWIW, related (I guess).
I am generating a resource file. I tried via generator
and via custom_target
(both) and depfile argument seems broken to me for both invocations.
It does not generate a depfile at all anywhere if I invoke my resource compiler through the custom_target
or generator
. If I invoke the equivalent command from the command line, it does create the dep file.
My resource compiler program throws an exception if it cannot create the dep file, but it does not break when compiling with meson. I assume, then, that the file is created.
Meson will generate the output but not the depfile at all and my resource compiler works well. This means that it is not my resource compiler working wrong, I am guessing, but some kind of weird or unexpected behavior?
It is true also that my command, basically, has no inputs (the input is actually traversing a directory, and for generator I just faked the input by putting a file in the directory to compile the resource for). As a side-effect of invocation a depfile should be generated.
Here, the command line I used for custom_target
:
embedded_resources = custom_target('rmlResources',
output: 'rmlResources.res.hpp',
depfile: 'rmlResources.deps',
command: [resources_compiler_prog,
'rmlResources',
'@OUTPUT@',
'@DEPFILE@',
meson.current_source_dir() / 'resources', meson.current_source_dir() / 'resources/']
)
executable(..., sources: [..., embedded_resources])
Is this incorrect behavior?
Describe the bug
Depfile argument seems broken from 0.53.0 - 0.52.0 and 0.52.1 has the behavior I expect to be correct.
Using configure_file with depfile argument works fine first time after a clean configure. But after running ninja or meson compile changes to dep files are on longer detected. Whats happens is that the depfile is removed from build.ninja.
To Reproduce
meson.build
generator-deps.py
meson build
touch shc_dep
ninja -C build
This works fine!
touch shc_dep
ninja -C build
Nothing happens - ninja just reports ninja: no work to do.
Expected behavior
After touching or changing dep file (shc_dep) I expect build files to be regenerated when running ninja or meson compile.
system parameters
Plain native build
Windows / clang
Python 3.10.1
Meson tried on 0.53.0, 0.55.0, 0.59.0, 0.61.1
Ninja 1.10.2
Plain native build
Linux
Python 3.6.8
Meson 0.60.1
Ninja 1.10.2
configure_file_issue.zip