Commits

Jason Perkins committed 5f939ad

Added NoRuntimeChecks flag to disable Visual Studio default checks

Comments (0)

Files changed (6)

 * Visual Studio C# projects now support architectures
 * Visual Studio C# projects now support pre- and post-build commands
 * Added NoImplicitLink flag to force explicit linking from Visual Studio
+* Decoupled VS2010 smaller type checks (/RTCc) from extra warnings (/W4)
+* Added NoRuntimeChecks flag to disable Visual Studio default checks
 
 
 -------

src/actions/vstudio/vs200x_vcproj.lua

 			_p(4,'MinimalRebuild="%s"', bool(true))
 		end
 		
-		if vc200x.optimization(cfg) == 0 and not cfg.flags.Managed then
-			_p(4,'BasicRuntimeChecks="3"')
-		end
+		vc200x.BasicRuntimeChecks(cfg)
 
 		if vc200x.optimization(cfg) ~= 0 then
 			_p(4,'StringPooling="%s"', bool(true))
 	end
 
 
+	function vc200x.BasicRuntimeChecks(cfg)
+		if not premake.config.isoptimizedbuild(cfg) 
+			and not cfg.flags.Managed 
+			and not cfg.flags.NoRuntimeChecks
+		then
+			_p(4,'BasicRuntimeChecks="3"')
+		end
+	end
+	
+
 --
 -- Write out the VCLinkerTool element.
 --

src/actions/vstudio/vs2010_vcxproj.lua

 
 		for cfg in project.eachconfig(prj) do
 			_p(1,'<ItemDefinitionGroup %s>', vc2010.condition(cfg))
-			vc2010.clCompile(cfg)
+			vc2010.ClCompile(cfg)
 			vc2010.resourceCompile(cfg)
 			vc2010.Link(cfg)
 			vc2010.buildEvents(cfg)
 -- Write the the <ClCompile> compiler settings block.
 --
 
-	function vc2010.clCompile(cfg)
+	function vc2010.ClCompile(cfg)
 		_p(2,'<ClCompile>')
 
 		if not cfg.flags.NoPCH and cfg.pchheader then
 			_p(3,'<PrecompiledHeader>NotUsing</PrecompiledHeader>')
 		end
 
-        vc2010.warnings(cfg)
+		vc2010.WarningLevel(cfg)
+		vc2010.TreatWarningAsError(cfg)
+        vc2010.BasicRuntimeChecks(cfg)
+
 		vc2010.preprocessorDefinitions(cfg.defines)
 		vc2010.additionalIncludeDirectories(cfg, cfg.includedirs)
 
 
 
 --
--- Convert Premake warning flags to Visual Studio equivalents.
+-- Handlers for individual project elements.
 --
 
-	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,'<WarningLevel>Level%d</WarningLevel>', warnLevel)
-
-		-- Ohter warning blocks only when NoWarnings are not specified
-		if cfg.flags.NoWarnings then
-			return
-		end
-
-		if cfg.flags.FatalWarnings then
-			_p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
+	function vc2010.BasicRuntimeChecks(cfg)
+		if cfg.flags.NoRuntimeChecks then
+			_p(3,'<BasicRuntimeChecks>Default</BasicRuntimeChecks>')
 		end
 	end
+
+
+	function vc2010.TreatWarningAsError(cfg)
+		if cfg.flags.FatalWarnings and not cfg.flags.NoWarnings then
+			_p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
+		end		
+	end
+
+
+	function vc2010.WarningLevel(cfg)
+		local w = 3
+		if cfg.flags.NoWarnings then
+			w = 0
+		elseif cfg.flags.ExtraWarnings then
+			w = 4
+		end
+		_p(3,'<WarningLevel>Level%d</WarningLevel>', w)
+	end
 			"NoMinimalRebuild",
 			"NoNativeWChar",
 			"NoPCH",
+			"NoRuntimeChecks",
 			"NoRTTI",
 			"NoWarnings",
 			"Optimize",

tests/actions/vstudio/vc200x/test_compiler_block.lua

 				ForcedIncludeFiles="stdafx.h;include/sys.h"
 		]]
 	end
+
+
+--
+-- Verify handling of the NoRuntimeChecks flag.
+--
+
+	function suite.onNoRuntimeChecks()
+		flags { "NoRuntimeChecks" }
+		prepare()
+		test.capture [[
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				RuntimeLibrary="2"
+		]]
+	end
+		

tests/actions/vstudio/vc2010/test_compile_settings.lua

 
 	local function prepare(platform)
 		cfg = project.getconfig(prj, "Debug", platform)
-		vc2010.clCompile(cfg)
+		vc2010.ClCompile(cfg)
 	end
 
 
- --
+--
 -- Check the basic element structure with default settings.
 --
 
 			<ForcedIncludeFiles>stdafx.h;include/sys.h</ForcedIncludeFiles>
 		]]
 	end
+
+
+--
+-- Check handling of the NoRuntimeChecks flag.
+--
+
+	function suite.onNoRuntimeChecks()
+		flags { "NoRuntimeChecks" }
+		prepare()
+		test.capture [[
+		<ClCompile>
+			<PrecompiledHeader>NotUsing</PrecompiledHeader>
+			<WarningLevel>Level3</WarningLevel>
+			<BasicRuntimeChecks>Default</BasicRuntimeChecks>
+		]]
+	end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.