summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-15 00:51:47 +0800
committerruki <[email protected]>2023-09-15 00:51:47 +0800
commite45896ac7e84dbaa88c708584f389d6eacc1dd53 (patch)
tree7b83f87269a17f2547da01765dfd52c2b6189a42
parentd5d4cdf20ad56f7c9d1f6b2cd8890d4097b1b742 (diff)
package as deps
-rw-r--r--xmake/actions/package/local/main.lua20
-rw-r--r--xmake/actions/package/remote/main.lua19
2 files changed, 39 insertions, 0 deletions
diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua
index 9b31d7d1f..90495dae4 100644
--- a/xmake/actions/package/local/main.lua
+++ b/xmake/actions/package/local/main.lua
@@ -156,9 +156,29 @@ function _package_library(target)
if target:license() then
file:print(" set_license(\"%s\")", target:license())
end
+ file:print("")
if #deps > 0 then
file:print(" add_deps(\"%s\")", table.concat(deps, "\", \""))
end
+ -- export packages as deps, @see https://github.com/xmake-io/xmake/issues/4202
+ local interface
+ if target:is_shared() then
+ interface = true
+ end
+ for _, pkg in ipairs(target:orderpkgs({interface = interface})) do
+ local requireconf_str
+ local requireconf = pkg:requireconf()
+ if requireconf then
+ local conf = table.clone(requireconf)
+ conf.alias = nil
+ requireconf_str = string.serialize(conf, {indent = false, strip = true})
+ end
+ if requireconf_str and requireconf_str ~= "{}" then
+ file:print(" add_deps(\"%s\", %s)", pkg:requirestr(), requireconf_str)
+ else
+ file:print(" add_deps(\"%s\")", pkg:requirestr())
+ end
+ end
file:print("")
file:print([[
add_configs("shared", {description = "Build shared library.", default = %s, type = "boolean", readonly = true})
diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua
index 47966ccf2..028c1f966 100644
--- a/xmake/actions/package/remote/main.lua
+++ b/xmake/actions/package/remote/main.lua
@@ -67,6 +67,25 @@ function _package_remote(target)
if #deps > 0 then
file:print(" add_deps(\"%s\")", table.concat(deps, "\", \""))
end
+ -- export packages as deps, @see https://github.com/xmake-io/xmake/issues/4202
+ local interface
+ if target:is_shared() then
+ interface = true
+ end
+ for _, pkg in ipairs(target:orderpkgs({interface = interface})) do
+ local requireconf_str
+ local requireconf = pkg:requireconf()
+ if requireconf then
+ local conf = table.clone(requireconf)
+ conf.alias = nil
+ requireconf_str = string.serialize(conf, {indent = false, strip = true})
+ end
+ if requireconf_str and requireconf_str ~= "{}" then
+ file:print(" add_deps(\"%s\", %s)", pkg:requirestr(), requireconf_str)
+ else
+ file:print(" add_deps(\"%s\")", pkg:requirestr())
+ end
+ end
file:print("")
local url = option.get("url") or "https://github.com/myrepo/foo.git"
local version = option.get("version") or target:version() and (target:version()) or "1.0"