From 8ed53ed3bea9550329551000e7e1631ec5552de2 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 3 Mar 2015 15:20:33 -0500 Subject: [PATCH] Skip baking and validation phases for "non-configurable" actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/_premake_main.lua | 18 +++++++++++++----- src/base/action.lua | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/_premake_main.lua b/src/_premake_main.lua index c7a6c1a3..5c2caca6 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -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 diff --git a/src/base/action.lua b/src/base/action.lua index 6ae87781..df5dec27 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -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. --