SCons env.Command() 没有按预期工作,没有执行命令

SCons env.Command() doesn't work as expected, no command executed

我有一个简单的 SConstruct 文件如下:

import os,sys
env = Environment()

env.Command([], [], "echo abc")

我预计这会输出"abc",但实际上并没有打印任何额外的内容,屏幕输出是:

$scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

那我该如何解决呢?非常感谢。

由于您在没有源和目标的情况下调用了构建器,因此它永远不会过时,因此也不会 运行。

所以您希望它立即 运行,在这种情况下您应该使用 Execute()

env = Environment()
env.Execute("echo abc")

或者只是

Execute("echo abc")

后者产生

$ scons
scons: Reading SConscript files ...
echo abc
abc
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.