在 Makefile 中,可以引用调用时在命令行中设置的参数make
。例如,规则中的配方可能包括 command python/subsample.py $(subsample_size)
,在命令行中通过键入类似make subsample subsample_size=0.1
.
我想对shake
. 我写了以下规则:
phony "echoEnvVar" $ do
ev <- fromMaybe "undefined" <$> getEnv "ev"
liftIO $ putStrLn ev
问题在于shake
将变量的命令行定义ev
视为另一个目标:
jeff@jeff-ThinkCentre-M700:~/shake-studies$ stack exec ./build.sh echoEnvVar ev=whatever
Error when running Shake build system:
* ev=whatever
Error, file does not exist and no rule available:
ev=whatever
CallStack (from HasCallStack):
error, called at src/Development/Shake/Internal/Rules/File.hs:180:58 in shake-0.16.4-7UipAYwzJlKKX7fQ0hMQ1b:Development.Shake.Internal.Rules.File
如果我改为在没有命令行参数的情况下调用该规则,它将按预期运行:
jeff@jeff-ThinkCentre-M700:~/shake-studies$ stack exec ./build.sh echoEnvVar
undefined
Build completed in 0:01m
jeff@jeff-ThinkCentre-M700:~/shake-studies$