Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'supports_language' callback to action #755

Merged
merged 1 commit into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/codelite/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion modules/d/actions/gmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion modules/d/actions/vstudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions modules/raw/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
5 changes: 4 additions & 1 deletion modules/xcode/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/actions/make/_make.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2005.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2008.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2010.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2012.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2013.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2015.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/actions/vstudio/vs2017.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 14 additions & 9 deletions src/base/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down