Added api's for control of specific warnings.
Support VS200x, 201x, gmake
This commit is contained in:
parent
025c434590
commit
b965c5a665
@ -808,6 +808,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "enablewarnings",
|
||||
scope = "config",
|
||||
kind = "list:string",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "disablewarnings",
|
||||
scope = "config",
|
||||
kind = "list:string",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "fatalwarnings",
|
||||
scope = "config",
|
||||
kind = "list:string",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -478,6 +478,7 @@
|
||||
m.detect64BitPortabilityProblems,
|
||||
m.debugInformationFormat,
|
||||
m.compileAs,
|
||||
m.disableSpecificWarnings,
|
||||
m.forcedIncludeFiles,
|
||||
m.omitDefaultLib,
|
||||
}
|
||||
@ -1001,6 +1002,14 @@
|
||||
|
||||
|
||||
|
||||
function m.disableSpecificWarnings(cfg)
|
||||
if #cfg.disablewarnings > 0 or vstudio.isMakefile(cfg) then
|
||||
p.x('DisableSpecificWarnings="%s"', table.concat(cfg.disablewarnings, ";"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function m.compileAsManaged(cfg)
|
||||
p.w('CompileAsManaged=""')
|
||||
end
|
||||
|
@ -291,6 +291,8 @@
|
||||
m.precompiledHeader,
|
||||
m.warningLevel,
|
||||
m.treatWarningAsError,
|
||||
m.disableSpecificWarnings,
|
||||
m.treatSpecificWarningsAsErrors,
|
||||
m.basicRuntimeChecks,
|
||||
m.clCompilePreprocessorDefinitions,
|
||||
m.clCompileAdditionalIncludeDirectories,
|
||||
@ -610,6 +612,8 @@
|
||||
m.precompiledHeader(cfg, fcfg, condition)
|
||||
m.enableEnhancedInstructionSet(fcfg, condition)
|
||||
m.additionalCompileOptions(fcfg, condition)
|
||||
m.disableSpecificWarnings(fcfg, condition)
|
||||
m.treatSpecificWarningsAsErrors(fcfg, condition)
|
||||
end
|
||||
end
|
||||
p.pop()
|
||||
@ -1595,6 +1599,24 @@
|
||||
end
|
||||
|
||||
|
||||
function m.disableSpecificWarnings(cfg, condition)
|
||||
if #cfg.disablewarnings > 0 then
|
||||
local warnings = table.concat(cfg.disablewarnings, ";")
|
||||
warnings = premake.esc(warnings) .. ";%%(DisableSpecificWarnings)"
|
||||
m.element('DisableSpecificWarnings', condition, warnings)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.treatSpecificWarningsAsErrors(cfg, condition)
|
||||
if #cfg.fatalwarnings > 0 then
|
||||
local fatal = table.concat(cfg.fatalwarnings, ";")
|
||||
fatal = premake.esc(fatal) .. ";%%(TreatSpecificWarningsAsErrors)"
|
||||
m.element('TreatSpecificWarningsAsErrors', condition, fatal)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.useDebugLibraries(cfg)
|
||||
local runtime = config.getruntime(cfg)
|
||||
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', tostring(runtime:endswith("Debug")))
|
||||
|
@ -80,9 +80,24 @@
|
||||
|
||||
function gcc.getcflags(cfg)
|
||||
local flags = config.mapFlags(cfg, gcc.cflags)
|
||||
flags = table.join(flags, gcc.getwarnings(cfg))
|
||||
return flags
|
||||
end
|
||||
|
||||
function gcc.getwarnings(cfg)
|
||||
local result = {}
|
||||
for _, enable in ipairs(cfg.enablewarnings) do
|
||||
table.insert(result, '-W' .. enable)
|
||||
end
|
||||
for _, disable in ipairs(cfg.disablewarnings) do
|
||||
table.insert(result, '-Wno-' .. disable)
|
||||
end
|
||||
for _, fatal in ipairs(cfg.fatalwarnings) do
|
||||
table.insert(result, '-Werror=' .. fatal)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns list of C++ compiler flags for a configuration.
|
||||
|
@ -66,6 +66,8 @@
|
||||
function msc.getcflags(cfg)
|
||||
local flags = config.mapFlags(cfg, msc.cflags)
|
||||
|
||||
flags = table.join(flags, msc.getwarnings(cfg))
|
||||
|
||||
local runtime = iif(cfg.flags.StaticRuntime, "/MT", "/MD")
|
||||
if config.isDebugBuild(cfg) then
|
||||
runtime = runtime .. "d"
|
||||
@ -75,6 +77,18 @@
|
||||
return flags
|
||||
end
|
||||
|
||||
function msc.getwarnings(cfg)
|
||||
local result = {}
|
||||
-- NOTE: VStudio can't enable specific warnings (workaround?)
|
||||
for _, disable in ipairs(cfg.disablewarnings) do
|
||||
table.insert(result, '/wd"' .. disable .. '"')
|
||||
end
|
||||
for _, fatal in ipairs(cfg.fatalwarnings) do
|
||||
table.insert(result, '/we"' .. fatal .. '"')
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns list of C++ compiler flags for a configuration.
|
||||
|
Loading…
Reference in New Issue
Block a user