2009-04-09 20:02:49 +00:00
|
|
|
--
|
|
|
|
-- tests/test_configs.lua
|
|
|
|
-- Automated test suite for the configuration building functions.
|
|
|
|
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.configs = { }
|
|
|
|
|
2009-05-29 15:36:39 +00:00
|
|
|
--
|
|
|
|
-- Setup code
|
|
|
|
--
|
|
|
|
|
2009-05-08 20:18:47 +00:00
|
|
|
local prj, cfg
|
2009-04-09 20:02:49 +00:00
|
|
|
function T.configs.setup()
|
2009-05-08 20:18:47 +00:00
|
|
|
_ACTION = "gmake"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
2009-05-01 19:50:45 +00:00
|
|
|
platforms { "x32", "ps3" }
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
defines "SOLUTION"
|
|
|
|
|
|
|
|
configuration "Debug"
|
|
|
|
defines "SOLUTION_DEBUG"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
prj = project "MyProject"
|
|
|
|
language "C"
|
2009-05-01 19:50:45 +00:00
|
|
|
kind "SharedLib"
|
2009-05-08 20:18:47 +00:00
|
|
|
targetdir "../bin"
|
2009-04-28 00:19:44 +00:00
|
|
|
defines "PROJECT"
|
2009-04-09 20:02:49 +00:00
|
|
|
|
|
|
|
configuration "Debug"
|
|
|
|
defines "DEBUG"
|
|
|
|
|
|
|
|
configuration "Release"
|
|
|
|
defines "RELEASE"
|
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
configuration "native"
|
|
|
|
defines "NATIVE"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
configuration "x32"
|
|
|
|
defines "X86_32"
|
|
|
|
|
|
|
|
configuration "x64"
|
|
|
|
defines "X86_64"
|
2009-05-29 15:36:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2009-04-09 20:02:49 +00:00
|
|
|
premake.buildconfigs()
|
2009-05-08 20:18:47 +00:00
|
|
|
prj = premake.getconfig(prj)
|
|
|
|
cfg = premake.getconfig(prj, "Debug")
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2009-07-15 14:38:28 +00:00
|
|
|
--
|
|
|
|
-- Tests
|
|
|
|
--
|
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.SolutionFields()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
test.isequal("Debug:Release", table.concat(cfg.configurations,":"))
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.ProjectFields()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
test.isequal("C", cfg.language)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
|
|
|
function T.configs.ProjectWideSettings()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-05-08 20:18:47 +00:00
|
|
|
test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":"))
|
2009-04-28 00:19:44 +00:00
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
|
|
|
function T.configs.BuildCfgSettings()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-29 18:51:15 +00:00
|
|
|
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":"))
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
|
|
|
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.PlatformSettings()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:X86_32", table.concat(cfg.defines,":"))
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
|
|
|
function T.configs.SetsConfigName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("Debug", cfg.name)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
|
|
|
function T.configs.SetsPlatformName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("x32", cfg.platform)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
function T.configs.SetsPlatformNativeName()
|
|
|
|
test.isequal("Native", cfg.platform)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.SetsShortName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("debug32", cfg.shortname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
function T.configs.SetsNativeShortName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-29 18:51:15 +00:00
|
|
|
test.isequal("debug", cfg.shortname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.SetsLongName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("Debug|x32", cfg.longname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
function T.configs.SetsNativeLongName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-29 18:51:15 +00:00
|
|
|
test.isequal("Debug", cfg.longname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
function T.configs.SetsProject()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
2009-05-08 20:18:47 +00:00
|
|
|
test.istrue(prj.project == cfg.project)
|
2009-04-28 00:19:44 +00:00
|
|
|
end
|
2009-05-01 19:50:45 +00:00
|
|
|
|
2009-05-08 20:18:47 +00:00
|
|
|
|
|
|
|
|
2009-05-01 19:50:45 +00:00
|
|
|
--
|
|
|
|
-- Target system testing
|
|
|
|
--
|
|
|
|
|
|
|
|
function T.configs.SetsTargetSystem_OnNative()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-05-01 19:50:45 +00:00
|
|
|
test.isequal(os.get(), cfg.system)
|
|
|
|
end
|
|
|
|
|
|
|
|
function T.configs.SetTargetSystem_OnCrossCompiler()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-05-01 19:50:45 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "PS3")
|
|
|
|
test.isequal("PS3", cfg.system)
|
|
|
|
end
|
2009-05-08 20:18:47 +00:00
|
|
|
|
|
|
|
|
2009-05-01 19:50:45 +00:00
|
|
|
|
2009-05-29 15:36:39 +00:00
|
|
|
--
|
|
|
|
-- Configuration-specific kinds
|
|
|
|
--
|
|
|
|
|
2009-05-29 15:41:32 +00:00
|
|
|
function T.configs.SetsConfigSpecificKind()
|
|
|
|
configuration "Debug"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
prepare()
|
|
|
|
test.isequal("ConsoleApp", cfg.kind)
|
|
|
|
end
|
|
|
|
|
2009-05-29 15:36:39 +00:00
|
|
|
|
2009-05-01 19:50:45 +00:00
|
|
|
--
|
|
|
|
-- Platform kind translation
|
|
|
|
--
|
|
|
|
|
|
|
|
function T.configs.SetsTargetKind_OnSupportedKind()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-05-01 19:50:45 +00:00
|
|
|
test.isequal("SharedLib", cfg.kind)
|
|
|
|
end
|
|
|
|
|
|
|
|
function T.configs.SetsTargetKind_OnUnsupportedKind()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-05-01 19:50:45 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "PS3")
|
|
|
|
test.isequal("StaticLib", cfg.kind)
|
|
|
|
end
|