2012-04-18 19:15:56 +00:00
|
|
|
--
|
|
|
|
-- tests/oven/test_tokens.lua
|
|
|
|
-- Test the Premake oven's handling of tokens.
|
|
|
|
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.oven_tokens = { }
|
|
|
|
local suite = T.oven_tokens
|
|
|
|
local oven = premake5.oven
|
2012-04-20 22:15:32 +00:00
|
|
|
local solution = premake.solution
|
2012-04-18 19:15:56 +00:00
|
|
|
local project = premake5.project
|
2012-04-20 20:08:42 +00:00
|
|
|
local config = premake5.config
|
2012-04-18 19:15:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj, cfg
|
|
|
|
|
|
|
|
function suite.setup()
|
|
|
|
premake.api.register {
|
|
|
|
name = "testapi",
|
|
|
|
kind = "string",
|
|
|
|
scope = "config",
|
2012-04-20 20:08:42 +00:00
|
|
|
tokens = true
|
2012-04-18 19:15:56 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 22:15:32 +00:00
|
|
|
sln = test.createsolution()
|
2012-04-18 19:15:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.teardown()
|
|
|
|
testapi = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function prepare()
|
2012-04-20 22:15:32 +00:00
|
|
|
-- some values are only accessible after a full bake
|
|
|
|
solution.bake(sln)
|
|
|
|
prj = solution.getproject_ng(sln, 1)
|
2012-04-18 19:15:56 +00:00
|
|
|
cfg = project.getconfig(prj, "Debug")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Verify that multiple values can be expanded.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesExpandMultipleValues()
|
|
|
|
testapi "bin/%{prj.name}/%{cfg.buildcfg}"
|
|
|
|
prepare()
|
|
|
|
test.isequal("bin/MyProject/Debug", cfg.testapi)
|
|
|
|
end
|
2012-04-20 20:08:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Verify that file-specific values are expanded.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesExpandTokens_onFileCfg()
|
|
|
|
files { "hello.c" }
|
|
|
|
configuration "**/hello.c"
|
|
|
|
testapi "%{cfg.buildcfg}"
|
|
|
|
prepare()
|
|
|
|
local fcfg = config.getfileconfig(cfg, os.getcwd().."/hello.c")
|
|
|
|
test.isequal("Debug", fcfg.testapi)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Verify handling of tokens in a build rule.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesExpandFileTokens_inBuildRules()
|
|
|
|
files { "shaders/hello.cg" }
|
|
|
|
configuration { "**.cg" }
|
|
|
|
buildrule {
|
|
|
|
commands = {
|
|
|
|
"cgc --profile gp5vp %{file.path} -o %{cfg.objdir}/%{file.basename}.gxp",
|
|
|
|
},
|
|
|
|
outputs = {
|
|
|
|
"%{cfg.objdir}/%{file.basename}.o"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prepare()
|
|
|
|
local fcfg = config.getfileconfig(cfg, os.getcwd().."/shaders/hello.cg")
|
2012-04-23 22:18:31 +00:00
|
|
|
test.isequal("cgc --profile gp5vp shaders/hello.cg -o obj/Debug/hello.gxp", fcfg.buildrule.commands[1])
|
2012-04-20 20:08:42 +00:00
|
|
|
end
|