xmake如何支持多个命令级联执行? #2590
Unanswered
xumaofeng-jn
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
xmake 版本号
v2.6.8+202206221403
诉求描述
我希望执行如下两个命令,第二个命令的输入是第一个命令的输出
objdump -p xxx | awk '/^ +SONAME +/ {print $2}'
遇到的问题
在cmake中,使用如下命令即可搞定:
execute_process ( COMMAND objdump -p ${_filename} COMMAND awk "/^ +SONAME +/ {print $2}" OUTPUT_VARIABLE _soname OUTPUT_STRIP_TRAILING_WHITESPACE)
而在 xmake 中,使用如下命令
local inputfile = io.open("$(buildir)/lib/objdump.in", "w") local outputfile = io.open("$(buildir)/lib/objdump.out", "w") os.execv("objdump", {"-p", libpath}, { stdout = inputfile }) os.execv("awk", { '/^ +SONAME +/ {print $2}' }, { stdin = inputfile, stdout = outputfile })
命令执行后,objdump.in文件内容正确,而objdump.out文件内容为空。
是我的使用方式有问题吗?我看文档描述,execv支持标准输入和输出重定向到文件或管道对象,目前不了解管道对象的方式如何写,但是文件的方式看起来不起作用。
另外,即使这种方式可用,看起来也太啰嗦,能否和cmake一样,可以支持多个命令一起执行,后一个命令的输入是前一个命令的输入?
Beta Was this translation helpful? Give feedback.
All reactions