2012-11-17 20:49:06 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_config_maps.lua
|
|
|
|
-- Test mapping from solution to project configurations.
|
2014-04-25 15:53:01 +00:00
|
|
|
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
2012-11-17 20:49:06 +00:00
|
|
|
--
|
|
|
|
|
2013-11-14 13:52:55 +00:00
|
|
|
local suite = test.declare("project_config_maps")
|
2012-11-17 20:49:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks, prj, cfg
|
2012-11-17 20:49:06 +00:00
|
|
|
|
|
|
|
function suite.setup()
|
2015-08-28 20:16:14 +00:00
|
|
|
wks = solution("MySolution")
|
2012-11-17 20:49:06 +00:00
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare(buildcfg, platform)
|
2015-08-28 20:16:14 +00:00
|
|
|
prj = wks.projects[1]
|
2013-11-14 13:52:55 +00:00
|
|
|
cfg = test.getconfig(prj, buildcfg or "Debug", platform)
|
2012-11-17 20:49:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- When no configuration is specified in the project, the solution
|
|
|
|
-- settings should map directly to a configuration object.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.solutionConfig_onNoProjectConfigs()
|
|
|
|
project ("MyProject")
|
|
|
|
prepare()
|
|
|
|
test.isequal("Debug", cfg.buildcfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a project configuration mapping exists, it should be taken into
|
|
|
|
-- account when fetching the configuration object.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.appliesCfgMapping_onBuildCfgMap()
|
|
|
|
project ("MyProject")
|
|
|
|
configmap { ["Debug"] = "Development" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("Development", cfg.buildcfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.appliesCfgMapping_onPlatformMap()
|
|
|
|
platforms { "Shared", "Static" }
|
|
|
|
project ("MyProject")
|
|
|
|
configmap { ["Shared"] = "DLL" }
|
|
|
|
prepare("Debug", "Shared")
|
|
|
|
test.isequal("DLL", cfg.platform)
|
|
|
|
end
|
2013-09-13 15:15:36 +00:00
|
|
|
|
2012-11-17 20:49:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a configuration mapping exists, can also use the mapped value
|
|
|
|
-- to fetch the configuration.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.fetchesMappedCfg_onBuildCfgMap()
|
|
|
|
project ("MyProject")
|
|
|
|
configmap { ["Debug"] = "Development" }
|
|
|
|
prepare("Development")
|
|
|
|
test.isequal("Development", cfg.buildcfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.fetchesMappedCfg_onPlatformMap()
|
|
|
|
platforms { "Shared", "Static" }
|
|
|
|
project ("MyProject")
|
|
|
|
configmap { ["Shared"] = "DLL" }
|
|
|
|
prepare("Debug", "DLL")
|
|
|
|
test.isequal("DLL", cfg.platform)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If the specified configuration has been removed from the project,
|
|
|
|
-- then nil should be returned.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.returnsNil_onRemovedBuildCfg()
|
|
|
|
project ("MyProject")
|
|
|
|
removeconfigurations { "Debug" }
|
|
|
|
prepare()
|
|
|
|
test.isnil(cfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.returnsNil_onRemovedPlatform()
|
|
|
|
platforms { "Shared", "Static" }
|
|
|
|
project ("MyProject")
|
|
|
|
removeplatforms { "Shared" }
|
|
|
|
prepare("Debug", "Shared")
|
|
|
|
test.isnil(cfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check mapping from a buildcfg-platform tuple to a simple single
|
|
|
|
-- value platform configuration.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.canMap_tupleToSingle()
|
2015-03-11 20:16:56 +00:00
|
|
|
platforms { "Win32", "Linux" }
|
2012-11-17 20:49:06 +00:00
|
|
|
project ("MyProject")
|
|
|
|
removeconfigurations "*"
|
|
|
|
removeplatforms "*"
|
2015-03-11 20:16:56 +00:00
|
|
|
configurations { "Debug Win32", "Release Win32", "Debug Linux", "Release Linux" }
|
2012-11-17 20:49:06 +00:00
|
|
|
configmap {
|
|
|
|
[{"Debug", "Win32"}] = "Debug Win32",
|
2015-03-11 20:16:56 +00:00
|
|
|
[{"Debug", "Linux"}] = "Debug Linux",
|
2012-11-17 20:49:06 +00:00
|
|
|
[{"Release", "Win32"}] = "Release Win32",
|
2015-03-11 20:16:56 +00:00
|
|
|
[{"Release", "Linux"}] = "Release Linux"
|
2012-11-17 20:49:06 +00:00
|
|
|
}
|
2015-03-11 20:16:56 +00:00
|
|
|
prepare("Debug", "Linux")
|
|
|
|
test.isequal("Debug Linux", cfg.buildcfg)
|
2012-11-17 20:49:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check mapping from a buildcfg-platform tuple to new project
|
|
|
|
-- configuration tuple.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.canMap_tupleToTuple()
|
2015-03-11 20:16:56 +00:00
|
|
|
platforms { "Win32", "Linux" }
|
2012-11-17 20:49:06 +00:00
|
|
|
project ("MyProject")
|
|
|
|
removeconfigurations "*"
|
|
|
|
removeplatforms "*"
|
|
|
|
configurations { "Development", "Production" }
|
2015-04-13 22:27:11 +00:00
|
|
|
platforms { "x86", "x86_64" }
|
2013-09-13 15:15:36 +00:00
|
|
|
|
2012-11-17 20:49:06 +00:00
|
|
|
configmap {
|
2015-04-13 22:27:11 +00:00
|
|
|
[{"Debug", "Win32"}] = { "Development", "x86" },
|
|
|
|
[{"Debug", "Linux"}] = { "Development", "x86_64" },
|
|
|
|
[{"Release", "Win32"}] = { "Production", "x86" },
|
|
|
|
[{"Release", "Linux"}] = { "Production", "x86_64" },
|
2012-11-17 20:49:06 +00:00
|
|
|
}
|
2015-03-11 20:16:56 +00:00
|
|
|
prepare("Debug", "Linux")
|
2015-04-13 22:27:11 +00:00
|
|
|
test.isequal({ "Development", "x86_64" }, { cfg.buildcfg, cfg.platform })
|
2012-11-17 20:49:06 +00:00
|
|
|
end
|
2012-12-23 18:10:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- To allow some measure of global configuration, config maps that are contained
|
|
|
|
-- in configuration blocks are allowed to bubble up to the project level.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.canBubbleUp_onConfiguration()
|
|
|
|
platforms { "XCUA", "XCUB" }
|
2013-09-13 15:15:36 +00:00
|
|
|
|
2014-04-25 15:53:01 +00:00
|
|
|
filter { "platforms:CCU" }
|
2012-12-23 18:10:06 +00:00
|
|
|
configmap { XCUA = "CCU", XCUB = "CCU" }
|
|
|
|
|
|
|
|
project "MyProject"
|
|
|
|
platforms { "CCU" }
|
2013-09-13 15:15:36 +00:00
|
|
|
|
2012-12-23 18:10:06 +00:00
|
|
|
prepare("Debug", "XCUA")
|
|
|
|
test.isequal({"Debug", "CCU"}, {cfg.buildcfg, cfg.platform})
|
|
|
|
end
|