Skip to content
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

Adding C++ module file extensions and implementing "allmodulespublic" #1790

Merged
merged 2 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions modules/vstudio/tests/vc2019/test_toolset_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 11 additions & 6 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
m.generateManifest,
m.extensionsToDeleteOnClean,
m.executablePath,
m.allModulesPublic,
}
end
end
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1506,11 +1507,15 @@
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")
end
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
Expand Down
6 changes: 6 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@
"HeaderUnit"
}
}

api.register {
name = "allmodulespublic",
scope = "config",
kind = "boolean"
}

api.register {
name = "configmap",
Expand Down
2 changes: 1 addition & 1 deletion src/base/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions website/docs/allmodulespublic.md
Original file line number Diff line number Diff line change
@@ -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"
```

1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
type: 'category',
label: 'Project Settings',
items: [
'allmodulespublic',
'androidapilevel',
'androidapplibname',
'architecture',
Expand Down