summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl/package.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/private/action/require/impl/package.lua')
-rw-r--r--xmake/modules/private/action/require/impl/package.lua37
1 files changed, 31 insertions, 6 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index c3998c728..1105384c8 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -198,7 +198,7 @@ end
-- - plat: the given platform of this package
-- - arch: the given architecture of this package
-- - name: the given repository name, we will only find this package in the given repository
--- - rootdir: the root directory of repositories, e.g. "packages" (default), "plugins"
+-- - rootdir: the root directory of repositories, e.g. "packages" (default), "addons"
-- - locked_repo: the locked repository info in `xmake-requires.lock`, e.g. {url = .., commit = .., branch = ..}
--
function _load_package_from_repository(packagename, opt)
@@ -209,6 +209,23 @@ function _load_package_from_repository(packagename, opt)
end
end
+-- get the root directory of repositories for the given package
+--
+-- e.g. "packages" (default), "addons", "plugins" (deprecated)
+--
+-- @note the addon packages are only searched from the `addons` root directory,
+-- and we need to set it explicitly, e.g. add_deps("foo", {kind = "addon"})
+--
+function _get_repository_rootdir(requireinfo, opt)
+ local packagekind = requireinfo.kind or opt.packagekind
+ if packagekind == "addon" then
+ return "addons"
+ elseif packagekind == "plugin" then
+ return "plugins"
+ end
+ return "packages"
+end
+
-- load package package from base
--
-- e.g. package("foo") set_base("bar")
@@ -956,7 +973,7 @@ end
-- @param opt the options
-- - system: load package from system if `true`, and never load it if `false`,
-- it's only used when `add_requires("zlib", {system = nil})` is not set (only for non-3rd packages)
--- - packagekind: the package kind, e.g. "plugin", it will be loaded from the `plugins` root directory of repositories
+-- - packagekind: the package kind, e.g. "addon", it will be loaded from the `addons` root directory of repositories
-- - toolchain: only load toolchain packages, the non-toolchain toplevel packages will be ignored
-- - requirepath: the current require path, e.g. "foo.bar", it's used to detect circular dependencies
-- and match `add_requireconfs()`
@@ -969,6 +986,12 @@ function _load_package(packagename, requireinfo, opt)
-- check circular dependency
opt = opt or {}
+
+ -- the `addon` and `self` names are reserved, we use them to reference the addon resources,
+ -- e.g. add_rules("@addon/esp32/flash"), import("@self.sdkconfig")
+ if packagename == "addon" or packagename == "self" then
+ raise("package(%s): the name `%s` is reserved by xmake for the addon references, please rename it!", packagename, packagename)
+ end
if opt.requirepath then
local splitinfo = opt.requirepath:split(".", {plain = true})
if #splitinfo > 3 and
@@ -1014,7 +1037,7 @@ function _load_package(packagename, requireinfo, opt)
plat = requireinfo.plat,
arch = requireinfo.arch,
name = requireinfo.reponame,
- rootdir = opt.packagekind == "plugin" and "plugins" or "packages",
+ rootdir = _get_repository_rootdir(requireinfo, opt),
locked_repo = locked_requireinfo and locked_requireinfo.repo})
if package then
from_repo = true
@@ -1025,7 +1048,7 @@ function _load_package(packagename, requireinfo, opt)
if package and package:get("base") then
_load_package_from_base(package, package:get("base"), {
name = requireinfo.reponame,
- rootdir = opt.packagekind == "plugin" and "plugins" or "packages",
+ rootdir = _get_repository_rootdir(requireinfo, opt),
locked_repo = locked_requireinfo and locked_requireinfo.repo})
end
@@ -1211,7 +1234,6 @@ function _load_packages(requires, opt)
parentinfo = requireinfo,
nodeps = opt.nodeps,
resolvedinfo = opt.resolvedinfo,
- packagekind = opt.packagekind,
system = false})
for _, dep in ipairs(plaindeps) do
dep:parents_add(package)
@@ -1680,6 +1702,9 @@ function get_configs_str(package)
end
if requireinfo.kind then
table.insert(configs, requireinfo.kind)
+ elseif package:is_addon() then
+ -- @note the kind is only set for the dependencies, e.g. add_deps("foo", {kind = "addon"})
+ table.insert(configs, "addon")
end
local ignored_configs_for_buildhash = hashset.from(requireinfo.ignored_configs_for_buildhash or {})
local configs_overrided = requireinfo.configs_overrided or {}
@@ -1765,7 +1790,7 @@ end
-- - requires_extra: the extra require configs from `add_requires()`, e.g. {["zlib >=1.2.11"] = {configs = {shared = true}}}
-- - nodeps: only load the given packages, do not load their dependent packages
-- - system: load package from system if `true`, and never load it if `false` (only for non-3rd packages)
--- - packagekind: the package kind, e.g. "plugin", it will be loaded from the `plugins` root directory of repositories
+-- - packagekind: the package kind, e.g. "addon", it will be loaded from the `addons` root directory of repositories
-- - toolchain: only load toolchain packages and their dependent packages
-- - requirepath: the parent require path, e.g. "foo.bar", it's used to detect circular dependencies and match `add_requireconfs()`
-- - parentinfo: the parent requireinfo, the child package will inherit some builtin configs from it, e.g. runtimes, pic