Added force include files

This commit is contained in:
Jason Perkins 2012-11-06 16:42:44 -05:00
parent 2800ebd010
commit 89deec0474
8 changed files with 108 additions and 2 deletions

View File

@ -332,6 +332,8 @@
if cfg.project.language == "C" then
_p(4, 'CompileAs="1"')
end
vc200x.forcedIncludeFiles(cfg)
end
@ -358,6 +360,8 @@
_p(4,'DebugInformationFormat="0"')
_p(4,'CompileAs="0"')
vc200x.forcedIncludeFiles(cfg)
end
@ -900,6 +904,18 @@
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.

View File

@ -229,6 +229,12 @@
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

View File

@ -570,6 +570,12 @@
},
}
api.register {
name = "forceincludes",
scope = "config",
kind = "file-list",
}
api.register {
name = "framework",
scope = "project",

View File

@ -83,6 +83,11 @@
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

View File

@ -210,7 +210,7 @@
-- Verify that the PDB file uses the target name if specified.
--
function suite.pdfUsesTargetName_onTargetName()
function suite.pdbUsesTargetName_onTargetName()
targetname "foob"
prepare()
test.capture [[
@ -439,3 +439,26 @@
/>
]]
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

View File

@ -61,3 +61,23 @@
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

View File

@ -403,6 +403,7 @@
]]
end
--
-- Verify character handling.
--
@ -488,6 +489,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
]]
end
--
-- Edit-and-Continue is not support on 64-bit builds.
@ -505,6 +507,7 @@
]]
end
--
-- Check the handling of the NoEditAndContinue flag.
--
@ -520,6 +523,7 @@
]]
end
--
-- Edit-and-Continue is not supported for optimized builds.
--
@ -535,6 +539,7 @@
]]
end
--
-- Edit-and-Continue is not supported for Managed builds.
--
@ -550,3 +555,18 @@
]]
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

View File

@ -278,7 +278,6 @@
-- libraries, since I don't know the actual output target.
--
function suite.skipsExternalProjectRefs()
links { "MyProject2" }
@ -289,3 +288,14 @@
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