Skip to content

Commit

Permalink
Merge pull request #1809 from hannes-harnisch/inheritdependencies
Browse files Browse the repository at this point in the history
Feature for disabling inherited dependencies
  • Loading branch information
samsinsane authored Feb 22, 2022
2 parents 7deba66 + 827d07c commit 1cd78b4
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 5 deletions.
33 changes: 31 additions & 2 deletions modules/vstudio/tests/vc2010/test_link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@
]]
end

--
--
-- Test ignoring default libraries with extensions specified.
--

Expand All @@ -737,4 +737,33 @@
<AssemblyDebug>true</AssemblyDebug>
</Link>
]]
end
end

--
-- Test for not including additional dependencies.
--

function suite.inheritDependenciesOff()
inheritdependencies "Off"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies></AdditionalDependencies>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end

function suite.inheritDependenciesOn()
inheritdependencies "On"
links { "kernel32" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end
15 changes: 12 additions & 3 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1422,9 +1422,18 @@
links = vstudio.getLinks(cfg, explicit)
end

if #links > 0 then
links = path.translate(table.concat(links, ";"))
m.element("AdditionalDependencies", nil, "%s;%%(AdditionalDependencies)", links)
links = path.translate(table.concat(links, ";"))

local additional = ";%(AdditionalDependencies)"
if cfg.inheritdependencies ~= nil then
if not cfg.inheritdependencies then
additional = ""
end
end

-- If there are no links and dependencies should be inherited, the tag doesn't have to be generated.
if #links > 0 or additional == "" then
m.element("AdditionalDependencies", nil, "%s%s", links, additional)
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 @@ -644,6 +644,12 @@
tokens = true,
}

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

api.register {
name = "icon",
scope = "project",
Expand Down
29 changes: 29 additions & 0 deletions website/docs/inheritdependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
inheritdependencies

```lua
inheritdependencies "value"
```

For Visual Studio project files, this controls the generation of the `%(AdditionalDependencies)` entry in the list of libraries that a project links.

### Parameters ###

`value` one of:
* `On` - The project(s) will inherit library dependencies based on the parent project (if any) and project default settings. This is the default behavior.
* `Off` - The project(s) will not inherit any library dependencies. Only explicitly specified dependencies will be linked.

## Applies To ###

The `config` scope.

### Availability ###

Visual Studio 2015 and later.
Premake 5.0-beta2 or later.

### Examples ###

```lua
inheritdependencies "Off"
```

1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ module.exports = {
'implibsuffix',
'importdirs',
'includedirs',
'inheritdependencies',
'inlinesvisibility',
'inlining',
'intrinsics',
Expand Down

0 comments on commit 1cd78b4

Please sign in to comment.