Added per-configuration file lists for VC2008

This commit is contained in:
Jason Perkins 2012-02-14 16:16:58 -05:00
parent 9d8958a923
commit dac18c990b
3 changed files with 52 additions and 10 deletions

View File

@ -738,22 +738,37 @@
depth = depth + 1
for cfg in project.eachconfig(prj) do
local hasconfig
local elementOpened = false
local filecfg = nil
local out = function(depth, msg, ...)
if not hasconfig then
hasconfig = true
-- helper function writes an attribute into the <Tool> element, opening
-- the containing <FileConfiguration> element on the first call.
local toolattrib = function(depth, msg, ...)
if not elementOpened then
elementOpened = true
_p(depth, '<FileConfiguration')
_p(depth, '\tName="%s"', vstudio.configname(cfg))
if not filecfg then
_p(depth, '\tExcludedFromBuild="true"')
end
_p(depth, '\t>')
_p(depth, '\t<Tool')
_p(depth, '\t\tName="%s"', vc200x.compilertool(cfg))
end
_x(depth, msg, unpack(arg))
if msg then
_x(depth, msg, unpack(arg))
end
end
-- get any settings specific to this file/config combination. If nil,
-- the file is excluded from this configuration
filecfg = config.getfileconfig(cfg, node.cfg.abspath)
if not filecfg then
toolattrib(depth)
end
if compileAs then
out(depth, '\t\tCompileAs="%s"', compileAs)
toolattrib(depth, '\t\tCompileAs="%s"', compileAs)
end
if pchsource == node.cfg.fullpath and not cfg.flags.NoPCH then
@ -762,13 +777,13 @@
premake.snc.getcxxflags(cfg),
cfg.buildoptions,
' --create_pch="$(IntDir)/$(TargetName).pch"')
out(depth, '\t\tAdditionalOptions="%s"', table.concat(options, " "))
toolattrib(depth, '\t\tAdditionalOptions="%s"', table.concat(options, " "))
else
out(depth, '\t\tUsePrecompiledHeader="1"')
toolattrib(depth, '\t\tUsePrecompiledHeader="1"')
end
end
if hasconfig then
if elementOpened then
_p(depth, '\t/>')
_p(depth, '</FileConfiguration>')
end

View File

@ -87,6 +87,7 @@
if i <= #files then
local fcfg = {}
fcfg.fullpath = project.getrelative(prj, files[i])
fcfg.abspath = files[i]
local vpath = project.getvpath(prj, files[i])
if vpath ~= files[i] then

View File

@ -189,3 +189,29 @@
UsePrecompiledHeader="1"
]]
end
--
-- A file excluded from a specific configuration should be marked as such.
--
function suite.excludedFromBuild_onExcludedFile()
files { "hello.cpp" }
configuration "Debug"
removefiles { "hello.cpp" }
prepare()
test.capture [[
<File
RelativePath="hello.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
]]
end