diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 668feb82..c1bbaf71 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -145,6 +145,7 @@ if cfg.kind == p.UTILITY then return { m.configurationType, + m.platformToolset, } else return { @@ -349,7 +350,7 @@ end function m.resourceCompile(cfg) - if cfg.system ~= p.XBOX360 and config.hasResourceFiles(cfg) then + if cfg.system ~= p.XBOX360 and p.config.hasFile(cfg, path.isresourcefile) then local contents = p.capture(function () p.push() p.callArray(m.elements.resourceCompile, cfg) @@ -1560,12 +1561,12 @@ version = action.vstudio.platformToolset end if version then - -- should only be written if there is a C/C++ file in the config - for i = 1, #cfg.files do - if path.iscppfile(cfg.files[i]) then + if cfg.kind == p.NONE or cfg.kind == p.MAKEFILE then + if p.config.hasFile(cfg, path.iscppfile) then m.element("PlatformToolset", nil, version) - break end + else + m.element("PlatformToolset", nil, version) end end end diff --git a/src/base/config.lua b/src/base/config.lua index a38c5ba0..45aed44c 100755 --- a/src/base/config.lua +++ b/src/base/config.lua @@ -359,14 +359,15 @@ --- --- Determine if a configuration contains one or more resource files. --- +--- +-- Returns true if any of the files in the provided container pass the +-- provided test function. +--- - function config.hasResourceFiles(self) + function config.hasFile(self, testfn) local files = self.files for i = 1, #files do - if path.isresourcefile(files[i]) then + if testfn(files[i]) then return true end end diff --git a/tests/actions/vstudio/vc2010/test_platform_toolset.lua b/tests/actions/vstudio/vc2010/test_platform_toolset.lua index eb02b7fe..891ec61b 100644 --- a/tests/actions/vstudio/vc2010/test_platform_toolset.lua +++ b/tests/actions/vstudio/vc2010/test_platform_toolset.lua @@ -56,17 +56,6 @@ end --- --- Element should only be written if C++ files are present. --- - - function suite.empty_onNoRelevantSources() - removefiles "hello.cpp" - prepare() - test.isemptycapture() - end - - -- -- Check for overrides from project scripts. -- @@ -102,3 +91,31 @@ LLVM-vs2014_xp ]] end + +-- +-- Check if platform toolset element is being emitted correctly. +-- + + function suite.output_onConsoleAppAndNoCpp() + kind "ConsoleApp" + removefiles "hello.cpp" + prepare() + test.capture [[ +v110 + ]] + end + + function suite.skipped_onNoMakefileAndNoCpp() + kind "Makefile" + removefiles "hello.cpp" + prepare() + test.isemptycapture() + end + + function suite.output_onNoMakefileAndCpp() + kind "Makefile" + prepare() + test.capture [[ +v110 + ]] + end