如何在 Tupfile 中为变量分配 shell 命令的输出?

How to assign a variable the output of a shell command in Tupfile?

我想将命令 find . -name "*.cpp" -exec dirname {} \; | sort -u 的输出分配给 Tupfile 中的一个变量。我该怎么做?

这对我有用:

BOTAN_CFLAGS = `pkg-config botan-1.10 --cflags`

注意:反引号 字符“`”

然而,这似乎只在规则的 command 部分有效,而不是 dependencies.

根据我在手册中阅读的内容,变量赋值不会导致执行 shell 命令。相反,它存储为常规字符串。然后,当变量传递给命令时,shell 会扩展它。这意味着如果你有 K 个文件要编译,shell expression 将被计算 K 次。