【问题标题】:Premake, command line options don't do anythingPremake,命令行选项不做任何事情
【发布时间】:2020-05-25 06:58:14
【问题描述】:

我的 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】:

    configuration() 是一个函数,而不是 if-then。您上面的示例相当于...

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

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

    而是查看实际生成的项目输出,看看事情是否正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-05
      • 2020-03-20
      • 1970-01-01
      • 2021-06-25
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 2018-04-04
      相关资源
      最近更新 更多