@BASENAME@ in install_dir of custom_target()

86 views
Skip to first unread message

Nicholas Brown

unread,
Nov 9, 2020, 10:38:05 AM11/9/20
to The Meson Build System
@BASENAME@ does not work in install_dir on custom_target() and I cannot think of work around.

I need the generated files to end up in at (just example, I have 50+ files, not just 3):

If I use @BASENAME@ in install_dir to try and create the directory needed, it does not expand, and instead just creates a literal '@BASENAME@' directory.

How can achieve the installed location needed?

protobuf_sources= [
'apples.proto',
'oranges.proto',
'pears.proto'
]

protobuf_generated_go = []
foreach protobuf_definition : protobuf_sources

protobuf_generated_go += custom_target('go_' + protobuf_definition,
       command: [protoc, '--proto_path=@CURRENT_SOURCE_DIR@', '--go_out=paths=source_relative:@OUTDIR@', '@INPUT@'],
       input: protobuf_definition,
       output: '@BASENAME@.pb.go',
       install: true,
       install_dir: 'share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/'
)

endforeach

Nicholas Brown

unread,
Nov 9, 2020, 5:50:08 PM11/9/20
to The Meson Build System

A work around for this is to use format and string splitting:

install_dir: 'share/gocode/src/github.com/foo/bar/protobuf/go/@0@'.format(protobuf_definition.split('.')[0])

However extending substitution support to the install_dir: parameter, along side the existing command: and output: substitution support, would be a very useful feature.

https://github.com/mesonbuild/meson/issues/7957#issuecomment-724321719
https://stackoverflow.com/a/64759950/898671

Reply all
Reply to author
Forward
0 new messages