diff --git a/modules/codelite/_preload.lua b/modules/codelite/_preload.lua index d7accaae..be544968 100644 --- a/modules/codelite/_preload.lua +++ b/modules/codelite/_preload.lua @@ -22,10 +22,13 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "Makefile", "SharedLib", "StaticLib", "Utility" }, - valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc", "clang", "msc" } }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) + end, -- Workspace and project generation logic diff --git a/modules/d/actions/gmake.lua b/modules/d/actions/gmake.lua index 8559e8c4..6aa148e7 100644 --- a/modules/d/actions/gmake.lua +++ b/modules/d/actions/gmake.lua @@ -28,9 +28,11 @@ -- -- Patch the gmake action with the allowed tools... -- - gmake.valid_languages = table.join(gmake.valid_languages, { p.D } ) gmake.valid_tools.dc = { "dmd", "gdc", "ldc" } + p.override(gmake, "supports_language", function(oldfn, lang) + return oldfn(lang) or lang == p.D; + end) function m.make.separateCompilation(prj) local some = false diff --git a/modules/d/actions/vstudio.lua b/modules/d/actions/vstudio.lua index 31bef121..2106f29f 100644 --- a/modules/d/actions/vstudio.lua +++ b/modules/d/actions/vstudio.lua @@ -22,7 +22,9 @@ for k,v in pairs({ "vs2005", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015" }) do local vs = p.action.get(v) if vs ~= nil then - table.insert( vs.valid_languages, p.D ) + p.override(vs, "supports_language", function(oldfn, lang) + return oldfn(lang) or lang == p.D; + end) vs.valid_tools.dc = { "dmd", "gdc", "ldc" } p.override(vs, "onProject", function(oldfn, prj) diff --git a/modules/raw/_preload.lua b/modules/raw/_preload.lua index b8bef93d..3c056a2e 100644 --- a/modules/raw/_preload.lua +++ b/modules/raw/_preload.lua @@ -4,10 +4,6 @@ newaction shortname = "Raw output", description = "Generate raw representation of Premake structures", - valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib", "Makefile", "None", "Utility" }, - valid_languages = { "C", "C++" }, - valid_tools = { cc = { "clang" } }, - onsolution = function(sln) require('raw') diff --git a/modules/xcode/_preload.lua b/modules/xcode/_preload.lua index 4c1cc1b2..63b62bc8 100644 --- a/modules/xcode/_preload.lua +++ b/modules/xcode/_preload.lua @@ -40,10 +40,13 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib", "Makefile", "None" }, - valid_languages = { "C", "C++" }, valid_tools = { cc = { "gcc", "clang" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/make/_make.lua b/src/actions/make/_make.lua index 7da88ec9..dbd09b02 100644 --- a/src/actions/make/_make.lua +++ b/src/actions/make/_make.lua @@ -22,13 +22,17 @@ valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Utility", "Makefile" }, - valid_languages = { "C", "C++", "C#" }, - valid_tools = { cc = { "clang", "gcc" }, dotnet = { "mono", "msnet", "pnet" } }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, + onWorkspace = function(wks) premake.escaper(make.esc) premake.generate(wks, make.getmakefilename(wks, false), make.generate_workspace) diff --git a/src/actions/vstudio/vs2005.lua b/src/actions/vstudio/vs2005.lua index 2a7ebc88..9cbfe81d 100644 --- a/src/actions/vstudio/vs2005.lua +++ b/src/actions/vstudio/vs2005.lua @@ -100,11 +100,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2008.lua b/src/actions/vstudio/vs2008.lua index afe3e49a..6ee1a6cf 100644 --- a/src/actions/vstudio/vs2008.lua +++ b/src/actions/vstudio/vs2008.lua @@ -27,11 +27,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2010.lua b/src/actions/vstudio/vs2010.lua index 4cd57f91..fd7109bb 100644 --- a/src/actions/vstudio/vs2010.lua +++ b/src/actions/vstudio/vs2010.lua @@ -123,11 +123,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None", "Utility" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2012.lua b/src/actions/vstudio/vs2012.lua index 4f46dc56..cc6910b6 100644 --- a/src/actions/vstudio/vs2012.lua +++ b/src/actions/vstudio/vs2012.lua @@ -29,11 +29,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None", "Utility" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2013.lua b/src/actions/vstudio/vs2013.lua index 558f02bc..7ade06db 100644 --- a/src/actions/vstudio/vs2013.lua +++ b/src/actions/vstudio/vs2013.lua @@ -31,11 +31,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None", "Utility" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2015.lua b/src/actions/vstudio/vs2015.lua index 88ab8e5e..ab2676a3 100644 --- a/src/actions/vstudio/vs2015.lua +++ b/src/actions/vstudio/vs2015.lua @@ -31,11 +31,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None", "Utility" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/actions/vstudio/vs2017.lua b/src/actions/vstudio/vs2017.lua index 0d5617c3..0ecb53f9 100644 --- a/src/actions/vstudio/vs2017.lua +++ b/src/actions/vstudio/vs2017.lua @@ -31,11 +31,15 @@ -- The capabilities of this action valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None", "Utility", "Installer" }, - valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, + supports_language = function(lang) + return p.languages.isc(lang) or + p.languages.iscpp(lang) or + p.languages.isdotnet(lang) + end, -- Workspace and project generation logic diff --git a/src/base/action.lua b/src/base/action.lua index c403742c..5edabf23 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -239,19 +239,24 @@ if not self then return false end - if not self.valid_languages and not self.valid_kinds then + + if not self.valid_languages and not self.valid_kinds and not self.supports_language then return true end - if self.valid_languages then - if table.contains(self.valid_languages, feature) then - return true - end + + if self.valid_languages and table.contains(self.valid_languages, feature) then + return true end - if self.valid_kinds then - if table.contains(self.valid_kinds, feature) then - return true - end + + if self.valid_kinds and table.contains(self.valid_kinds, feature) then + return true end + + if self.supports_language and self.supports_language(feature) then + return true + end + + return false end