介子:从可执行文件中打印构建目标文件名()
Meson: print buildtarget filename from executable()
我想打印由 executable()
. Looking into class Executable
创建的 buildtarget
的文件名 我试过 ping.name
:
ping = executable('ping', [
'ping.c',
'ping_common.c',
'ping6_common.c',
'node_info.c',
git_version_h
],
include_directories : inc,
dependencies : [
cap_dep,
idn_dep,
intl_dep,
m_dep,
resolv_dep
],
link_with : [libcommon],
install: true)
message(ping.name))
但是报错:
ping/meson.build:23:17: ERROR: Expecting lparen got rparen.
ping.filename
也是一样,没有to_string()
。这些是“私人”的还是隐藏的?
BuildTarget
是documented,但是没有描述方法。因此,通常如何理解哪些方法是 public 以及某些介子的私有方法 class?
name
其实是一个方法,你漏了(
message(ping.name())
更好的 link 参考是 this one,因为它显示了所有支持的方法。在你的情况下,它也应该工作 full_path()
方法:
message(ping.full_path())
如果您只需要目标文件名而没有 name()
,那么一些 string/array 操作应该可行:
message(ping.full_path().split('/')[-1])
因此,它应该将完整路径名拆分为字符串数组并打印数组的最后一个元素。
我想打印由 executable()
. Looking into class Executable
创建的 buildtarget
的文件名 我试过 ping.name
:
ping = executable('ping', [
'ping.c',
'ping_common.c',
'ping6_common.c',
'node_info.c',
git_version_h
],
include_directories : inc,
dependencies : [
cap_dep,
idn_dep,
intl_dep,
m_dep,
resolv_dep
],
link_with : [libcommon],
install: true)
message(ping.name))
但是报错:
ping/meson.build:23:17: ERROR: Expecting lparen got rparen.
ping.filename
也是一样,没有to_string()
。这些是“私人”的还是隐藏的?
BuildTarget
是documented,但是没有描述方法。因此,通常如何理解哪些方法是 public 以及某些介子的私有方法 class?
name
其实是一个方法,你漏了(
message(ping.name())
更好的 link 参考是 this one,因为它显示了所有支持的方法。在你的情况下,它也应该工作 full_path()
方法:
message(ping.full_path())
如果您只需要目标文件名而没有 name()
,那么一些 string/array 操作应该可行:
message(ping.full_path().split('/')[-1])
因此,它应该将完整路径名拆分为字符串数组并打印数组的最后一个元素。