Merge action handling improvements

This commit is contained in:
Jason Perkins 2015-03-04 16:19:12 -05:00
commit e267e775d4
4 changed files with 60 additions and 60 deletions

View File

@ -10,3 +10,5 @@ Since 5.0-alpha1:
* filter() now accepts field value aliases in the conditions
* Fixed _ACTION and _OPTIONS filter prefixes
* Main application logic can now be extended by modules
* Action arguments (_ARGS) are now keyed by both index and value
* Configuration baking and validation now skipped for execute only actions

View File

@ -217,7 +217,7 @@
os.exit(1)
end
if not os.isfile(_MAIN_SCRIPT) then
if p.action.isConfigurable() and not os.isfile(_MAIN_SCRIPT) then
print(string.format("No Premake script (%s) found!", path.getname(_MAIN_SCRIPT)))
os.exit(1)
end
@ -230,7 +230,9 @@
---
function m.preBake()
print("Building configurations...")
if p.action.isConfigurable() then
print("Building configurations...")
end
end
@ -239,7 +241,9 @@
---
function m.bake()
premake.oven.bake()
if p.action.isConfigurable() then
premake.oven.bake()
end
end
@ -257,7 +261,9 @@
---
function m.validate()
p.container.validate(p.api.rootContainer())
if p.action.isConfigurable() then
p.container.validate(p.api.rootContainer())
end
end
@ -287,5 +293,7 @@
---
function m.postAction()
print("Done.")
if p.action.isConfigurable() then
print("Done.")
end
end

View File

@ -1,7 +1,7 @@
---
-- action.lua
-- Work with the list of registered actions.
-- Copyright (c) 2002-2014 Jason Perkins and the Premake project
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
---
local p = premake
@ -25,6 +25,7 @@
_ACTION = arg
else
table.insert(_ARGS, arg)
_ARGS[arg] = arg
end
end
end
@ -39,12 +40,12 @@
action._list = {}
--
---
-- Register a new action.
--
-- @param act
-- The new action object.
--
---
function action.add(act)
-- validate the action object, at least a little bit
@ -60,19 +61,16 @@
error(string.format('action "%s" needs a %s', name, missing), 3)
end
-- add it to the master list
action._list[act.trigger] = act
end
--
---
-- Trigger an action.
--
-- @param name
-- The name of the action to be triggered.
-- @returns
-- None.
--
---
function action.call(name)
local act = action._list[name]
@ -112,26 +110,26 @@
end
--
---
-- Retrieve the current action, as determined by _ACTION.
--
-- @return
-- The current action, or nil if _ACTION is nil or does not match any action.
--
---
function action.current()
return action.get(_ACTION)
end
--
---
-- Retrieve an action by name.
--
-- @param name
-- The name of the action to retrieve.
-- @returns
-- The requested action, or nil if the action does not exist.
--
---
function action.get(name)
-- "Next-gen" actions are deprecated
@ -142,9 +140,9 @@
end
--
---
-- Iterator for the list of actions.
--
---
function action.each()
-- sort the list by trigger
@ -162,12 +160,34 @@
end
--
---
-- Determines if an action makes use of the configuration information
-- provided by the project scripts (i.e. it is an exporter) or if it
-- simply performs an action irregardless of configuration, in which
-- case the baking and validation phases can be skipped.
---
function action.isConfigurable(self)
if not self then
self = action.current() or {}
end
if self.onSolution or self.onsolution then
return true
end
if self.onProject or self.onproject then
return true
end
return false
end
---
-- Activates a particular action.
--
-- @param name
-- The name of the action to activate.
--
---
function action.set(name)
_ACTION = name
@ -180,51 +200,28 @@
end
--
---
-- Determines if an action supports a particular language or target type.
--
-- @param act
-- The action to test.
-- @param feature
-- The feature to check, either a programming language or a target type.
-- @returns
-- True if the feature is supported, false otherwise.
--
---
function action.supports(act, feature)
if not act then
function action.supports(self, feature)
if not self then
return false
end
if act.valid_languages then
if table.contains(act.valid_languages, feature) then
if self.valid_languages then
if table.contains(self.valid_languages, feature) then
return true
end
end
if act.valid_kinds then
if table.contains(act.valid_kinds, feature) then
if self.valid_kinds then
if table.contains(self.valid_kinds, feature) then
return true
end
end
return false
end
--
-- Determines if an action supports a particular configuration.
-- @return
-- True if the configuration is supported, false otherwise.
--
function action.supportsconfig(act, cfg)
if not act then
return false
end
if act.supportsconfig then
return act.supportsconfig(cfg)
end
return true
end

View File

@ -177,14 +177,7 @@
local buildcfg = pairing[1]
local platform = pairing[2]
local cfg = oven.bakeConfig(self, buildcfg, platform)
-- Check to make sure this configuration is supported by the current
-- action; add it to the project's configuration cache if so.
if p.action.supportsconfig(cfg) then
self.configs[(buildcfg or "*") .. (platform or "")] = cfg
end
self.configs[(buildcfg or "*") .. (platform or "")] = cfg
end
-- Process the sub-objects that are contained by this project. The