summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require
diff options
context:
space:
mode:
authorruki <[email protected]>2024-10-19 21:50:33 +0800
committerGitHub <[email protected]>2024-10-19 21:50:33 +0800
commitfc14af5094d4ea41f96b01c19cc6fcb71bf79b5f (patch)
tree09f3005a870f97c4a389e71360c380ab743ec872 /xmake/modules/private/action/require
parent86627f20f80a50fece956b4e8394afc4b5a83cd1 (diff)
parent4d8f21ac73053661c26aac2db376517ae0890340 (diff)
Merge pull request #5736 from xmake-io/requires
improve add_requires #5727
Diffstat (limited to 'xmake/modules/private/action/require')
-rw-r--r--xmake/modules/private/action/require/impl/package.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 5fc10ee0e..86df86bfb 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -85,6 +85,10 @@ end
--
-- {build = true}: always build packages, we do not use the precompiled artifacts
--
+-- simply configs as string:
+-- add_requires("boost[iostreams,system,thread,key=value] >=1.78.0")
+-- add_requires("boost[iostreams,thread=n] >=1.78.0")
+--
function _parse_require(require_str)
-- split package and version info
@@ -144,6 +148,30 @@ function _load_require(require_str, requires_extra, parentinfo)
require_extra = requires_extra[require_str] or {}
end
+ -- parse configs from package name
+ -- @see https://github.com/xmake-io/xmake/issues/5727#issuecomment-2421040107
+ --
+ -- e.g.
+ -- add_requires("boost[iostreams,system,thread,key=value] >=1.78.0")
+ --
+ local packagename_raw, configs_str = packagename:match("(.+)%[(.+)%]")
+ if packagename_raw and configs_str then
+ packagename = packagename_raw
+ local splitinfo = configs_str:split(",", {plain = true})
+ for _, v in ipairs(splitinfo) do
+ local parts = v:split("=", {plain = true})
+ local k = parts[1]
+ v = parts[2]
+ require_extra.configs = require_extra.configs or {}
+ local configs = require_extra.configs
+ if v then
+ configs[k] = option.boolean(v)
+ else
+ configs[k] = true
+ end
+ end
+ end
+
-- get required building configurations
-- we need to clone a new configs object, because the whole requireinfo will be modified later.
-- @see https://github.com/xmake-io/xmake-repo/pull/2067