custom_target: Output must not contain a path segment

573 views
Skip to first unread message

Jason Crain

unread,
Mar 12, 2017, 9:09:28 PM3/12/17
to The Meson Build System
I'm trying to generate some data files that will be used by a test program.  I'd like to keep these files organized in directories to group test cases together.  I'm using a custom target to generate these files, but I'm running into a problem where meson complains "Output must not contain a path segment." or "Depfile must be a plain filename without a subdirectory.".  I'm using something like this in a meson.build:

sources = [
 
'dir1/file1',
 
'dir1/file2',
 
'dir2/file3',
 
'dir3/dir/file4'
]
foreach s : sources
  custom_target
(
    s
+ '.out',
    input
: s + '.in',
    output
: s + '.out',
    command
: ['touch', '@OUTPUT@', '@DEPFILE@'],
    depfile
: s + '.dep',
    build_by_default
: true)
endforeach

Though of course it doesn't use 'touch' and it can generate a real depfile.  If I modify meson and remove the following lines, things work as I expected, at least on linux:

diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index bf692e17
..b3bc9863 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1320,8 +1320,6 @@ class CustomTarget(Target):
         
for i in self.output:
             
if not(isinstance(i, str)):
                 
raise InvalidArguments('Output argument not a string.')
-            if '/' in i:
-                raise InvalidArguments('Output must not contain a path segment.')
             
if '@INPUT@' in i or '@INPUT0@' in i:
                 m
= 'Output cannot contain @INPUT@ or @INPUT0@, did you ' \
                     
'mean @PLAINNAME@ or @BASENAME@?'
@@ -1342,8 +1340,6 @@ class CustomTarget(Target):
             depfile
= kwargs['depfile']
             
if not isinstance(depfile, str):
                 
raise InvalidArguments('Depfile must be a string.')
-            if os.path.split(depfile)[1] != depfile:
-                raise InvalidArguments('Depfile must be a plain filename without a subdirectory.')
             
self.depfile = depfile
         
self.command = self.flatten_command(kwargs['command'])
         
if self.capture:

It looks like meson is intentionally preventing a custom target from writing to a subdirectory.  Is this something that can be supported?
Reply all
Reply to author
Forward
0 new messages