Merge pull request #1790 from hannes-harnisch/allmodulespublic

Adding C++ module file extensions and implementing "allmodulespublic"
This commit is contained in:
Samuel Surtees 2022-02-22 22:20:49 +10:00 committed by GitHub
commit 78b7e4525f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 7 deletions

View File

@ -57,3 +57,40 @@
</PropertyGroup>
]]
end
--
-- If AllModulesPublic flag is set, add <AllProjectBMIsArePublic> element (supported from VS2019)
--
function suite.onAllModulesPublicOn()
allmodulespublic "On"
local cfg = test.getconfig(prj, "Debug", platform)
vc2010.outputProperties(cfg)
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>bin\Debug\</OutDir>
<IntDir>obj\Debug\</IntDir>
<TargetName>MyProject</TargetName>
<TargetExt>.exe</TargetExt>
<AllProjectBMIsArePublic>true</AllProjectBMIsArePublic>
</PropertyGroup>
]]
end
function suite.onAllModulesPublicOff()
allmodulespublic "Off"
local cfg = test.getconfig(prj, "Debug", platform)
vc2010.outputProperties(cfg)
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>bin\Debug\</OutDir>
<IntDir>obj\Debug\</IntDir>
<TargetName>MyProject</TargetName>
<TargetExt>.exe</TargetExt>
<AllProjectBMIsArePublic>false</AllProjectBMIsArePublic>
</PropertyGroup>
]]
end

View File

@ -243,6 +243,7 @@
m.generateManifest,
m.extensionsToDeleteOnClean,
m.executablePath,
m.allModulesPublic,
}
end
end
@ -795,7 +796,7 @@
---
m.categories.ClCompile = {
name = "ClCompile",
extensions = { ".cc", ".cpp", ".cxx", ".c++", ".c", ".s", ".m", ".mm" },
extensions = { ".cc", ".cpp", ".cxx", ".c++", ".c", ".s", ".m", ".mm", ".cppm", ".ixx" },
priority = 2,
emitFiles = function(prj, group)
@ -1506,13 +1507,17 @@
function m.conformanceMode(cfg)
if _ACTION >= "vs2017" then
if cfg.conformancemode ~= nil then
if cfg.conformancemode then
m.element("ConformanceMode", nil, "true")
else
m.element("ConformanceMode", nil, "false")
m.element("ConformanceMode", nil, iif(cfg.conformancemode, "true", "false"))
end
end
end
function m.allModulesPublic(cfg)
if _ACTION >= "vs2019" then
if cfg.allmodulespublic ~= nil then
m.element("AllProjectBMIsArePublic", nil, iif(cfg.allmodulespublic, "true", "false"))
end
end
end
function m.structMemberAlignment(cfg)

View File

@ -191,6 +191,12 @@
}
}
api.register {
name = "allmodulespublic",
scope = "config",
kind = "boolean"
}
api.register {
name = "configmap",
scope = "project",

View File

@ -171,7 +171,7 @@
end
function path.iscppfile(fname)
return path.hasextension(fname, { ".cc", ".cpp", ".cxx", ".c++" })
return path.hasextension(fname, { ".cc", ".cpp", ".cxx", ".c++", ".cppm", ".ixx" })
or path.isobjcppfile(fname) -- is this really right?
or path.iscfile(fname)
end

View File

@ -0,0 +1,27 @@
allmodulespublic
```lua
allmodulespublic "value"
```
### Parameters ###
`value` one of:
* `On` - All C++ modules in the given project(s) will be public.
* `Off` - Not all C++ modules in the given project(s) will be public.
## Applies To ###
The `config` scope.
### Availability ###
Visual Studio 2019 and later.
Premake 5.0-beta2 or later.
### Examples ###
```lua
allmodulespublic "On"
```

View File

@ -60,6 +60,7 @@ module.exports = {
type: 'category',
label: 'Project Settings',
items: [
'allmodulespublic',
'androidapilevel',
'androidapplibname',
'architecture',