Commits

Jason Perkins committed e012212

Added force include files

Comments (0)

Files changed (8)

src/actions/vstudio/vs200x_vcproj.lua

 		if cfg.project.language == "C" then
 			_p(4, 'CompileAs="1"')
 		end
+
+		vc200x.forcedIncludeFiles(cfg)
 	end
 
 
 
 		_p(4,'DebugInformationFormat="0"')
 		_p(4,'CompileAs="0"')
+
+		vc200x.forcedIncludeFiles(cfg)
 	end
 
 
 
 
 --
+-- Write out the ForcedIncludeFiles element, used by both compiler variations.
+--
+
+	function vc200x.forcedIncludeFiles(cfg)
+		if #cfg.forceincludes > 0 then
+			local includes = project.getrelative(cfg.project, cfg.forceincludes)
+			_x(4,'ForcedIncludeFiles="%s"', table.concat(includes, ';'))
+		end
+	end
+
+
+--
 -- Returns the correct name for the linker tool element, based on
 -- the configuration target system.
 --

src/actions/vstudio/vs2010_vcxproj.lua

         vc2010.warnings(cfg)
 		vc2010.preprocessorDefinitions(cfg.defines)
 		vc2010.additionalIncludeDirectories(cfg, cfg.includedirs)
+
+		if #cfg.forceincludes > 0 then
+			local includes = project.getrelative(cfg.project, cfg.forceincludes)
+			_x(3,'<ForcedIncludeFiles>%s</ForcedIncludeFiles>', table.concat(includes, ';'))
+		end
+
 		vc2010.debuginfo(cfg)
 
 		if cfg.flags.Symbols and cfg.debugformat ~= "c7" then
 	}
 
 	api.register {
+		name = "forceincludes",
+		scope = "config",
+		kind = "file-list",
+	}
+
+	api.register {
 		name = "framework",
 		scope = "project",
 		kind = "string",

src/tools/gcc.lua

 			flags = { "-MMD", "-MP" }
 		end
 
+		for _, fi in ipairs(cfg.forceincludes) do
+			local fn = project.getrelative(cfg.project, fi)
+			table.insert(flags, string.format('-include "%s"', fn))
+		end
+		
 		return flags
 	end
 

tests/actions/vstudio/vc200x/test_compiler_block.lua

 -- Verify that the PDB file uses the target name if specified.
 --
 
-	function suite.pdfUsesTargetName_onTargetName()
+	function suite.pdbUsesTargetName_onTargetName()
 		targetname "foob"
 		prepare()
 		test.capture [[
 			/>
 		]]
 	end
+
+
+--
+-- Check handling of forced includes.
+--
+
+	function suite.forcedIncludeFiles()
+		forceincludes { "stdafx.h", "include/sys.h" }
+		prepare()
+		test.capture [[
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="0"
+				ProgramDataBaseFileName="$(OutDir)\MyProject.pdb"
+				WarningLevel="3"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="stdafx.h;include/sys.h"
+		]]
+	end

tests/actions/vstudio/vc200x/test_external_compiler.lua

 				UsePrecompiledHeader="0"
 		]]
 	end
+
+
+--
+-- Check handling of forced includes.
+--
+
+	function suite.forcedIncludeFiles()
+		forceincludes { "stdafx.h", "include/sys.h" }
+		prepare()
+		test.capture [[
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="-Xc+=exceptions -Xc+=rtti"
+				UsePrecompiledHeader="0"
+				ProgramDataBaseFileName="$(OutDir)\MyProject.pdb"
+				DebugInformationFormat="0"
+				CompileAs="0"
+				ForcedIncludeFiles="stdafx.h;include/sys.h"
+		]]
+	end

tests/actions/vstudio/vc2010/test_compile_settings.lua

 		]]
 	end
 
+
 --
 -- Verify character handling.
 --
 			<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
 		]]
 	end
+
 	
 --
 -- Edit-and-Continue is not support on 64-bit builds.
 		]]
 	end
 
+
 --
 -- Check the handling of the NoEditAndContinue flag.
 --
 		]]
 	end
 
+
 --
 -- Edit-and-Continue is not supported for optimized builds.
 --
 		]]
 	end
 
+
 --
 -- Edit-and-Continue is not supported for Managed builds.
 --
 		]]
 	end
 
+
+--
+-- Check handling of forced includes.
+--
+
+	function suite.forcedIncludeFiles()
+		forceincludes { "stdafx.h", "include/sys.h" }
+		prepare()
+		test.capture [[
+		<ClCompile>
+			<PrecompiledHeader>NotUsing</PrecompiledHeader>
+			<WarningLevel>Level3</WarningLevel>
+			<ForcedIncludeFiles>stdafx.h;include/sys.h</ForcedIncludeFiles>
+		]]
+	end

tests/tools/test_gcc.lua

 -- libraries, since I don't know the actual output target.
 --
 
-
 	function suite.skipsExternalProjectRefs()
 		links { "MyProject2" }
 		
 		prepare()
 		test.isequal({}, gcc.getlinks(cfg, false))
 	end
+
+
+--
+-- Check handling of forced includes.
+--
+
+	function suite.forcedIncludeFiles()
+		forceincludes { "stdafx.h", "include/sys.h" }
+		prepare()
+		test.isequal({"-MMD", "-MP", '-include "stdafx.h"', '-include "include/sys.h"'}, gcc.getcppflags(cfg))
+	end