Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-05-16 23:37:48 +0400
committerJason Perkins <starkos@industriousone.com>2011-05-16 23:37:48 +0400
commit7b647b1537ed346c11b4be6e95b34d21fa95154c (patch)
tree5f43e8fe2ec4f8a80324d7f0c08ed3b817801edd
parent43c24650bc476c6f8ab6188fdc232990b532130f (diff)
Split configuration baking into its own file; prep for file config work
-rw-r--r--src/_manifest.lua3
-rw-r--r--src/actions/vstudio/vs200x_vcproj.lua18
-rw-r--r--src/actions/vstudio/vs2010_vcxproj.lua2
-rw-r--r--src/base/bake.lua (renamed from src/base/configs.lua)68
-rw-r--r--src/base/config.lua56
-rw-r--r--tests/base/test_config.lua8
6 files changed, 85 insertions, 70 deletions
diff --git a/src/_manifest.lua b/src/_manifest.lua
index 9748976..3f3c365 100644
--- a/src/_manifest.lua
+++ b/src/_manifest.lua
@@ -21,7 +21,8 @@
"base/tree.lua",
"base/solution.lua",
"base/project.lua",
- "base/configs.lua",
+ "base/config.lua",
+ "base/bake.lua",
"base/api.lua",
"base/cmdline.lua",
"tools/dotnet.lua",
diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua
index 7fbd61e..fde1199 100644
--- a/src/actions/vstudio/vs200x_vcproj.lua
+++ b/src/actions/vstudio/vs200x_vcproj.lua
@@ -344,7 +344,7 @@
_p(4,'OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
_p(4,'LinkIncremental="%s"',
- iif(premake.config.should_link_incrementally(cfg) , 2, 1))
+ iif(premake.config.isincrementallink(cfg) , 2, 1))
_p(4,'AdditionalLibraryDirectories="%s"', table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";"))
@@ -394,14 +394,14 @@
_p(4,'AdditionalLibraryDirectories="%s"', premake.esc(path.translate(table.concat(cfg.libdirs , ";"))))
end
- local addlOptions = {}
- if cfg.platform == "x32" then
- table.insert(addlOptions, "/MACHINE:X86")
- elseif cfg.platform == "x64" then
- table.insert(addlOptions, "/MACHINE:X64")
- end
- addlOptions = table.join(addlOptions, cfg.linkoptions)
- if #addlOptions > 0 then
+ local addlOptions = {}
+ if cfg.platform == "x32" then
+ table.insert(addlOptions, "/MACHINE:X86")
+ elseif cfg.platform == "x64" then
+ table.insert(addlOptions, "/MACHINE:X64")
+ end
+ addlOptions = table.join(addlOptions, cfg.linkoptions)
+ if #addlOptions > 0 then
_p(4,'AdditionalOptions="%s"', table.concat(premake.esc(addlOptions), " "))
end
end
diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index 90b2448..03d220a 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -155,7 +155,7 @@
if cfg.kind ~= "StaticLib" then
_p(2,'<LinkIncremental '..if_config_and_platform() ..'>%s</LinkIncremental>'
,premake.esc(cfginfo.name)
- ,tostring(premake.config.should_link_incrementally(cfg)))
+ ,tostring(premake.config.isincrementallink(cfg)))
end
end
diff --git a/src/base/configs.lua b/src/base/bake.lua
index f15f71f..a11c843 100644
--- a/src/base/configs.lua
+++ b/src/base/bake.lua
@@ -1,59 +1,16 @@
--
--- configs.lua
+-- base/bake.lua
--
--- Functions for working with configuration objects (which can include
--- projects and solutions).
+-- Takes all the configuration information provided by the project scripts
+-- and stored in the solution->project->block hierarchy and flattens it all
+-- down into one object per configuration. These objects are cached with the
+-- project, and can be retrieved by calling the getconfig() or eachconfig().
--
--- This script also contains the configuration "baking" logic (though I
--- would like to eventually move this out to a different file):
--- Once the project scripts have been run, flatten all of the configuration
--- data down into simpler objects, keeping only the settings that apply to
--- the current runtime environment.
---
--- Copyright (c) 2008-2010 Jason Perkins and the Premake project
---
-
- 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
--- (and might also be useful elsewhere).
---
--- @param cfg
--- The configuration object to test.
--- @returns
--- True if the configuration represents a debug build; false otherwise.
+-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
--
- function premake.config.isdebugbuild(cfg)
- -- If any of the optimize flags are set, it's a release a build
- if cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then
- return false
- end
- -- If symbols are not defined, it's a release build
- if not cfg.flags.Symbols then
- return false
- end
- return true
- end
-
-
--------------------------------------------------------------------------
--- Configuration Baking Logic
--------------------------------------------------------------------------
+ premake.bake = { }
+ local bake = premake.bake
-- do not copy these fields into the configurations
local nocopy =
@@ -668,7 +625,8 @@
end
end
end
-
+
+
--
-- Takes the configuration information stored in solution->project->block
-- hierarchy and flattens it all down into one object per configuration.
@@ -702,9 +660,9 @@
end
end
- --This loop finds the projects that a configuration is connected to
- --via its "uses" field. It will then copy any usage project information from that
- --usage project to the configuration in question.
+ -- This loop finds the projects that a configuration is connected to
+ -- via its "uses" field. It will then copy any usage project information from that
+ -- usage project to the configuration in question.
for sln in premake.solution.each() do
for prjIx, prj in ipairs(sln.projects) do
if(not prj.usage) then
diff --git a/src/base/config.lua b/src/base/config.lua
new file mode 100644
index 0000000..4be034a
--- /dev/null
+++ b/src/base/config.lua
@@ -0,0 +1,56 @@
+--
+-- configs.lua
+--
+-- Functions for working with configuration objects (which can include
+-- projects and solutions).
+--
+-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
+--
+
+ premake.config = { }
+ local config = premake.config
+
+
+--
+-- Determine if a configuration represents a "debug" or "release" build.
+-- This controls the runtime library selected for Visual Studio builds
+-- (and might also be useful elsewhere).
+--
+
+ function premake.config.isdebugbuild(cfg)
+ -- If any of the optimize flags are set, it's a release a build
+ if cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then
+ return false
+ end
+ -- If symbols are not defined, it's a release build
+ if not cfg.flags.Symbols then
+ return false
+ end
+ return true
+ end
+
+
+--
+-- Determines if this configuration can be linked incrementally.
+--
+
+ function premake.config.isincrementallink(cfg)
+ if cfg.kind == "StaticLib"
+ or config.isoptimizedbuild(cfg.flags)
+ or cfg.flags.NoIncrementalLink then
+ return false
+ end
+ return true
+ end
+
+
+--
+-- Determine if this configuration uses one of the optimize flags.
+-- Optimized builds get different treatment, such as full linking
+-- instead of incremental.
+--
+
+ function premake.config.isoptimizedbuild(flags)
+ return flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed
+ end
+
diff --git a/tests/base/test_config.lua b/tests/base/test_config.lua
index dd7434a..2723624 100644
--- a/tests/base/test_config.lua
+++ b/tests/base/test_config.lua
@@ -59,23 +59,23 @@
function suite.shouldIncrementallyLink_staticLib_returnsFalse()
kind "StaticLib"
prepare()
- return test.isfalse(premake.config.should_link_incrementally(cfg))
+ return test.isfalse(premake.config.isincrementallink(cfg))
end
function suite.shouldIncrementallyLink_optimizeFlagSet_returnsFalse()
flags { "Optimize" }
prepare()
- return test.isfalse(premake.config.should_link_incrementally(cfg))
+ return test.isfalse(premake.config.isincrementallink(cfg))
end
function suite.shouldIncrementallyLink_NoIncrementalLinkFlag_returnsFalse()
flags { "NoIncrementalLink" }
prepare()
- return test.isfalse(premake.config.should_link_incrementally(cfg))
+ return test.isfalse(premake.config.isincrementallink(cfg))
end
function suite.shouldIncrementallyLink_notStaticLib_NoIncrementalLinkFlag_noOptimiseFlag_returnsTrue()
prepare()
- return test.istrue(premake.config.should_link_incrementally(cfg))
+ return test.istrue(premake.config.isincrementallink(cfg))
end