From 7caece0cb3ee8ab207130edc17421d604610e686 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 9 Aug 2026 17:57:20 +0800 Subject: improve addon to import includes, rules and toolchains --- xmake/core/base/task.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'xmake/core/base/task.lua') diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index e8d2441b9..eeb2dd8f2 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -415,6 +415,8 @@ function task.tasks() -- load tasks local tasks = {} + local taskfiles = {} + local addondir = path.absolute(addon.installdir()) local dirs = task._directories() for _, dir in ipairs(dirs) do local files = os.files(path.join(dir, "*", "xmake.lua")) @@ -422,7 +424,19 @@ function task.tasks() for _, filepath in ipairs(files) do local results, errors = task._load(filepath) if results then - table.join2(tasks, results) + for taskname, taskinfo in pairs(results) do + -- the plugins are not namespaced, so we need to report the conflicts of the addons, + -- otherwise we do not know which plugin will be run + local taskfile = taskfiles[taskname] + if taskfile and (path.absolute(taskfile):startswith(addondir) or path.absolute(filepath):startswith(addondir)) then + -- @note we cannot raise errors here, otherwise all the commands will be broken, + -- and the user cannot even remove the conflicting addons + utils.warning("plugin(%s) conflicts, we will use the first one!\n -> %s\n -> %s", taskname, taskfile, filepath) + else + taskfiles[taskname] = filepath + tasks[taskname] = taskinfo + end + end else os.raise(errors) end -- cgit v1.3.1