I have the following section in my lua script:
newoption {
trigger = "build-tests",
description = "Build tests."
}
configuration "build-tests"
print("bbbbbbbbb")
include("Src/tests/tests.lua")
configuration "not build-tests"
print("aaaaaaaaaaa")
running premake5 gmake --help
gives:
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
However running premake5 --build-tests gmake
outputs:
bbbbbbbbb
aaaaaaaaaaa
Building configurations...
Running action 'gmake'...
Done (362ms).
BOTH versions are running, I don't understand. I am trying to get a toggle to select whether I want to build tests or not.
configuration()
is a function, not an if-then
. Your example above is equivalent to...
configuration("build-tests")
print("bbbbbbbbb")
include("Src/tests/tests.lua")
configuration("not build-tests")
print("aaaaaaaaaaa")
It has no effect on which code runs or does not run in your script; all the code in your script is always run, and then the configuration conditions are evaluated later.
Instead look at the actual generated project output to see if things are working or not.