Added target action, operating environment to configuration building filters

This commit is contained in:
Jason Perkins 2012-01-22 12:19:43 -05:00
parent 283ecaeb45
commit bcbc7f4950
6 changed files with 111 additions and 17 deletions

View File

@ -146,13 +146,18 @@
if (not ok) then error("Error: " .. err, 0) end
-- work-in-progress: build the configurations
print("Building configurations...")
premake.bake.buildconfigs()
ok, err = premake.checkprojects()
if (not ok) then error("Error: " .. err, 0) end
-- Quick hack: disable the old configuration baking logic for the new
-- next-gen actions; this code will go away when everything has been
-- ported to the new API
if not _ACTION:endswith("ng") then
-- work-in-progress: build the configurations
print("Building configurations...")
premake.bake.buildconfigs()
ok, err = premake.checkprojects()
if (not ok) then error("Error: " .. err, 0) end
end
-- Hand over control to the action
printf("Running action '%s'...", action.trigger)

View File

@ -207,6 +207,7 @@
function premake.getconfigname(cfgname, platform, useshortname)
if cfgname then
print(debug.traceback())
local name = cfgname
if platform and platform ~= "Native" then
if useshortname then

View File

@ -40,7 +40,6 @@
filterTerms = filterTerms or {}
-- keyword/term tests are case-insensitive; convert all terms to lowercase
-- right up front, to save a few cycles
for key, value in pairs(filterTerms) do
filterTerms[key] = value:lower()
end
@ -118,7 +117,7 @@
end
for _, pattern in ipairs(keyword:explode(" or ")) do
for _, term in ipairs(terms) do
for _, term in pairs(terms) do
if term:match(pattern) == term then
return true
end

View File

@ -123,21 +123,26 @@
--
function project.getconfig(prj, buildcfg, platform, field, filename)
local cfg = premake5.oven.bake(prj, { buildcfg, platform }, field)
cfg.project = prj
cfg.buildcfg = buildcfg
cfg.platform = platform
local system
local architecture
-- For backward compatibility with the old platforms API, use platform
-- as the default system or architecture if it would be a valid value.
if cfg.platform then
cfg.system = premake.checkvalue(cfg.platform, premake.fields.system.allowed)
cfg.architecture = premake.checkvalue(cfg.platform, premake.fields.architecture.allowed)
if platform then
system = premake.checkvalue(platform, premake.fields.system.allowed)
architecture = premake.checkvalue(platform, premake.fields.architecture.allowed)
end
-- If no system is specified, try to find one
cfg.system = cfg.system or premake.action.current().os or os.get()
-- Figure out the target operating environment for this configuration
local cfg = premake5.oven.bake(prj, { buildcfg, platform, _ACTION }, "system")
system = cfg.system or system or premake.action.current().os or os.get()
cfg = premake5.oven.bake(prj, { buildcfg, platform, _ACTION, system }, field)
cfg.project = prj
cfg.buildcfg = buildcfg
cfg.platform = platform
cfg.system = system
cfg.architecture = cfg.architecture or architecture
return cfg
end

View File

@ -63,6 +63,7 @@
dofile("project/test_eachconfig.lua")
dofile("project/test_eachfile.lua")
dofile("project/test_filtering.lua")
dofile("project/test_getconfig.lua")
dofile("project/test_vpaths.lua")
-- Configuration object tests

View File

@ -0,0 +1,83 @@
--
-- tests/project/test_getconfig.lua
-- Test the project object configuration accessor.
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
--
T.project_getconfig = { }
local suite = T.project_getconfig
local premake = premake5
--
-- Setup and teardown
--
local sln, prj, cfg
function suite.setup()
sln, prj = test.createsolution()
end
local function prepare()
cfg = premake.project.getconfig(prj)
end
--
-- If the target system is not specified, the current operating environment
-- should be used as the default.
--
function suite.usesCurrentOS_onNoSystemSpecified()
_OS = "linux"
configuration { "linux" }
defines { "correct" }
prepare()
test.isequal("correct", cfg.defines[1])
end
--
-- If the current action specifies a target operating environment (i.e.
-- Visual Studio targets Windows), that should override the current
-- operating environment.
--
function suite.usesCurrentOS_onNoSystemSpecified()
_OS = "linux"
_ACTION = "vs2005"
configuration { "windows" }
defines { "correct" }
prepare()
test.isequal("correct", cfg.defines[1])
end
--
-- If a target system is specified in a configuration, it should override
-- the current operating environment, as well as the tool's target OS.
--
function suite.usesCurrentOS_onNoSystemSpecified()
_OS = "linux"
_ACTION = "vs2005"
system "macosx"
configuration { "macosx" }
defines { "correct" }
prepare()
test.isequal("correct", cfg.defines[1])
end
--
-- The current action should be taken into account.
--
function suite.usesCurrentOS_onNoSystemSpecified()
_ACTION = "vs2005"
configuration { "vs2005" }
defines { "correct" }
prepare()
test.isequal("correct", cfg.defines[1])
end