Commits

Jason Perkins committed 60dbc2d

Added MultiProcessorCompile flag to enable multiple compiler processes in Visual Studio

Comments (0)

Files changed (6)

 * Added support for Visual Studio solution groups
 * Added dependson() to specify non-linking dependencies (Alexey Orlov)
 * Added startproject() to specify solution startup project
+* Added ExcludeFromBuild flag to mark source files as non-buildable
+* Added MultiProcessorCompile flag to run multiple compiler processes
 
 
 -------

src/actions/vstudio/vs200x_vcproj.lua

 	end
 
 	function vc200x.VCCLBuiltInCompilerTool(cfg)
-		if #cfg.buildoptions > 0 then
-			_x(4,'AdditionalOptions="%s"', table.concat(cfg.buildoptions, " "))
-		end
+		vc200x.VCCL_AdditionalOptions(cfg)
 
 		_p(4,'Optimization="%s"', vc200x.optimization(cfg))
 
 		vc200x.additionalIncludeDirectories(cfg, cfg.includedirs)
 		vc200x.preprocessorDefinitions(cfg, cfg.defines)
 
-		if premake.config.isdebugbuild(cfg) and
-		   cfg.debugformat ~= "c7" and
-		   not cfg.flags.NoMinimalRebuild and
-		   not cfg.flags.Managed
-		then
-			_p(4,'MinimalRebuild="%s"', bool(true))
-		end
-
-		vc200x.BasicRuntimeChecks(cfg)
+		vc200x.VCCL_MinimalRebuild(cfg)
+		vc200x.VCCL_BasicRuntimeChecks(cfg)
 
 		if vc200x.optimization(cfg) ~= 0 then
 			_p(4,'StringPooling="%s"', bool(true))
 	end
 
 
-	function vc200x.BasicRuntimeChecks(cfg)
+	function vc200x.VCCL_BasicRuntimeChecks(cfg)
 		if not premake.config.isoptimizedbuild(cfg)
 			and not cfg.flags.Managed
 			and not cfg.flags.NoRuntimeChecks
 	end
 
 
+	function vc200x.VCCL_AdditionalOptions(cfg)
+		local opts = cfg.buildoptions
+		if cfg.flags.MultiProcessorCompile then
+			table.insert(opts, "/MP")
+		end
+		if #opts > 0 then
+			_x(4,'AdditionalOptions="%s"', table.concat(cfg.buildoptions, " "))
+		end
+	end
+
+
+	function vc200x.VCCL_MinimalRebuild(cfg)
+		if premake.config.isdebugbuild(cfg) and
+		   cfg.debugformat ~= "c7" and
+		   not cfg.flags.NoMinimalRebuild and
+		   not cfg.flags.Managed and
+		   not cfg.flags.MultiProcessorCompile
+		then
+			_p(4,'MinimalRebuild="%s"', bool(true))
+		end
+	end
+
+
 --
 -- Write out the VCLinkerTool element.
 --

src/actions/vstudio/vs2010_vcxproj.lua

 			_p(3,'<IntrinsicFunctions>true</IntrinsicFunctions>')
 		end
 
-		local minimalRebuild = not premake.config.isoptimizedbuild(cfg) and
-		                       not cfg.flags.NoMinimalRebuild and
-							   cfg.debugformat ~= premake.C7
-		if not minimalRebuild then
-			_p(3,'<MinimalRebuild>false</MinimalRebuild>')
-		end
+		vc2010.MinimalRebuild(cfg)
 
 		if cfg.flags.NoFramePointer then
 			_p(3,'<OmitFramePointers>true</OmitFramePointers>')
 			_p(3,'<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>')
 		end
 
+		vc2010.MultiProcessorCompilation(cfg)
+
 		if #cfg.buildoptions > 0 then
 			local options = table.concat(cfg.buildoptions, " ")
 			_x(3,'<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>', options)
 	end
 
 
+	function vc2010.MinimalRebuild(cfg)
+		if premake.config.isoptimizedbuild(cfg) or
+		   cfg.flags.NoMinimalRebuild or
+		   cfg.flags.MultiProcessorCompile or
+		   cfg.debugformat == premake.C7
+		then
+			_p(3,'<MinimalRebuild>false</MinimalRebuild>')
+		end
+	end
+
+
+	function vc2010.MultiProcessorCompilation(cfg)
+		if cfg.flags.MultiProcessorCompile then
+			_p(3,'<MultiProcessorCompilation>true</MultiProcessorCompilation>')
+		end
+	end
+
+
 	function vc2010.TreatWarningAsError(cfg)
 		if cfg.flags.FatalWarnings and not cfg.flags.NoWarnings then
 			_p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
 			"FloatStrict",
 			"Managed",
 			"MFC",
+			"MultiProcessorCompile",
 			"NativeWChar",
 			"No64BitChecks",
 			"NoEditAndContinue",

tests/actions/vstudio/vc200x/test_compiler_block.lua

 --
 -- tests/actions/vstudio/vc200x/test_compiler_block.lua
 -- Validate generation the VCCLCompiler element in Visual Studio 200x C/C++ projects.
--- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
 --
 
-	T.vs200x_compiler_block = { }
-	local suite = T.vs200x_compiler_block
+	local suite = test.declare("vs200x_compiler_block")
 	local vc200x = premake.vstudio.vc200x
 
 
 				RuntimeLibrary="2"
 		]]
 	end
-		
+
+
+
+--
+-- Check handling of the EnableMultiProcessorCompile flag.
+--
+
+	function suite.onMultiProcessorCompile()
+		flags { "MultiProcessorCompile" }
+		prepare()
+		test.capture [[
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/MP"
+				Optimization="0"
+				BasicRuntimeChecks="3"
+		]]
+	end

tests/actions/vstudio/vc2010/test_compile_settings.lua

 --
 -- tests/actions/vstudio/vc2010/test_compile_settings.lua
 -- Validate compiler settings in Visual Studio 2010 C/C++ projects.
--- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
 --
 
-	T.vstudio_vs2010_compile_settings = { }
-	local suite = T.vstudio_vs2010_compile_settings
+	local suite = test.declare("vstudio_vs2010_compile_settings")
 	local vc2010 = premake.vstudio.vc2010
 	local project = premake5.project
 
 		]]
 	end
 
-	
+
 --
 -- If build options are specified, the <AdditionalOptions> element should be specified.
 --
 		]]
 	end
 
-	
+
 --
 -- Edit-and-Continue is not support on 64-bit builds.
 --
 			<BasicRuntimeChecks>Default</BasicRuntimeChecks>
 		]]
 	end
+
+
+--
+-- Check handling of the EnableMultiProcessorCompile flag.
+--
+
+	function suite.onMultiProcessorCompile()
+		flags { "MultiProcessorCompile" }
+		prepare()
+		test.capture [[
+		<ClCompile>
+			<PrecompiledHeader>NotUsing</PrecompiledHeader>
+			<WarningLevel>Level3</WarningLevel>
+			<Optimization>Disabled</Optimization>
+			<MinimalRebuild>false</MinimalRebuild>
+			<MultiProcessorCompilation>true</MultiProcessorCompilation>
+		]]
+	end