Skip baking and validation phases for "non-configurable" actions

For actions that don't actually use the configured project information—such Premake's own embed, test, and release actions—the results of baking and validation phases aren't used, and the extra processing just takes up unnecessary time. Detect this case by checking the action for an onSolution() or onProject() call; if there isn't one, if isn't configurable.

If you have a custom action that does all its work in execute() that *does* need configurable information, you can just define a empty onSolution() function.
This commit is contained in:
Jason Perkins 2015-03-03 15:20:33 -05:00
parent 77a4c81406
commit 8ed53ed3be
2 changed files with 35 additions and 5 deletions

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

@ -160,6 +160,28 @@
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.
--