-
-
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
Implemented VS API for toggling of C++20 modules and STL module build #2130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,26 @@ | |
} | ||
} | ||
|
||
p.api.register { | ||
name = "enablemodules", | ||
scope = { "config" }, | ||
kind = "string", | ||
allowed = { | ||
"On", | ||
"Off" | ||
} | ||
} | ||
|
||
p.api.register { | ||
name = "buildstlmodules", | ||
scope = { "config" }, | ||
kind = "string", | ||
allowed = { | ||
"On", | ||
"Off" | ||
} | ||
Comment on lines
+211
to
+215
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
} | ||
|
||
-- | ||
-- Decide when the full module should be loaded. | ||
-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,6 +403,8 @@ | |
m.externalAngleBrackets, | ||
m.scanSourceForModuleDependencies, | ||
m.useStandardPreprocessor, | ||
m.enableModules, | ||
m.buildStlModules, | ||
} | ||
|
||
if cfg.kind == p.STATICLIB then | ||
|
@@ -3024,6 +3026,24 @@ | |
end | ||
|
||
|
||
function m.enableModules(cfg) | ||
if _ACTION >= "vs2019" then | ||
if cfg.enablemodules then | ||
m.element("EnableModules", nil, iif(cfg.enablemodules == "On", "true", "false")) | ||
end | ||
end | ||
end | ||
|
||
|
||
function m.buildStlModules(cfg) | ||
if _ACTION >= "vs2022" then | ||
if cfg.buildstlmodules then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, it makes no sense to have this activated wtihout the other, but I don't believe we do this kind of sanity checking elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
m.element("BuildStlModules", nil, iif(cfg.buildstlmodules == "On", "true", "false")) | ||
end | ||
end | ||
end | ||
|
||
|
||
function m.externalAngleBrackets(cfg, condition) | ||
if _ACTION >= "vs2019" then | ||
if cfg.externalanglebrackets == p.OFF then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Sets whether or not the compiler should build STL modules. | ||
|
||
```lua | ||
buildstlmodules("value") | ||
``` | ||
|
||
### Parameters ### | ||
|
||
`value` is one of: | ||
|
||
- `On` | ||
- `Off` | ||
|
||
### Applies To ### | ||
|
||
The `config` scope. | ||
|
||
### Availability ### | ||
|
||
Premake 5.0.0 beta 3 or later for Visual Studio 2022 and later. | ||
|
||
### See Also ### | ||
|
||
* [enablemodules](enablemodules.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Sets whether or not the compiler should enable C++20 modules. | ||
|
||
```lua | ||
enablemodules("value") | ||
``` | ||
|
||
### Parameters ### | ||
|
||
`value` is one of: | ||
|
||
- `On` | ||
- `Off` | ||
|
||
### Applies To ### | ||
|
||
The `config` scope. | ||
|
||
### Availability ### | ||
|
||
Premake 5.0.0 beta 3 or later for Visual Studio 2019 and later. | ||
nickclark2016 marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Using the
boolean
type would probably be better.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 thought about using those, but there are also plenty of spots in the code where "Off" and "On" are used in place of a boolean value. Should we start just using boolean instead? If so, that's an easy fix.
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.
The inputs for boolean are more flexible:
premake-core/src/base/api.lua
Lines 762 to 787 in 561f9a9
From memory there are issues when using this with look up tables, which is how the toolsets work. So, it's up to you whether you think it's a good idea or not.