-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Refactor language flags to go through the language API. #686
Conversation
@@ -366,7 +366,10 @@ | |||
end | |||
|
|||
function m.completion(cfg) | |||
_p(3, '<Completion EnableCpp11="%s" EnableCpp14="%s">', iif(cfg.flags["C++11"], "yes", "no"), iif(cfg.flags["C++14"], "yes", "no")) | |||
local cpp11 = (cfg.language == 'gnu++11') or (cfg.language == 'C++11') or cfg.flags["C++11"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a function, to allow others to add other language extensions like GNU++11. For example, VS2015 Update 3 (probably VS2017 too) allows you to specify "C++Latest", we should have support for this to translate to C++17. When C++20 starts happening, it will need to map to that, and changing it everywhere is going to be time consuming.
modules/xcode/xcode_common.lua
Outdated
settings['GCC_C_LANGUAGE_STANDARD'] = 'gnu99' | ||
if (p.languages.isc(cfg.language)) then | ||
if cfg.language ~= "C" then | ||
settings['GCC_C_LANGUAGE_STANDARD'] = cfg.language:lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on previous comment, this will need to handle things like "C++Latest" (but a C equivalent), so it's probably best this entire block for adding GCC_C_LANGUAGE_STANDARD
be a function instead, same for the C++ block.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these all set the language?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, shouldn't break anything. Just thought it would be easier to handle both the language and the flags at the point of application, which you did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the suggestion was ultimately the correct one:
api.deprecateValue("flags", "C++11", 'Use `language "C++11"` instead',
function(value)
language "C++11"
end,
function(value)
<what to do here> ???
end)
I've tried a few things,
removelanguage "C++11"
or
language "C++"
but they all break...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a Default
value to language
? I'm picturing a situation like this:
project "NiceProject"
language "C++14"
files { "**.h", "**.c" }
filter { "files:RealCFiles/**.c" }
language "Default"
Would the language value flow down regardless of extension? Assuming it would, the above might be desired functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's right, forgot about that part. We need the ability to set the language (or standard, or whatever) for each "dialect".
clanguage "C99"
cpplanguage "C++14"
We can still have the generic language
, which is used if a more specific value hasn't been set. And of course this needs to extend to any supported language:
dlanguage "SafeD"
So yeah…there's that. Not sure if there is a more elegant/transparent way to express this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just do:
language "C++14"
filter { "files:*.c" }
language "C99"
but that said, if we went the "dialect" route, I would certainly prefer to actually use that name.
So either:
dialect {
cpp = "C++14"
c = "C90",
d = "D3.4", -- if such a thing was a thing.
}
or as suggested:
cdialect 'C90'
cppdialect 'C++14'
ddialect 'D3.4"
I'm somewhat indifferent to the approach, I think both have merit..
You guys want me to prototype that instead??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just do:
language "C++14"
filter { "files:*.c" }
language "C99"
You're quite right, I was overthinking. It is really only an issue in multi-language (or dialect) projects, and this suggestion is the right way to go.
48377b0
to
d1bf9be
Compare
Can we merge this? or is there more work left? |
@tvandijck There's a few places where you remove checks for |
not sure I understand this...
I see that one, but the check was wrong... vcxproj is for both C and C++ projects. In that same boat, I then also think the "project.isnative" method is confusing, because there really isn't such a thing... |
Well, ideally, we'd change the functions so that generic and specific code don't exist in the same function. Maybe for now, the best move would be to check for C and C++ and then, eventually, we can move the generic code out. Thoughts? |
While you're at it, add the new switches for Visual Studio as well? ["C++"] = "/std:c++latest",
["C++14"] = "/std:c++14" imo it's a horrible thing that MS did there, especially since "some" of the standards aren't locked behind the switches, I really hope they'll sort this out in the future and maybe add switches for the older standards as well...
|
@samsinsane what changes do we still need here? other then what @neico suggests to add? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have this feeling that this will break at least one of my modules, but I'm not sure which one or where, and I'm just not that bothered to find out exactly how. Something else has probably already broken them, so let's move forward and I'll submit a PR if something needs to be fixed.
So you can use 'language "C++11"' instead of 'flags { "C++11" }'
I rebased this, and made some more modifications to solve some of the comments @samsinsane made about me removing some of the required "iscpp" calls... I think I got them all correct now, but please review. |
@neico this commit just modifies the flag/api.... I've not actually implemented usage of it inside of the Visual Studio action at all... Feel free to submit further PR's on top of this change for that once this is merged (or even against this PR). |
end | ||
end | ||
else | ||
settings['GCC_C_LANGUAGE_STANDARD'] = 'gnu99' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this map to one of the C11 standards when the language is C++17? I believe C++17 is based on C11, rather than C99, or is it the plan for the next C++ standard to be on C11?
@@ -51,16 +51,14 @@ | |||
if #user > 0 then | |||
p.generate(prj, ".csproj.user", function() p.outln(user) end) | |||
end | |||
|
|||
elseif premake.project.iscpp(prj) then | |||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this should probably have the check for C/C++, but I'm happy to ignore this since it's for VS2005 and VS2008, and VS2008 will be EOL in a little under a year.
Are we good to merge? I think it looks pretty good, major props to @tvandijck for putting it together! |
Looks like the line endings in |
|
I fixed this in my branch by running I think git provides facilities to automatically normalize line endings on push with a |
@aleksijuvani if you throw in So yeah, imo any git project should at least use the first 2 mentioned files. |
So you can use 'language "C++11"' instead of 'flags { "C++11" }'