Merge action handling improvements
This commit is contained in:
commit
e267e775d4
@ -10,3 +10,5 @@ Since 5.0-alpha1:
|
|||||||
* filter() now accepts field value aliases in the conditions
|
* filter() now accepts field value aliases in the conditions
|
||||||
* Fixed _ACTION and _OPTIONS filter prefixes
|
* Fixed _ACTION and _OPTIONS filter prefixes
|
||||||
* Main application logic can now be extended by modules
|
* 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
|
||||||
|
@ -217,7 +217,7 @@
|
|||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
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)))
|
print(string.format("No Premake script (%s) found!", path.getname(_MAIN_SCRIPT)))
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
@ -230,7 +230,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function m.preBake()
|
function m.preBake()
|
||||||
print("Building configurations...")
|
if p.action.isConfigurable() then
|
||||||
|
print("Building configurations...")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +241,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function m.bake()
|
function m.bake()
|
||||||
premake.oven.bake()
|
if p.action.isConfigurable() then
|
||||||
|
premake.oven.bake()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +261,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function m.validate()
|
function m.validate()
|
||||||
p.container.validate(p.api.rootContainer())
|
if p.action.isConfigurable() then
|
||||||
|
p.container.validate(p.api.rootContainer())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -287,5 +293,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function m.postAction()
|
function m.postAction()
|
||||||
print("Done.")
|
if p.action.isConfigurable() then
|
||||||
|
print("Done.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
-- action.lua
|
-- action.lua
|
||||||
-- Work with the list of registered actions.
|
-- 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
|
local p = premake
|
||||||
@ -25,6 +25,7 @@
|
|||||||
_ACTION = arg
|
_ACTION = arg
|
||||||
else
|
else
|
||||||
table.insert(_ARGS, arg)
|
table.insert(_ARGS, arg)
|
||||||
|
_ARGS[arg] = arg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -39,12 +40,12 @@
|
|||||||
action._list = {}
|
action._list = {}
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Register a new action.
|
-- Register a new action.
|
||||||
--
|
--
|
||||||
-- @param act
|
-- @param act
|
||||||
-- The new action object.
|
-- The new action object.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.add(act)
|
function action.add(act)
|
||||||
-- validate the action object, at least a little bit
|
-- validate the action object, at least a little bit
|
||||||
@ -60,19 +61,16 @@
|
|||||||
error(string.format('action "%s" needs a %s', name, missing), 3)
|
error(string.format('action "%s" needs a %s', name, missing), 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add it to the master list
|
|
||||||
action._list[act.trigger] = act
|
action._list[act.trigger] = act
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Trigger an action.
|
-- Trigger an action.
|
||||||
--
|
--
|
||||||
-- @param name
|
-- @param name
|
||||||
-- The name of the action to be triggered.
|
-- The name of the action to be triggered.
|
||||||
-- @returns
|
---
|
||||||
-- None.
|
|
||||||
--
|
|
||||||
|
|
||||||
function action.call(name)
|
function action.call(name)
|
||||||
local act = action._list[name]
|
local act = action._list[name]
|
||||||
@ -112,26 +110,26 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Retrieve the current action, as determined by _ACTION.
|
-- Retrieve the current action, as determined by _ACTION.
|
||||||
--
|
--
|
||||||
-- @return
|
-- @return
|
||||||
-- The current action, or nil if _ACTION is nil or does not match any action.
|
-- The current action, or nil if _ACTION is nil or does not match any action.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.current()
|
function action.current()
|
||||||
return action.get(_ACTION)
|
return action.get(_ACTION)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Retrieve an action by name.
|
-- Retrieve an action by name.
|
||||||
--
|
--
|
||||||
-- @param name
|
-- @param name
|
||||||
-- The name of the action to retrieve.
|
-- The name of the action to retrieve.
|
||||||
-- @returns
|
-- @returns
|
||||||
-- The requested action, or nil if the action does not exist.
|
-- The requested action, or nil if the action does not exist.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.get(name)
|
function action.get(name)
|
||||||
-- "Next-gen" actions are deprecated
|
-- "Next-gen" actions are deprecated
|
||||||
@ -142,9 +140,9 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Iterator for the list of actions.
|
-- Iterator for the list of actions.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.each()
|
function action.each()
|
||||||
-- sort the list by trigger
|
-- sort the list by trigger
|
||||||
@ -162,12 +160,34 @@
|
|||||||
end
|
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.
|
-- Activates a particular action.
|
||||||
--
|
--
|
||||||
-- @param name
|
-- @param name
|
||||||
-- The name of the action to activate.
|
-- The name of the action to activate.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.set(name)
|
function action.set(name)
|
||||||
_ACTION = name
|
_ACTION = name
|
||||||
@ -180,51 +200,28 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Determines if an action supports a particular language or target type.
|
-- Determines if an action supports a particular language or target type.
|
||||||
--
|
--
|
||||||
-- @param act
|
|
||||||
-- The action to test.
|
|
||||||
-- @param feature
|
-- @param feature
|
||||||
-- The feature to check, either a programming language or a target type.
|
-- The feature to check, either a programming language or a target type.
|
||||||
-- @returns
|
-- @returns
|
||||||
-- True if the feature is supported, false otherwise.
|
-- True if the feature is supported, false otherwise.
|
||||||
--
|
---
|
||||||
|
|
||||||
function action.supports(act, feature)
|
function action.supports(self, feature)
|
||||||
if not act then
|
if not self then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if act.valid_languages then
|
if self.valid_languages then
|
||||||
if table.contains(act.valid_languages, feature) then
|
if table.contains(self.valid_languages, feature) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if act.valid_kinds then
|
if self.valid_kinds then
|
||||||
if table.contains(act.valid_kinds, feature) then
|
if table.contains(self.valid_kinds, feature) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
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
|
|
||||||
|
|
||||||
|
@ -177,14 +177,7 @@
|
|||||||
local buildcfg = pairing[1]
|
local buildcfg = pairing[1]
|
||||||
local platform = pairing[2]
|
local platform = pairing[2]
|
||||||
local cfg = oven.bakeConfig(self, buildcfg, platform)
|
local cfg = oven.bakeConfig(self, buildcfg, platform)
|
||||||
|
self.configs[(buildcfg or "*") .. (platform or "")] = cfg
|
||||||
-- 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
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Process the sub-objects that are contained by this project. The
|
-- Process the sub-objects that are contained by this project. The
|
||||||
|
Reference in New Issue
Block a user