Merge pull request #1952 from flakey5/flakey5/add-usestandardpreprocessor

vstudio: add usestandardpreprocessor option
This commit is contained in:
Samuel Surtees 2022-10-07 12:59:07 +10:00 committed by GitHub
commit 7d241a6d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 0 deletions

View File

@ -175,6 +175,16 @@
kind = "boolean" kind = "boolean"
} }
p.api.register {
name = "usestandardpreprocessor",
scope = "config",
kind = "string",
allowed = {
"On",
"Off"
}
}
-- --
-- Decide when the full module should be loaded. -- Decide when the full module should be loaded.

View File

@ -106,3 +106,27 @@
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies> <ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
]] ]]
end end
function suite.UseStandardPreprocessorOn()
usestandardpreprocessor 'On'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
]]
end
function suite.UseStandardPreprocessorOff()
usestandardpreprocessor 'Off'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<UseStandardPreprocessor>false</UseStandardPreprocessor>
]]
end

View File

@ -400,6 +400,7 @@
m.externalWarningLevel, m.externalWarningLevel,
m.externalAngleBrackets, m.externalAngleBrackets,
m.scanSourceForModuleDependencies, m.scanSourceForModuleDependencies,
m.useStandardPreprocessor,
} }
if cfg.kind == p.STATICLIB then if cfg.kind == p.STATICLIB then
@ -2955,6 +2956,16 @@
end end
end end
function m.useStandardPreprocessor(cfg)
if _ACTION >= "vs2019" and cfg.usestandardpreprocessor ~= nil then
if cfg.usestandardpreprocessor == 'On' then
m.element("UseStandardPreprocessor", nil, "true")
else
m.element("UseStandardPreprocessor", nil, "false")
end
end
end
function m.xmlDeclaration() function m.xmlDeclaration()
p.xmlUtf8() p.xmlUtf8()

View File

@ -134,6 +134,10 @@
openmp = { openmp = {
On = "/openmp", On = "/openmp",
Off = "/openmp-" Off = "/openmp-"
},
usestandardpreprocessor = {
On = "/Zc:preprocessor",
Off = "/Zc:preprocessor-"
} }
} }

View File

@ -0,0 +1,26 @@
Enables a token-based preprocessor conforming to C99, C++11, and later standards.
```lua
usestandardpreprocessor 'value'
```
### Parameters ###
`value` is one of:
| Action | Description |
|-------------|---------------------------------------|
| Off | Do not use the conforming processor. |
| On | Enable the conforming processor. |
### Applies To ###
Visual Studio 2019 or later.
### Availability ###
Premake 5.0 or later.
### See Also ###
* [Microsoft's documentation](https://docs.microsoft.com/en-us/cpp/build/reference/zc-preprocessor)

View File

@ -277,6 +277,7 @@ module.exports = {
'undefines', 'undefines',
'unsignedchar', 'unsignedchar',
'usefullpaths', 'usefullpaths',
'usestandardpreprocessor',
'usingdirs', 'usingdirs',
'uuid', 'uuid',
'vectorextensions', 'vectorextensions',