Skip to content

Commit

Permalink
[core] Use 'cdialect' and 'cppdialect' instead of 'language'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom van Dijck committed May 4, 2017
1 parent 347c9c4 commit 7af2817
Show file tree
Hide file tree
Showing 21 changed files with 243 additions and 162 deletions.
5 changes: 1 addition & 4 deletions modules/codelite/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
-- 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: 2 additions & 2 deletions modules/codelite/codelite_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@
end

function m.isCpp11(cfg)
return (cfg.language == 'gnu++11') or (cfg.language == 'C++11') or cfg.flags["C++11"]
return (cfg.cppdialect == 'gnu++11') or (cfg.cppdialect == 'C++11')
end

function m.isCpp14(cfg)
return (cfg.language == 'gnu++14') or (cfg.language == 'C++14') or cfg.flags["C++14"]
return (cfg.cppdialect == 'gnu++14') or (cfg.cppdialect == 'C++14')
end

function m.completion(cfg)
Expand Down
8 changes: 5 additions & 3 deletions modules/codelite/tests/test_codelite_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@
rtti "Off"
pic "On"
symbols "On"
language "C++11"
language "C++"
cppdialect "C++11"
flags { "NoBufferSecurityCheck" }
buildoptions { "-opt1", "-opt2" }
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="-O0;-fPIC;-g;-fno-exceptions;-fno-stack-protector;-std=c++11;-fno-rtti;-opt1;-opt2" C_Options="-O0;-fPIC;-g;-opt1;-opt2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
<Compiler Options="-O0;-fPIC;-g;-std=c++11;-fno-exceptions;-fno-stack-protector;-fno-rtti;-opt1;-opt2" C_Options="-O0;-fPIC;-g;-opt1;-opt2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
Expand Down Expand Up @@ -219,7 +220,8 @@ cmd2</StartupCommands>
end

function suite.OnProject_Completion()
language "C++11"
language "C++"
cppdialect "C++11"
prepare()
codelite.project.completion(prj)
test.capture [[
Expand Down
2 changes: 0 additions & 2 deletions modules/d/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
--

p.D = "D"

table.insert(p.languages.all, p.D)
api.addAllowed("language", p.D)

api.addAllowed("floatingpoint", "None")
Expand Down
5 changes: 1 addition & 4 deletions modules/d/actions/gmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
--
-- 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
local all = true
Expand Down
6 changes: 2 additions & 4 deletions modules/d/actions/vstudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
-- Patch the vstudio actions with D support...
--

for k,v in pairs({ "vs2005", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015" }) do
for k,v in pairs({ "vs2005", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015", "vs2017" }) do
local vs = p.action.get(v)
if vs ~= nil then
p.override(vs, "supports_language", function(oldfn, lang)
return oldfn(lang) or lang == p.D;
end)
table.insert( vs.valid_languages, p.D )
vs.valid_tools.dc = { "dmd", "gdc", "ldc" }

p.override(vs, "onProject", function(oldfn, prj)
Expand Down
6 changes: 2 additions & 4 deletions modules/xcode/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
-- 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
26 changes: 4 additions & 22 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -960,35 +960,17 @@


function xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg)
if (p.languages.isc(cfg.language)) then
if cfg.language ~= "C" then
settings['GCC_C_LANGUAGE_STANDARD'] = cfg.language:lower()
else
if cfg.flags['C99'] then
settings['GCC_C_LANGUAGE_STANDARD'] = 'C99'
elseif cfg.flags['C11'] then
settings['GCC_C_LANGUAGE_STANDARD'] = 'C11'
else
settings['GCC_C_LANGUAGE_STANDARD'] = 'C90'
end
end
if cfg.cdialect and cfg.cdialect ~= "Default" then
settings['GCC_C_LANGUAGE_STANDARD'] = cfg.cdialect
else
settings['GCC_C_LANGUAGE_STANDARD'] = 'gnu99'
end
end


function xcode.XCBuildConfiguration_CppLanguageStandard(settings, cfg)
if (p.languages.iscpp(cfg.language)) then
if cfg.language ~= "C++" then
settings['CLANG_CXX_LANGUAGE_STANDARD'] = cfg.language:lower()
else
if cfg.flags['C++11'] then
settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++11'
elseif cfg.flags['C++14'] then
settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++14'
end
end
if cfg.cppdialect and cfg.cppdialect ~= "Default" then
settings['CLANG_CXX_LANGUAGE_STANDARD'] = cfg.cppdialect
end
end

Expand Down
84 changes: 78 additions & 6 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,47 @@

api.register {
name = "language",
scope = "project",
kind = "string",
allowed = {
"C",
"C++",
"C#"
}
}

api.register {
name = "cdialect",
scope = "config",
kind = "string",
allowed = p.languages.all
allowed = {
"Default",
"C89",
"C90",
"C99",
"C11",
"gnu89",
"gnu90",
"gnu99",
"gnu11",
}
}

api.register {
name = "cppdialect",
scope = "config",
kind = "string",
allowed = {
"Default",
"C++98",
"C++11",
"C++14",
"C++17",
"gnu++98",
"gnu++11",
"gnu++14",
"gnu++17",
}
}

api.register {
Expand Down Expand Up @@ -1368,11 +1406,45 @@

-- 31 January 2017

api.deprecateValue("flags", "C++11", 'Use `language "C++11"` instead', function(value) end, function(value) end)
api.deprecateValue("flags", "C++14", 'Use `language "C++14"` instead', function(value) end, function(value) end)
api.deprecateValue("flags", "C90", 'Use `language "C90"` instead', function(value) end, function(value) end)
api.deprecateValue("flags", "C99", 'Use `language "C99"` instead', function(value) end, function(value) end)
api.deprecateValue("flags", "C11", 'Use `language "C11"` instead', function(value) end, function(value) end)
api.deprecateValue("flags", "C++11", 'Use `cppdialect "C++11"` instead',
function(value)
cppdialect "C++11"
end,
function(value)
cppdialect "Default"
end)

api.deprecateValue("flags", "C++14", 'Use `cppdialect "C++14"` instead',
function(value)
cppdialect "C++14"
end,
function(value)
cppdialect "Default"
end)

api.deprecateValue("flags", "C90", 'Use `cdialect "gnu90"` instead',
function(value)
cdialect "gnu90"
end,
function(value)
cdialect "Default"
end)

api.deprecateValue("flags", "C99", 'Use `cdialect "gnu99"` instead',
function(value)
cdialect "gnu99"
end,
function(value)
cdialect "Default"
end)

api.deprecateValue("flags", "C11", 'Use `cdialect "gnu11"` instead',
function(value)
cdialect "gnu11"
end,
function(value)
cdialect "Default"
end)


-- 13 April 2017
Expand Down
8 changes: 1 addition & 7 deletions src/actions/make/_make.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@
description = "Generate GNU makefiles for POSIX, MinGW, and Cygwin",

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)
p.escaper(make.esc)
p.generate(wks, make.getmakefilename(wks, false), make.generate_workspace)
Expand Down
6 changes: 1 addition & 5 deletions src/actions/vstudio/vs2005.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2008.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2010.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2012.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2013.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2015.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@
-- 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: 1 addition & 5 deletions src/actions/vstudio/vs2017.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@
-- 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
Loading

0 comments on commit 7af2817

Please sign in to comment.