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 depth = depth + 1
for cfg in project.eachconfig(prj) do for cfg in project.eachconfig(prj) do
local hasconfig local elementOpened = false
local filecfg = nil
local out = function(depth, msg, ...) -- helper function writes an attribute into the <Tool> element, opening
if not hasconfig then -- the containing <FileConfiguration> element on the first call.
hasconfig = true local toolattrib = function(depth, msg, ...)
if not elementOpened then
elementOpened = true
_p(depth, '<FileConfiguration') _p(depth, '<FileConfiguration')
_p(depth, '\tName="%s"', vstudio.configname(cfg)) _p(depth, '\tName="%s"', vstudio.configname(cfg))
if not filecfg then
_p(depth, '\tExcludedFromBuild="true"')
end
_p(depth, '\t>') _p(depth, '\t>')
_p(depth, '\t<Tool') _p(depth, '\t<Tool')
_p(depth, '\t\tName="%s"', vc200x.compilertool(cfg)) _p(depth, '\t\tName="%s"', vc200x.compilertool(cfg))
end end
_x(depth, msg, unpack(arg)) if msg then
_x(depth, msg, unpack(arg))
end
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 if compileAs then
out(depth, '\t\tCompileAs="%s"', compileAs) toolattrib(depth, '\t\tCompileAs="%s"', compileAs)
end end
if pchsource == node.cfg.fullpath and not cfg.flags.NoPCH then if pchsource == node.cfg.fullpath and not cfg.flags.NoPCH then
@ -762,13 +777,13 @@
premake.snc.getcxxflags(cfg), premake.snc.getcxxflags(cfg),
cfg.buildoptions, cfg.buildoptions,
' --create_pch="$(IntDir)/$(TargetName).pch"') ' --create_pch="$(IntDir)/$(TargetName).pch"')
out(depth, '\t\tAdditionalOptions="%s"', table.concat(options, " ")) toolattrib(depth, '\t\tAdditionalOptions="%s"', table.concat(options, " "))
else else
out(depth, '\t\tUsePrecompiledHeader="1"') toolattrib(depth, '\t\tUsePrecompiledHeader="1"')
end end
end end
if hasconfig then if elementOpened then
_p(depth, '\t/>') _p(depth, '\t/>')
_p(depth, '</FileConfiguration>') _p(depth, '</FileConfiguration>')
end end

View File

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

View File

@ -189,3 +189,29 @@
UsePrecompiledHeader="1" UsePrecompiledHeader="1"
]] ]]
end 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