diff options
| author | ruki <[email protected]> | 2023-10-24 22:40:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-10-24 22:40:36 +0800 |
| commit | 8d0e4717a14cd460428cc4d294bb1ae4dd100f6f (patch) | |
| tree | d116a97f656deb53bc6f4a18b8e1d2c8740cfec3 /xmake/core/project/package.lua | |
| parent | 795272da127f97058d2d061e32ace82a8c2ff009 (diff) | |
fetch extras
Diffstat (limited to 'xmake/core/project/package.lua')
| -rw-r--r-- | xmake/core/project/package.lua | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua index 0e16a7e1b..cf372022f 100644 --- a/xmake/core/project/package.lua +++ b/xmake/core/project/package.lua @@ -161,23 +161,56 @@ function _instance:components_deps() return self:get("__components_deps") end --- get other extra information from package/on_fetch +-- get user extra configuration from package/on_fetch +-- @see https://github.com/xmake-io/xmake/issues/3106#issuecomment-1330143922 -- -- e.g. -- -- @code -- package("xxx") -- on_fetch(function (package) --- return {includedirs = "", links = "", extra = {foo = ""}} +-- return {includedirs = "", links = "", extras = {foo = ""}} -- end) -- -- @endcode -function _instance:extra(name) - local extra = self:get("extra") - if extra and name then - extra = extra[name] +-- +-- we can also get extra configuration from package/add_xxx +-- +-- e.g. +-- +-- @code +-- package("xxx") +-- add_linkgroups("foo", {group = true}) +-- +-- target:pkg("xxx"):extraconf("linkgroups", "foo", "group") +-- @endcode +-- +-- extras = { +-- linkgroups = { +-- z = { +-- group = true +-- } +-- } +-- } +-- +function _instance:extraconf(name, item, key) + local extraconfs = self:get("extras") + if not extraconfs then + return end - return extra + + -- get configuration + local extraconf = extraconfs[name] + + -- get configuration value + local value = extraconf + if item then + value = extraconf and extraconf[item] or nil + if value and key then + value = value[key] + end + end + return value end -- get order dependencies of the given component |
