如何从Meson构建脚本运行shell命令(例如cp
,即复制)?
我尝试使用以下代码:
r = run_command('cp', 'test.txt', 'test2.txt')
if r.returncode() != 0
warning('Command failed')
endif
但是它什么也没做。
run_command
运行成功(返回0),但没有文件被复制。如果我用
cp3
替换 cp
,我会收到来自 Meson 的错误消息,进程终止,并且甚至无法执行后续的命令。如果我用
test0.txt
替换 test.txt
,我会从脚本中收到错误消息。
所以脚本的行为是正确的,但该命令在文件系统上没有留下任何痕迹。
run_command
是从 Meson 运行 shell 命令的唯一方法吗?我做错了什么?
join_paths
似乎不像附加一样工作。例如:join_path('/path/to/', 'subdir/test.txt') --> /path/to/subdir/test.txt
,而join_path('/path/to/', '/subdir/test.txt') --> /subdir/test.txt
。 - Pietro