summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-11-27 00:43:26 +0800
committerruki <[email protected]>2018-11-26 22:20:36 +0800
commitb01f8aea133afbd401ee93b694f32828cc4a4f0c (patch)
tree4777137be952e460b65d36b19fa3edd5be577521
parent6c56467b2938a414f62311133fe8a0edb3aaa5c6 (diff)
add package extra config info
-rw-r--r--xmake/core/project/project.lua5
-rw-r--r--xmake/core/project/target.lua8
-rw-r--r--xmake/core/tool/builder.lua23
3 files changed, 25 insertions, 11 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 502a5b6cf..b2e102833 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -536,11 +536,6 @@ function project._load_requires()
instance._INFO = { __requirestr = requirestr, __extrainfo = extrainfo }
end
- -- need not links? remove it
- if instance:extra("nolink") then
- instance:set("links", nil)
- end
-
-- add require info
requires[alias or packagename] = instance
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 986aaf56c..908f55ad5 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -543,6 +543,14 @@ function target:packages()
return self._PACKAGES_ENABLED
end
+-- get the config info of the given package
+function target:pkgconfig(pkgname)
+ local extra_packages = self:get("__extra_packages")
+ if extra_packages then
+ return extra_packages[pkgname]
+ end
+end
+
-- get the object files directory
function target:objectdir(onlyroot)
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index bc6d16aa4..653f7cbe1 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -115,6 +115,21 @@ function builder:_flagkinds()
return self._FLAGKINDS
end
+-- inherts from target packages
+function builder:_inherit_from_targetpkgs(values, target, name)
+ for _, pkg in ipairs(target:packages()) do
+ -- uses them instead of the builtin configs if exists extra package config
+ -- e.g. `add_packages("xxx", {links = "xxx"})`
+ local configinfo = target:pkgconfig(pkg:name())
+ if configinfo and configinfo[name] then
+ table.join2(values, configinfo[name])
+ else
+ -- uses the builtin package configs
+ table.join2(values, pkg:get(name))
+ end
+ end
+end
+
-- inherts from target deps
function builder:_inherit_from_target(values, target, name)
table.join2(values, target:get(name))
@@ -122,9 +137,7 @@ function builder:_inherit_from_target(values, target, name)
for _, opt in ipairs(target:options()) do
table.join2(values, opt:get(name))
end
- for _, opt in ipairs(target:packages()) do
- table.join2(values, opt:get(name))
- end
+ self:_inherit_from_targetpkgs(values, target, name)
end
end
@@ -333,9 +346,7 @@ function builder:_addflags_from_language(flags, target, getters)
for _, opt in ipairs(target:options()) do
table.join2(results, table.wrap(opt:get(name)))
end
- for _, pkg in ipairs(target:packages()) do
- table.join2(results, table.wrap(pkg:get(name)))
- end
+ self:_inherit_from_targetpkgs(results, target, name)
-- is option? get flagvalues of option with given flagname
elseif target:type() == "option" then