In a Makefile, one can refer to arguments set at the command line at the time one invokes make
. For instance, the recipe in a rule might include the command python/subsample.py $(subsample_size)
, which one invokes at the command line by typing something like make subsample subsample_size=0.1
.
I would like to do the same thing with shake
. I've written the following rule:
phony "echoEnvVar" $ do
ev <- fromMaybe "undefined" <$> getEnv "ev"
liftIO $ putStrLn ev
The problem is that shake
is treating the command-line definition of the ev
variable as another target:
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
If I instead call that rule with no command-line arguments, it behaves as expected:
jeff@jeff-ThinkCentre-M700:~/shake-studies$ stack exec ./build.sh echoEnvVar
undefined
Build completed in 0:01m
jeff@jeff-ThinkCentre-M700:~/shake-studies$