diff --git a/modules/codelite/_preload.lua b/modules/codelite/_preload.lua index d7accaaece..be544968b3 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 8559e8c4ab..6aa148e716 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 31bef12122..2106f29fd3 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 b8bef93ddd..3c056a2eb2 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 412974afd1..3ab136a478 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 7da88ec99f..dbd09b023c 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 72dff6f57b..916307553d 100644 --- a/src/actions/vstudio/vs2005.lua +++ b/src/actions/vstudio/vs2005.lua @@ -86,11 +86,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 81116e0084..07e131c9c5 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 d9ead4d0d0..df99f54059 100644 --- a/src/actions/vstudio/vs2010.lua +++ b/src/actions/vstudio/vs2010.lua @@ -135,11 +135,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 64653f68e1..e257b6642a 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 c0edb028b1..0a5c53fc0e 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 f57542386e..5ddf83a050 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 4afc9a1ac3..12121e61ed 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 b9ff31f852..f5e5857a04 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -245,19 +245,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