Added ReleaseRuntime build flag (Tarmo Pikaro)

This commit is contained in:
Jason Perkins 2013-03-27 11:12:37 -04:00
parent 09b0dd1182
commit 214ac7097f
10 changed files with 126 additions and 22 deletions

View File

@ -37,6 +37,7 @@
* Improved Xbox 360 support
* Added support for Clang C/C++ compiler
* Added external files and virtual paths for C# projects (James Whitworth)
* Added ReleaseRuntime build flag (Tarmo Pikaro)
-------

View File

@ -359,13 +359,7 @@
_p(4,'ExceptionHandling="2"')
end
local runtime
if premake.config.isdebugbuild(cfg) then
runtime = iif(cfg.flags.StaticRuntime, 1, 3)
else
runtime = iif(cfg.flags.StaticRuntime, 0, 2)
end
_p(4,'RuntimeLibrary="%s"', runtime)
vc200x.runtimeLibrary(cfg)
_p(4,'EnableFunctionLevelLinking="%s"', vc200x.bool(true))
@ -988,6 +982,17 @@
end
function vc200x.runtimeLibrary(cfg)
local runtimes = {
StaticRelease = 0,
StaticDebug = 1,
SharedRelease = 2,
SharedDebug = 3,
}
_p(4,'RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
end
function vc200x.tool(name)
_p(3,'<Tool')
_p(4,'Name="%s"', name)

View File

@ -887,8 +887,13 @@
function vc2010.runtimeLibrary(cfg)
if cfg.flags.StaticRuntime then
_p(3,'<RuntimeLibrary>%s</RuntimeLibrary>', iif(premake.config.isdebugbuild(cfg), "MultiThreadedDebug", "MultiThreaded"))
local runtimes = {
StaticDebug = "MultiThreadedDebug",
StaticRelease = "MultiThreaded",
}
local runtime = runtimes[config.getruntime(cfg)]
if runtime then
_p(3,'<RuntimeLibrary>%s</RuntimeLibrary>', runtime)
end
end
@ -942,7 +947,8 @@
function vc2010.useDebugLibraries(cfg)
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', tostring(premake.config.isdebugbuild(cfg)))
local runtime = config.getruntime(cfg)
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', tostring(runtime:endswith("Debug")))
end

View File

@ -652,6 +652,7 @@
"Optimize",
"OptimizeSize",
"OptimizeSpeed",
"ReleaseRuntime",
"SEH",
"StaticRuntime",
"Symbols",

View File

@ -4,10 +4,10 @@
-- Functions for working with configuration objects (which can include
-- projects and solutions).
--
-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
--
premake.config = { }
premake.config = {}
local config = premake.config
@ -18,7 +18,7 @@
--
function premake.config.isdebugbuild(cfg)
-- If any of the optimize flags are set, it's a release a build
-- If any of the optimize flags are set, it's a release build
if cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then
return false
end

View File

@ -423,6 +423,23 @@
end
--
-- Determines the correct runtime library for a configuration.
--
-- @param cfg
-- The configuration object to query.
-- @return
-- A string identifying the runtime library, one of
-- StaticDebug, StaticRelease, SharedDebug, SharedRelease.
--
function config.getruntime(cfg)
local linkage = iif(cfg.flags.StaticRuntime, "Static", "Shared")
local mode = iif(premake.config.isdebugbuild(cfg) and not cfg.flags.ReleaseRuntime, "Debug", "Release")
return linkage .. mode
end
--
-- Retrieve information about a configuration's build target.
--

View File

@ -458,7 +458,7 @@
ProgramDataBaseFileName="$(OutDir)\MyProject.pdb"
WarningLevel="3"
DebugInformationFormat="0"
ForcedIncludeFiles="stdafx.h;include/sys.h"
ForcedIncludeFiles="stdafx.h;include\sys.h"
]]
end
@ -476,7 +476,7 @@
ProgramDataBaseFileName="$(OutDir)\MyProject.pdb"
WarningLevel="3"
DebugInformationFormat="0"
ForcedUsingFiles="stdafx.h;include/sys.h"
ForcedUsingFiles="stdafx.h;include\sys.h"
]]
end
@ -513,3 +513,36 @@
BasicRuntimeChecks="3"
]]
end
--
-- Check handling of the ReleaseRuntime flag; should override the
-- default behavior of linking the debug runtime when symbols are
-- enabled with no optimizations.
--
function suite.releaseRuntime_onFlag()
flags { "Symbols", "ReleaseRuntime" }
prepare()
test.capture [[
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="2"
]]
end
function suite.releaseRuntime_onStaticAndReleaseRuntime()
flags { "Symbols", "ReleaseRuntime", "StaticRuntime" }
prepare()
test.capture [[
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="0"
]]
end

View File

@ -599,3 +599,26 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
]]
end
--
-- Check handling of the ReleaseRuntime flag; should override the
-- default behavior of linking the debug runtime when symbols are
-- enabled with no optimizations.
--
function suite.releaseRuntime_onStaticAndReleaseRuntime()
flags { "Symbols", "ReleaseRuntime", "StaticRuntime" }
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<ProgramDataBaseFileName>$(OutDir)MyProject.pdb</ProgramDataBaseFileName>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
]]
end

View File

@ -152,3 +152,20 @@
]]
end
--
-- Check handling of the ReleaseRuntime flag; should override the
-- default behavior of linking the debug runtime when symbols are
-- enabled with no optimizations.
--
function suite.releaseRuntime_onFlag()
flags { "Symbols", "ReleaseRuntime" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
]]
end

View File

@ -115,6 +115,7 @@
-- Visual Studio 2002-2008 C/C++ projects
dofile("actions/vstudio/vc200x/test_assembly_refs.lua")
dofile("actions/vstudio/vc200x/test_configuration.lua")
dofile("actions/vstudio/vc200x/test_compiler_block.lua")
dofile("actions/vstudio/vc200x/test_debug_settings.lua")
dofile("actions/vstudio/vc200x/test_excluded_configs.lua")
dofile("actions/vstudio/vc200x/test_external_compiler.lua")