From 2cbab565923ac55b936df56042fbe3b7945dcb97 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Mon, 16 Apr 2012 18:24:35 -0400 Subject: [PATCH] A bit of consistency cleanup on the prior pull request --- CHANGES.txt | 1 + src/actions/vstudio/vs200x_vcproj.lua | 47 ++++++++++++---------- src/actions/vstudio/vs2010_vcxproj.lua | 54 ++++++++++++++------------ 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index cc130401..9b9282c6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ * The include() function will now include each file only once * The include() function can now include specific files * path.translate() now defaults to Windows-style backslashes +* Added NoWarnings flag for Visual Studio (xpol) ------- diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 35b5f47b..8fecde1c 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -179,24 +179,6 @@ end - local function warningsblocks(cfg) - -- if NoWarnings flags specified just disable warnings, and return. - if cfg.flags.NoWarnings then - _p(4,'WarningLevel="0"') - return - end - - -- else setup all warning blocks as needed. - _p(4,'WarningLevel="%d"', iif(cfg.flags.ExtraWarnings, 4, 3)) - - if cfg.flags.FatalWarnings then - _p(4,'WarnAsError="%s"', bool(true)) - end - - if _ACTION < "vs2008" and not cfg.flags.Managed then - _p(4,'Detect64BitPortabilityProblems="%s"', bool(not cfg.flags.No64BitChecks)) - end - end -- -- Write out the VCCLCompilerTool element. -- @@ -304,7 +286,7 @@ _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2)) end - warningsblocks(cfg) + vc200x.warnings(cfg) _x(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', config.gettargetinfo(cfg).basename) @@ -957,6 +939,31 @@ end +-- +-- Convert Premake warning flags to Visual Studio equivalents. +-- + + function vc200x.warnings(cfg) + -- if NoWarnings flags specified just disable warnings, and return. + if cfg.flags.NoWarnings then + _p(4,'WarningLevel="0"') + return + end + + -- else setup all warning blocks as needed. + _p(4,'WarningLevel="%d"', iif(cfg.flags.ExtraWarnings, 4, 3)) + + if cfg.flags.FatalWarnings then + _p(4,'WarnAsError="%s"', bool(true)) + end + + if _ACTION < "vs2008" and not cfg.flags.Managed then + _p(4,'Detect64BitPortabilityProblems="%s"', bool(not cfg.flags.No64BitChecks)) + end + end + + + ----------------------------------------------------------------------------- -- Everything below this point is a candidate for deprecation @@ -1212,7 +1219,7 @@ _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2)) end - warningsblocks(cfg) + vc200x.warnings(cfg) _p(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', path.getbasename(cfg.buildtarget.name)) _p(4,'DebugInformationFormat="%s"', vc200x.symbols(cfg)) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index a12b246a..55079df1 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -188,29 +188,6 @@ end - function vc2010.warningBlocks(cfg) - local warnLevel = 3 -- default to normal warning level if there is not any warnings flags specified - if cfg.flags.NoWarnings then - warnLevel = 0 - elseif cfg.flags.ExtraWarnings then - warnLevel = 4 - end - _p(3,'Level%d', warnLevel) - - -- Ohter warning blocks only when NoWarnings are not specified - if cfg.flags.NoWarnings then - return - end - - if premake.config.isdebugbuild(cfg) and cfg.flags.ExtraWarnings then - _p(3,'true') - end - - if cfg.flags.FatalWarnings then - _p(3,'true') - end - end - -- -- Write the the compiler settings block. -- @@ -225,7 +202,7 @@ _p(3,'NotUsing') end - vc2010.warningBlocks(cfg) + vc2010.warnings(cfg) vc2010.preprocessorDefinitions(cfg.defines) vc2010.additionalIncludeDirectories(cfg, cfg.includedirs) vc2010.debuginfo(cfg) @@ -664,6 +641,33 @@ end +-- +-- Convert Premake warning flags to Visual Studio equivalents. +-- + + function vc2010.warnings(cfg) + local warnLevel = 3 -- default to normal warning level if there is not any warnings flags specified + if cfg.flags.NoWarnings then + warnLevel = 0 + elseif cfg.flags.ExtraWarnings then + warnLevel = 4 + end + _p(3,'Level%d', warnLevel) + + -- Ohter warning blocks only when NoWarnings are not specified + if cfg.flags.NoWarnings then + return + end + + if premake.config.isdebugbuild(cfg) and cfg.flags.ExtraWarnings then + _p(3,'true') + end + + if cfg.flags.FatalWarnings then + _p(3,'true') + end + end + ----------------------------------------------------------------------------- -- Everything below this point is a candidate for deprecation @@ -932,7 +936,7 @@ _p(3,'true') precompiled_header(cfg) - vc2010.warningBlocks(cfg) + vc2010.warnings(cfg) exceptions(cfg) rtti(cfg) wchar_t_buildin(cfg)