summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-16 09:15:45 +0800
committerruki <[email protected]>2017-08-16 09:15:45 +0800
commit66299aec15e67cb7d96ecc580b29b3441b399dfa (patch)
treeddf4dde3dbab466b0f8a31897e064932a0106d9c
parentb92d83c523045d7e8b716dc0610b88b0d357575f (diff)
improve add_deps to add inherit config
-rw-r--r--CHANGELOG.md2
-rw-r--r--docs/manual.md8
-rw-r--r--docs/zh/manual.md8
-rw-r--r--xmake/core/project/target.lua20
-rw-r--r--xmake/core/tool/builder.lua7
5 files changed, 41 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2179dfca7..4a649a77d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
* Improve `add_files` to configure the compile option of the given files
* Inherit links and linkdirs from the dependent targets and options
+* Improve `target.add_deps` and add inherit config, .e.g `add_deps("test", {inherit = false})`
### Bugs fixed
@@ -336,6 +337,7 @@
* 改进`add_files`,支持对files粒度进行编译选项的各种配置,更加灵活。
* 从依赖的target和option中继承links和linkdirs。
+* 改进`target.add_deps`接口,添加继承配置,允许手动禁止依赖继承,例如:`add_deps("test", {inherit = false})`
### Bugs修复
diff --git a/docs/manual.md b/docs/manual.md
index ab45c5833..24cca0afe 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -1466,6 +1466,14 @@ target("test")
add_deps("library2")
```
+如果我们还是想以前那样,并不想继承依赖target的任何配置,如何操作呢?这个在2.1.6版本中也对其进行了支持,通过:
+
+```lua
+add_deps("dep1", "dep2", {inherit = false})
+```
+
+通过显示设置inherit配置,来告诉xmake,这两个依赖的配置是否需要被继承,如果不设置,默认就是启用继承的。
+
##### target:add_links
###### 添加链接库名
diff --git a/docs/zh/manual.md b/docs/zh/manual.md
index d7c26d154..11cb547cb 100644
--- a/docs/zh/manual.md
+++ b/docs/zh/manual.md
@@ -1483,6 +1483,14 @@ target("test")
add_deps("library2")
```
+如果我们还是想以前那样,并不想继承依赖target的任何配置,如何操作呢?这个在2.1.6版本中也对其进行了支持,通过:
+
+```lua
+add_deps("dep1", "dep2", {inherit = false})
+```
+
+通过显示设置inherit配置,来告诉xmake,这两个依赖的配置是否需要被继承,如果不设置,默认就是启用继承的。
+
##### target:add_links
###### 添加链接库名
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 4c78b56c3..762c131bd 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -151,7 +151,7 @@ function target:linkflags()
return self:linker():linkflags({target = self})
end
--- get the given dependent option
+-- get the given dependent target
function target:dep(name)
local deps = self:deps()
if deps then
@@ -169,6 +169,24 @@ function target:orderdeps()
return self._ORDERDEPS
end
+-- get the given dependent config
+function target:depconfig(name)
+
+ -- get deps config
+ --
+ -- .e.g {inherit = false}
+ --
+ local depsconfig = self._DEPSCONFIG
+ if not depsconfig then
+ depsconfig = {}
+ for depname, depconfig in pairs(table.wrap(self:get("__extra_deps"))) do
+ depsconfig[depname] = depconfig
+ end
+ self._DEPSCONFIG = depsconfig
+ end
+ return depsconfig[name]
+end
+
-- is phony target?
function target:isphony()
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index d67d407ce..7d02930f0 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -137,9 +137,10 @@ function builder:_inherit_from_targetdeps(results, target, flagname)
local dep = orderdeps[total + 1 - idx]
-- is static or shared target library? link it
- local depkind = dep:get("kind")
- local targetkind = target:get("kind")
- if depkind == "static" or depkind == "shared" then
+ local depkind = dep:get("kind")
+ local targetkind = target:get("kind")
+ local depconfig = table.wrap(target:depconfig(dep:name()))
+ if (depkind == "static" or depkind == "shared") and (depconfig.inherit == nil or depconfig.inherit) then
if flagname == "links" and (targetkind == "binary" or targetkind == "shared") then
-- add dependent link