Added staticruntime
API. (#163)
This commit is contained in:
parent
66362c08c0
commit
2de9966995
@ -538,13 +538,13 @@
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of the ReleaseRuntime flag; should override the
|
||||
-- Check handling of the runtime API; should override the
|
||||
-- default behavior of linking the debug runtime when symbols are
|
||||
-- enabled with no optimizations.
|
||||
--
|
||||
|
||||
function suite.releaseRuntime_onFlag()
|
||||
flags { "ReleaseRuntime" }
|
||||
runtime "Release"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -558,7 +558,8 @@
|
||||
end
|
||||
|
||||
function suite.releaseRuntime_onStaticAndReleaseRuntime()
|
||||
flags { "ReleaseRuntime", "StaticRuntime" }
|
||||
runtime "Release"
|
||||
staticruntime "On"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -402,11 +402,23 @@
|
||||
|
||||
|
||||
--
|
||||
-- If the StaticRuntime flag is specified, add the <RuntimeLibrary> element.
|
||||
-- If staticruntime is specified, add the <RuntimeLibrary> element.
|
||||
--
|
||||
|
||||
function suite.runtimeLibrary_onDynamicRuntime()
|
||||
staticruntime "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.runtimeLibrary_onStaticRuntime()
|
||||
flags { "StaticRuntime" }
|
||||
staticruntime "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
@ -417,8 +429,22 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.runtimeLibrary_onDynamicRuntimeAndSymbols()
|
||||
staticruntime "Off"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.runtimeLibrary_onStaticRuntimeAndSymbols()
|
||||
flags { "StaticRuntime" }
|
||||
staticruntime "On"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -770,13 +796,43 @@
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of the ReleaseRuntime flag; should override the
|
||||
-- Check handling of the `runtime` API; should override the
|
||||
-- default behavior of linking the debug runtime when symbols are
|
||||
-- enabled with no optimizations.
|
||||
--
|
||||
|
||||
function suite.releaseRuntime_onReleaseRuntime()
|
||||
runtime "Release"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.releaseRuntime_onDynamicAndReleaseRuntime()
|
||||
runtime "Release"
|
||||
staticruntime "Off"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.releaseRuntime_onStaticAndReleaseRuntime()
|
||||
flags { "ReleaseRuntime", "StaticRuntime" }
|
||||
runtime "Release"
|
||||
staticruntime "On"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -174,7 +174,8 @@
|
||||
end
|
||||
|
||||
function suite.useOfMfc_onStaticRuntime()
|
||||
flags { "MFC", "StaticRuntime" }
|
||||
flags { "MFC" }
|
||||
staticruntime "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@ -217,7 +218,7 @@
|
||||
--
|
||||
|
||||
function suite.releaseRuntime_onFlag()
|
||||
flags { "ReleaseRuntime" }
|
||||
runtime "Release"
|
||||
symbols "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1519,7 +1519,14 @@
|
||||
SharedRelease = 2,
|
||||
SharedDebug = 3,
|
||||
}
|
||||
p.w('RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
|
||||
local runtime = config.getruntime(cfg)
|
||||
if runtime then
|
||||
p.w('RuntimeLibrary="%s"', runtimes[runtime])
|
||||
else
|
||||
-- TODO: this path should probably be omitted and left for default
|
||||
-- ...but I can't really test this, so I'm a leave it how I found it
|
||||
p.w('RuntimeLibrary="%s"', iif(config.isDebugBuild(cfg), 3, 2))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1596,7 +1603,7 @@
|
||||
|
||||
function m.useOfMFC(cfg)
|
||||
if (cfg.flags.MFC) then
|
||||
p.w('UseOfMFC="%d"', iif(cfg.flags.StaticRuntime, 1, 2))
|
||||
p.w('UseOfMFC="%d"', iif(cfg.staticruntime == "On", 1, 2))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1256,7 +1256,7 @@
|
||||
|
||||
function m.basicRuntimeChecks(cfg, condition)
|
||||
local prjcfg, filecfg = p.config.normalize(cfg)
|
||||
local runtime = config.getruntime(prjcfg)
|
||||
local runtime = config.getruntime(prjcfg) or iif(config.isDebugBuild(cfg), "Debug", "Release")
|
||||
if filecfg then
|
||||
if filecfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(filecfg) and runtime:endswith("Debug")) then
|
||||
m.element("BasicRuntimeChecks", condition, "Default")
|
||||
@ -2217,12 +2217,12 @@
|
||||
local runtimes = {
|
||||
StaticDebug = "MultiThreadedDebug",
|
||||
StaticRelease = "MultiThreaded",
|
||||
StaticDLLDebug = "MultiThreadedDebugDLL",
|
||||
StaticDLLRelease = "MultiThreadedDLL"
|
||||
SharedDebug = "MultiThreadedDebugDLL",
|
||||
SharedRelease = "MultiThreadedDLL"
|
||||
}
|
||||
local runtime = runtimes[config.getruntime(cfg)]
|
||||
local runtime = config.getruntime(cfg)
|
||||
if runtime then
|
||||
m.element("RuntimeLibrary", nil, runtime)
|
||||
m.element("RuntimeLibrary", nil, runtimes[runtime])
|
||||
end
|
||||
end
|
||||
|
||||
@ -2366,14 +2366,14 @@
|
||||
|
||||
|
||||
function m.useDebugLibraries(cfg)
|
||||
local runtime = config.getruntime(cfg)
|
||||
local runtime = config.getruntime(cfg) or iif(config.isDebugBuild(cfg), "Debug", "Release")
|
||||
m.element("UseDebugLibraries", nil, tostring(runtime:endswith("Debug")))
|
||||
end
|
||||
|
||||
|
||||
function m.useOfMfc(cfg)
|
||||
if cfg.flags.MFC then
|
||||
m.element("UseOfMfc", nil, iif(cfg.flags.StaticRuntime, "Static", "Dynamic"))
|
||||
m.element("UseOfMfc", nil, iif(cfg.staticruntime == "On", "Static", "Dynamic"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -513,7 +513,7 @@
|
||||
"RelativeLinks",
|
||||
"ReleaseRuntime", -- DEPRECATED
|
||||
"ShadowedVariables",
|
||||
"StaticRuntime",
|
||||
"StaticRuntime", -- DEPRECATED
|
||||
"Symbols", -- DEPRECATED
|
||||
"UndefinedIdentifiers",
|
||||
"WinMain", -- DEPRECATED
|
||||
@ -1048,6 +1048,17 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "staticruntime",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"Default",
|
||||
"On",
|
||||
"Off"
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "strictaliasing",
|
||||
scope = "config",
|
||||
@ -1519,6 +1530,16 @@
|
||||
entrypoint "mainCRTStartup"
|
||||
end)
|
||||
|
||||
-- 31 October 2017
|
||||
|
||||
api.deprecateValue("flags", "StaticRuntime", 'Use `staticruntime "On"` instead',
|
||||
function(value)
|
||||
staticruntime "On"
|
||||
end,
|
||||
function(value)
|
||||
staticruntime "Default"
|
||||
end)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
--
|
||||
-- Install Premake's default set of command line arguments.
|
||||
|
@ -326,11 +326,12 @@
|
||||
--
|
||||
|
||||
function config.getruntime(cfg)
|
||||
local linkage = iif(cfg.flags.StaticRuntime, "Static", "Shared")
|
||||
|
||||
if cfg.clr == "On" and cfg.flags.StaticRuntime then
|
||||
linkage = linkage .. "DLL"
|
||||
if (not cfg.staticruntime or cfg.staticruntime == "Default") and not cfg.runtime then
|
||||
return nil -- indicate that no runtime was explicitly selected
|
||||
end
|
||||
|
||||
local linkage = iif(cfg.staticruntime == "On", "Static", "Shared") -- assume 'Shared' is default?
|
||||
|
||||
if not cfg.runtime then
|
||||
return linkage .. iif(config.isDebugBuild(cfg), "Debug", "Release")
|
||||
else
|
||||
|
@ -40,9 +40,7 @@
|
||||
MultiProcessorCompile = "/MP",
|
||||
NoFramePointer = "/Oy",
|
||||
NoMinimalRebuild = "/Gm-",
|
||||
OmitDefaultLibrary = "/Zl",
|
||||
StaticRuntime = function(cfg) return iif(config.isDebugBuild(cfg), "/MTd", "/MT") end,
|
||||
_StaticRuntime = function(cfg) return iif(config.isDebugBuild(cfg), "/MDd", "/MD") end
|
||||
OmitDefaultLibrary = "/Zl"
|
||||
},
|
||||
floatingpoint = {
|
||||
Fast = "/fp:fast",
|
||||
@ -87,6 +85,14 @@
|
||||
High = "/W4",
|
||||
Off = "/W0",
|
||||
},
|
||||
staticruntime = {
|
||||
-- this option must always be emit (does it??)
|
||||
_ = function(cfg) return iif(config.isDebugBuild(cfg), "/MDd", "/MD") end,
|
||||
-- runtime defaults to dynamic in VS
|
||||
Default = function(cfg) return iif(config.isDebugBuild(cfg), "/MDd", "/MD") end,
|
||||
On = function(cfg) return iif(config.isDebugBuild(cfg), "/MTd", "/MT") end,
|
||||
Off = function(cfg) return iif(config.isDebugBuild(cfg), "/MDd", "/MD") end,
|
||||
},
|
||||
stringpooling = {
|
||||
On = "/GF",
|
||||
Off = "/GF-",
|
||||
|
Loading…
Reference in New Issue
Block a user