我的lua脚本中有以下部分:
newoption {
trigger = "build-tests",
description = "Build tests."
}
configuration "build-tests"
print("bbbbbbbbb")
include("Src/tests/tests.lua")
configuration "not build-tests"
print("aaaaaaaaaaa")
正在运行premake5 gmake --help
给出:
Usage: premake5 [options] action [arguments]
OPTIONS - General
--build-benchmarks Build benchmarks.
--build-tests Build tests.
--debugger Start MobDebug remote debugger. Works with ZeroBrane Studio
--fatal Treat warnings from project scripts as errors
--file=FILE Read FILE as a Premake script; default is 'premake5.lua'
--help Display this information
但是正在运行premake5 --build-tests gmake
输出:
bbbbbbbbb
aaaaaaaaaaa
Building configurations...
Running action 'gmake'...
Done (362ms).
两个版本都在运行,我不明白。我试图获得一个切换,以选择是否要构建测试。
configuration()
是函数,而不是if-then
。您上面的示例等效于...
configuration("build-tests")
print("bbbbbbbbb")
include("Src/tests/tests.lua")
configuration("not build-tests")
print("aaaaaaaaaaa")
它对在您的脚本中运行或不运行的代码没有影响; all脚本中的代码始终运行,然后稍后评估配置条件。
而不是查看实际生成的项目输出,以查看一切是否正常。