Add distinct FatalCompileWarnings and FatalLinkWarnings flags

This commit is contained in:
Jason Perkins 2014-02-14 12:23:12 -05:00
parent 407861bc80
commit fc79f5d9dc
8 changed files with 68 additions and 35 deletions

View File

@ -239,7 +239,8 @@
"EnableSSE2", -- DEPRECATED
"ExcludeFromBuild",
"ExtraWarnings", -- DEPRECATED
"FatalWarnings",
"FatalCompileWarnings",
"FatalLinkWarnings",
"FloatFast", -- DEPRECATED
"FloatStrict", -- DEPRECATED
"LinkTimeOptimization",
@ -277,6 +278,7 @@
"WPF",
},
aliases = {
FatalWarnings = { "FatalCompileWarnings", "FatalLinkWarnings" },
Optimise = 'Optimize',
OptimiseSize = 'OptimizeSize',
OptimiseSpeed = 'OptimizeSpeed',
@ -782,6 +784,15 @@
optimize "Off"
end)
api.deprecateValue("flags", { "Optimise", "OptimiseSize", "OptimiseSpeed" }, DOC_URL .. "optimize",
function(value)
local map = { Optimise = "On", OptimiseSize = "Size", OptimiseSpeed = "Speed" }
optimize (map[value] or "Off")
end,
function(value)
optimize "Off"
end)
api.deprecateValue("flags", { "ExtraWarnings", "NoWarnings" }, DOC_URL .. "warnings",
function(value)
local map = { ExtraWarnings = "Extra", NoWarnings = "Off" }

View File

@ -226,7 +226,7 @@
_p(2,'<AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end
if cfg.flags.FatalWarnings then
if cfg.flags.FatalCompileWarnings then
_p(2,'<TreatWarningsAsErrors>true</TreatWarningsAsErrors>')
end
end

View File

@ -1564,7 +1564,7 @@
p.w('WarningLevel="0"')
else
p.w('WarningLevel="%d"', iif(cfg.warnings == "Extra", 4, 3))
if cfg.flags.FatalWarnings then
if cfg.flags.FatalCompileWarnings then
p.w('WarnAsError="%s"', m.bool(true))
end
if _ACTION < "vs2008" and not cfg.flags.Managed then

View File

@ -1206,7 +1206,7 @@
function vc2010.treatLinkerWarningAsErrors(cfg)
if cfg.flags.FatalWarnings then
if cfg.flags.FatalLinkWarnings then
local el = iif(cfg.kind == premake.STATICLIB, "Lib", "Linker")
_p(3,'<Treat%sWarningAsErrors>true</Treat%sWarningAsErrors>', el, el)
end
@ -1223,7 +1223,7 @@
function vc2010.treatWarningAsError(cfg)
if cfg.flags.FatalWarnings and cfg.warnings ~= "Off" then
if cfg.flags.FatalLinkWarnings and cfg.warnings ~= "Off" then
_p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
end
end

View File

@ -317,30 +317,37 @@
table.foreachi(value, function(v)
recurse(v)
end)
else
if field.deprecated then
if value:contains("*") then
local current = target.configset[field.name]
local mask = path.wildcards(value)
for _, item in ipairs(current) do
if item:match(mask) == item then
check(item)
end
end
else
value, err = api.checkvalue(value, field)
if err then error(err, 4) end
check(value)
return
end
if value:contains("*") then
local current = target.configset[field.name]
local mask = path.wildcards(value)
for _, item in ipairs(current) do
if item:match(mask) == item then
recurse(item)
end
end
remover(removes, value)
return
end
local value, err, additional = api.checkvalue(value, field)
if err then error(err, 4) end
if field.deprecated then
check(value)
end
remover(removes, value)
if additional then
remover(removes, additional)
end
end
recurse(value)
-- Tell the config set to remove these values from future queries
configset.removevalues(target.configset, field.name, removes)
end
@ -354,17 +361,24 @@
-- @param field
-- The field to check against.
-- @return
-- If the value is valid for this field, the canonical version
-- of that value is returned. If the value is not valid two
-- values are returned: nil, and an error message.
-- Returns up to three values: the canonical match for the input value
-- or nil if there is no match. An error message if the input value is
-- invalid. And one (string) or more (array) additional values that are
-- associated with the input value (e.g. FatalWarnings expands to also
-- set FatalCompileWarnings and FatalLinkWarnings).
--
-- That's a wonky return value; grew that way out of historical usage.
--
function api.checkvalue(value, field)
local lowerValue = value:lower()
if field.aliases then
for k,v in pairs(field.aliases) do
if value:lower() == k:lower() then
value = v
break
-- if I find a matching alias, assume that it has already been
-- set to the right canonical value, and just return
if lowerValue == k:lower() then
return k, nil, v
end
end
end
@ -376,15 +390,15 @@
local n = #field.allowed
for i = 1, n do
local v = field.allowed[i]
if value:lower() == v:lower() then
if lowerValue == v:lower() then
return v
end
end
return nil, "invalid value '" .. value .. "'"
end
else
return value
end
return value
end
@ -647,7 +661,7 @@
error({ msg="expected string; got table" })
end
local value, err = api.checkvalue(value, field)
local value, err, additional = api.checkvalue(value, field)
if err then error({ msg=err }) end
if field.deprecated and field.deprecated[value] then
@ -665,6 +679,14 @@
-- of object (i.e. an array or list)
target = target.configset or target
target[name] = value
-- Odd case: the FatalWarnings flag expands to multiple values now
-- (FatalCompileWarnings, FatalLinkWarnings). Generalize this
-- behavior by running multiple return values back through again.
if additional then
api.callback(field, additional)
end
end

View File

@ -38,7 +38,7 @@
x64 = "-m64",
},
flags = {
FatalWarnings = "-Werror",
FatalCompileWarnings = "-Werror",
NoFramePointer = "-fomit-frame-pointer",
Symbols = "-g"
},

View File

@ -26,7 +26,7 @@
msc.cflags = {
flags = {
FatalWarnings = "/WX",
FatalCompileWarnings = "/WX",
MultiProcessorCompile = "/MP",
NoFramePointer = "/Oy",
NoMinimalRebuild = "/Gm-",
@ -146,7 +146,7 @@
msc.linkerFlags = {
flags = {
FatalWarnings = "/WX",
FatalLinkWarnings = "/WX",
LinkTimeOptimization = "/GL",
NoIncrementalLink = "/INCREMENTAL:NO",
NoManifest = "/MANIFEST:NO",
@ -160,7 +160,7 @@
msc.librarianFlags = {
flags = {
FatalWarnings = "/WX",
FatalLinkWarnings = "/WX",
}
}

View File

@ -16,7 +16,7 @@
snc.cflags = {
flags = {
FatalWarnings = "-Xquit=2",
FatalCompileWarnings = "-Xquit=2",
},
optimize = {
Off = "-O0",