From c2a22602c0b8112b18dc86443a35aa7edcf63b99 Mon Sep 17 00:00:00 2001 From: liamDevine Date: Mon, 1 Nov 2010 22:05:45 +0000 Subject: [PATCH] refactors optimise check to function premake.config.isoptimizedbuild(flags) which is not local scope as it can be used in other places adds function premake.config.should_link_incrementally(cfg) adds new flag NoIncrementalLink --- src/base/api.lua | 1 + src/base/configs.lua | 11 +++++++++++ tests/base/test_config.lua | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/base/api.lua b/src/base/api.lua index 1bcf1b56..c1dd2bac 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -88,6 +88,7 @@ "NoExceptions", "NoFramePointer", "NoImportLib", + "NoIncrementalLink", "NoManifest", "NoMinimalRebuild", "NoNativeWChar", diff --git a/src/base/configs.lua b/src/base/configs.lua index 97ef5635..126d509c 100644 --- a/src/base/configs.lua +++ b/src/base/configs.lua @@ -15,7 +15,18 @@ premake.config = { } + function premake.config.isoptimizedbuild(flags) + return flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed + end + function premake.config.should_link_incrementally(cfg) + if cfg.kind == "StaticLib" + or premake.config.isoptimizedbuild(cfg.flags) + or cfg.flags.NoIncrementalLink then + return false + end + return true + end -- -- Determine if a configuration represents a "debug" or "release" build. -- This controls the runtime library selected for Visual Studio builds diff --git a/tests/base/test_config.lua b/tests/base/test_config.lua index 7bd0786b..178c4ffe 100644 --- a/tests/base/test_config.lua +++ b/tests/base/test_config.lua @@ -56,3 +56,27 @@ prepare() return test.istrue(premake.config.isdebugbuild(cfg)) end + + function suite.shouldIncrementallyLink_staticLib_returnsFalse() + kind "StaticLib" + prepare() + return test.isfalse(premake.config.should_link_incrementally(cfg)) + end + + function suite.shouldIncrementallyLink_optimizeFlagSet_returnsFalse() + flags { "Optimize" } + prepare() + return test.isfalse(premake.config.should_link_incrementally(cfg)) + end + + function suite.shouldIncrementallyLink_NoIncrementalLinkFlag_returnsFalse() + flags { "NoIncrementalLink" } + prepare() + return test.isfalse(premake.config.should_link_incrementally(cfg)) + end + + function suite.shouldIncrementallyLink_notStaticLib_NoIncrementalLinkFlag_noOptimiseFlag_returnsTrue() + prepare() + return test.istrue(premake.config.should_link_incrementally(cfg)) + end +