Premake,命令行选项不执行任何操作

问题描述 投票:0回答:1

我的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).

两个版本都在运行,我不明白。我试图获得一个切换,以选择是否要构建测试。

lua compilation build-system premake
1个回答
0
投票

configuration()是函数,而不是if-then。您上面的示例等效于...

configuration("build-tests")
print("bbbbbbbbb")
include("Src/tests/tests.lua")

configuration("not build-tests")
print("aaaaaaaaaaa")

它对在您的脚本中运行或不运行的代码没有影响; all脚本中的代码始终运行,然后稍后评估配置条件。

而不是查看实际生成的项目输出,以查看一切是否正常。

© www.soinside.com 2019 - 2024. All rights reserved.