summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-10 22:34:14 +0800
committerruki <[email protected]>2024-01-10 22:34:14 +0800
commit9275a5f00ba06e300d8472f5cb6590327173f2ed (patch)
tree525996e80b2ffc4a5eed912258f4ad5a27928a25
parenteb90591a3962ae0d03115577b3b60bf9f376e606 (diff)
improve extraconf_from order
-rw-r--r--tests/apis/target_get_from/xmake.lua2
-rw-r--r--xmake/core/project/target.lua18
-rw-r--r--xmake/core/tool/builder.lua2
3 files changed, 14 insertions, 8 deletions
diff --git a/tests/apis/target_get_from/xmake.lua b/tests/apis/target_get_from/xmake.lua
index 5e77a0382..8d66c4681 100644
--- a/tests/apis/target_get_from/xmake.lua
+++ b/tests/apis/target_get_from/xmake.lua
@@ -28,6 +28,6 @@ target("test")
print("dep::foo/option::*", target:get_from("defines", "dep::foo/option::*"))
print("*", target:get_from("defines", "*"))
print("package::zlib", target:get_from("links", "package::zlib"))
- print("extraconf(dep::foo)", target:extraconf_from("dep::foo", "linkgroups"))
+ print("extraconf(dep::foo)", target:extraconf_from("linkgroups", "dep::foo"))
end)
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 569502e51..f4cdafb0e 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -741,10 +741,16 @@ end
-- target:extraconf_from("links", "dep::foo/option::bar")
-- target:extraconf_from("links", "dep::foo/package::bar")
--
-function _instance:extraconf_from(source, name, item, key)
+function _instance:extraconf_from(name, source)
+ if name:find("::") then
+ local tmp = name
+ name = source
+ source = tmp
+ utils.warning("please use target:extraconf_from(%s, %s) intead of target:extraconf_from(%s, %s)", name, source, source, name)
+ end
source = source or "self"
if source == "self" then
- return self:extraconf(name, item, key)
+ return self:extraconf(name)
elseif source:startswith("dep::") then
local depname = source:split("::", {plain = true, limit = 2})[2]
local depsource
@@ -759,23 +765,23 @@ function _instance:extraconf_from(source, name, item, key)
-- dep::foo/option::bar
-- dep::foo/package::bar
if depsource then
- return dep:extraconf_from(dep_source, name, item, key)
+ return dep:extraconf_from(name, dep_source)
else
-- dep::foo
- return dep:extraconf(name, item, key)
+ return dep:extraconf(name)
end
end
elseif source:startswith("option::") then
local optname = source:split("::", {plain = true, limit = 2})[2]
local opt_ = self:opt(optname, opt)
if opt_ then
- return opt_:extraconf(name, item, key)
+ return opt_:extraconf(name)
end
elseif source:startswith("package::") then
local pkgname = source:split("::", {plain = true, limit = 2})[2]
local pkg = self:pkg(pkgname, opt)
if pkg then
- return pkg:extraconf(name, item, key)
+ return pkg:extraconf(name)
end
else
os.raise("target:extraconf_from(): unknown source %s", source)
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index cfd3d19cf..255b69ca1 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -391,7 +391,7 @@ function builder:_add_items_from_target(items, name, opt)
if result then
for idx, values in ipairs(result) do
local source = sources[idx]
- local extras = target:extraconf_from(source, name)
+ local extras = target:extraconf_from(name, source)
values = table.wrap(values)
if values and #values > 0 then
table.insert(items, {