在 Meson 中将 @BASENAME@ 与 custom_target() 的 install_dir 一起使用
Using @BASENAME@ with install_dir of custom_target() in Meson
@BASENAME@
似乎在 Meson custom_target()
函数的 install_dir:
参数中不起作用。
protoc = find_program('protoc')
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
我需要根据输入文件的基本名称将生成的文件放在目录中:
share/gocode/src/github.com/foo/bar/protobuf/go/apples/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/oranges/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/pears/pears.pb.go
如果我在 install_dir:
中使用 @BASENAME@
来尝试创建所需的目录,它不会展开,而只是创建一个文字“@BASENAME@
”目录。
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/pears.pb.go
如何根据基本名称获得所需的安装目录位置?
(上面的例子只有3个文件,我实际有30+个文件)
是的,看起来 install_dir 参数不支持像 BASENAME 这样的占位符,因为此功能针对的是文件名而不是目录。但是您可以在循环中处理字符串迭代器:
foreach protobuf_definition : protobuf_sources
...
install_dir: '.../go/@0@'.format(protobuf_definition.split('.')[0])
endforeach
@BASENAME@
似乎在 Meson custom_target()
函数的 install_dir:
参数中不起作用。
protoc = find_program('protoc')
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
我需要根据输入文件的基本名称将生成的文件放在目录中:
share/gocode/src/github.com/foo/bar/protobuf/go/apples/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/oranges/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/pears/pears.pb.go
如果我在 install_dir:
中使用 @BASENAME@
来尝试创建所需的目录,它不会展开,而只是创建一个文字“@BASENAME@
”目录。
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/@BASENAME@/pears.pb.go
如何根据基本名称获得所需的安装目录位置? (上面的例子只有3个文件,我实际有30+个文件)
是的,看起来 install_dir 参数不支持像 BASENAME 这样的占位符,因为此功能针对的是文件名而不是目录。但是您可以在循环中处理字符串迭代器:
foreach protobuf_definition : protobuf_sources
...
install_dir: '.../go/@0@'.format(protobuf_definition.split('.')[0])
endforeach