Add 'supports_language' callback to action to validate languages now that we have multiple dialects

This commit is contained in:
Tom van Dijck 2017-04-24 13:37:28 -07:00
parent 97856fe923
commit 6d471ecc2a
14 changed files with 69 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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')

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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