diff options
| author | ruki <[email protected]> | 2026-08-23 23:24:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-08-23 23:24:43 +0800 |
| commit | ca2386b06786ac86fa11d75fb7459358b46ad6ba (patch) | |
| tree | 6f4a095780fd3ac14804b8774d74809211bbfe3a | |
| parent | 05b1ec467142a02aad0304f1361c2b59491fffcd (diff) | |
| parent | 6307b3ced2ac468ba10ca8e26968281bb3bbdc11 (diff) | |
Merge pull request #7733 from xmake-io/addon
Check conflict for addon modules
| -rw-r--r-- | xmake/core/package/addon.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua index e35a58317..d6798f56f 100644 --- a/xmake/core/package/addon.lua +++ b/xmake/core/package/addon.lua @@ -168,12 +168,19 @@ function addon._check_conflicts(dirname, addoninfo) end -- the global modules can also conflict with the builtin and the user modules + -- + -- @note the `core.*` modules are in the core directory of the sandbox, + -- they are not in `<programdir>/modules`, + -- @see core/sandbox/modules/import/core/sandbox/module.lua + local moduledirs = {path.join(os.programdir(), "modules"), + path.join(os.programdir(), "core", "sandbox", "modules", "import"), + path.join(global.directory(), "modules")} for _, name in ipairs(addoninfo.globalmodules or {}) do local modulepath = (name:gsub("%.", "/")) .. ".lua" - for _, moduledir in ipairs({os.programdir(), global.directory()}) do - if os.isfile(path.join(moduledir, "modules", modulepath)) then + for _, moduledir in ipairs(moduledirs) do + if os.isfile(path.join(moduledir, modulepath)) then return string.format("global module(%s) conflicts, it has been provided by %s!\nplease rename it in the addon manifest.", - name, moduledir == os.programdir() and "xmake" or path.join(moduledir, "modules")) + name, moduledir:startswith(os.programdir()) and "xmake" or moduledir) end end end |
