diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 6c77dfaa..c63021fd 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -496,7 +496,29 @@ if #files > 0 then _p(1,'') for _, file in ipairs(files) do - _x(2,'<%s Include=\"%s\" />', group, path.translate(file.relpath)) + + -- Capture the contents of the element, if any, so + -- I know which form to use. + + local contents = p.capture(function () + if group == "ResourceCompile" then + for cfg in project.eachconfig(prj) do + local condition = vc2010.condition(cfg) + local filecfg = fileconfig.getconfig(file, cfg) + if cfg.system == premake.WINDOWS then + vc2010.excludedFromBuild(cfg, filecfg) + end + end + end + end) + + if #contents > 0 then + _x(2,'<%s Include=\"%s\">', group, path.translate(file.relpath)) + _p("%s", contents) + _p(2,'', group) + else + _x(2,'<%s Include=\"%s\" />', group, path.translate(file.relpath)) + end end _p(1,'') end @@ -555,6 +577,8 @@ local condition = vc2010.condition(cfg) local filecfg = fileconfig.getconfig(file, cfg) if fileconfig.hasCustomBuildRule(filecfg) then + vc2010.excludedFromBuild(cfg, filecfg) + local commands = table.concat(filecfg.buildcommands,'\r\n') _p(3,'%s', condition, premake.esc(commands)) diff --git a/tests/actions/vstudio/vc200x/test_files.lua b/tests/actions/vstudio/vc200x/test_files.lua index 1554119f..853c76d1 100644 --- a/tests/actions/vstudio/vc200x/test_files.lua +++ b/tests/actions/vstudio/vc200x/test_files.lua @@ -259,6 +259,62 @@ ]] end + function suite.excludedFromBuild_onCustomBuildRule_excludedFile() + files { "hello.cg" } + configuration "**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + configuration "Debug" + removefiles { "hello.cg" } + prepare() + test.capture [[ + + + + + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_excludeFlag() + files { "hello.cg" } + configuration "**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + + + + + ]] + end + -- -- If a custom build rule is supplied, the custom build tool settings should be used. diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index 3026ccba..b0395b7e 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -15,6 +15,7 @@ local sln, prj function suite.setup() + _ACTION = "vs2010" sln = test.createsolution() end @@ -164,6 +165,109 @@ ]] end + function suite.excludedFromBuild_onResourceFile_excludedFile() + files { "hello.rc" } + configuration "Debug" + removefiles { "hello.rc" } + prepare() + test.capture [[ + + + true + + + ]] + end + + function suite.excludedFromBuild_onResourceFile_excludeFlag() + files { "hello.rc" } + configuration "hello.rc" + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + true + true + + + ]] + end + + function suite.excludedFromBuild_onResourceFile_excludeFlag_nonWindows() + files { "hello.rc" } + system "PS3" + configuration "hello.rc" + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_excludedFile() + files { "hello.cg" } + configuration "**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + configuration "Debug" + removefiles { "hello.cg" } + prepare() + test.capture [[ + + + Document + cgc $(InputFile) + $(InputName).obj + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_excludeFlag() + files { "hello.cg" } + configuration "**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + Document + true + cgc $(InputFile) + $(InputName).obj + true + cgc $(InputFile) + $(InputName).obj + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_withNoCommands() + files { "hello.cg" } + configuration { "**.cg", "Debug" } + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + configuration { "**.cg" } + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + Document + true + cgc $(InputFile) + $(InputName).obj + + + ]] + end + -- -- If two files at different folder levels have the same name, a different