烤饼有一个功能叫做“
Variables
". 您可以对它进行设置,以便它非常容易地读取命令行参数变量。因此,在您的情况下,您可以从命令行执行以下操作:
scons LIBFOO=C:\custom_path\libfoo
... 变量会在两次运行之间被记住。所以下次你跑的时候
scons
# read variables from the cache, a user's custom.py file or command line
# arguments
var = Variables(['variables.cache', 'custom.py'], ARGUMENTS)
# add a path variable
var.AddVariables(PathVariable('LIBFOO',
'where the foo library is installed',
r'C:\default\libfoo', PathVariable.PathIsDir))
env = Environment(variables=var)
env.Program('test', 'main.c', LIBPATH='$LIBFOO')
# save variables to a file
var.Save('variables.cache', env)
如果您真的想使用“-”样式选项,那么您可以将上面的选项与
AddOption
功能,但它更复杂。
This SO question