Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve add_requires #5727 #5736

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions xmake/modules/private/action/require/impl/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading