custom_target fails to work as documented
custom_target's command parameter is documented as
command command to run to create outputs from inputs. The command may be strings or the return value of functions that return file-like objects such as find_program(), executable(), configure_file(), files(), custom_target(), etc. Meson will automatically insert the appropriate dependencies on targets and files listed in this keyword argument.
However, using files() does not work. E.g.:
$ touch foo.txt bar.py
$ cat meson.build
project('test', [], version: '0', license: ['GPL3',],)
foo_sources = custom_target('foo',
input: 'foo.txt',
output: '@BASENAME@',
capture: true,
command: [files('bar.py'), '@INPUT',],
)
and run meson, which results in
Traceback (most recent call last):
File "/work/source/meson/mesonbuild/mesonmain.py", line 122, in run
return options.run_func(options)
File "/work/source/meson/mesonbuild/msetup.py", line 240, in run
app.generate()
File "/work/source/meson/mesonbuild/msetup.py", line 158, in generate
self._generate(env)
File "/work/source/meson/mesonbuild/msetup.py", line 210, in _generate
intr.backend.generate(intr)
File "/work/source/meson/mesonbuild/backend/ninjabackend.py", line 228, in generate
self.generate_target(t, outfile)
File "/work/source/meson/mesonbuild/backend/ninjabackend.py", line 382, in generate_target
self.generate_custom_target(target, outfile)
File "/work/source/meson/mesonbuild/backend/ninjabackend.py", line 611, in generate_custom_target
capture=ofilenames[0] if target.capture else None)
File "/work/source/meson/mesonbuild/backend/backends.py", line 340, in serialize_executable
basename = os.path.basename(exe)
File "/usr/lib64/python3.7/posixpath.py", line 146, in basename
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not File
(meson git master, commit 79e925b8)
Changing files('bar.py') to find_program('bar.py') works, but files() is documented as working, and find_program() also searches in PATH, which is never wanted for files in the source directory.