diff options
| author | ruki <[email protected]> | 2026-08-16 23:43:27 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-08-16 23:43:27 +0800 |
| commit | e180e51cfb91f59ea6b4912e4d7bc052f5ef5add (patch) | |
| tree | 637ba32123a35fbfec26a7b0c977a9c65b7e05fe /xmake/core/package/addon.lua | |
| parent | c3debec81c555e5b39c81c4e39e1b9737041a650 (diff) | |
| parent | d7fc1e30a747c0457b4f45194946fcff747c76db (diff) | |
Merge pull request #7714 from xmake-io/addon
move add_addons to xmake.lua
Diffstat (limited to 'xmake/core/package/addon.lua')
| -rw-r--r-- | xmake/core/package/addon.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua index 6e7d62eb4..e35a58317 100644 --- a/xmake/core/package/addon.lua +++ b/xmake/core/package/addon.lua @@ -566,6 +566,36 @@ function addon.globalmodules() return globalmodules end +-- find the include files of the given addon reference, e.g. includes("@addon/esp32/board") +-- +-- @param interp the interpreter which is loading the file, @see interpreter:includes_resolver_add +-- @param reference the reference, e.g. "@addon/esp32/board", "@self/board" +-- +-- @return the files, or nil and errors +-- +function addon.find_includes(interp, reference) + if not addon.is_reference(reference, "/") then + return + end + local referenceinfo, errors = addon.resolve_reference(reference, "/", "includes", {scriptdir = interp:scriptdir()}) + if not referenceinfo then + return nil, errors + end + local name = referenceinfo.name + local files + if name:endswith(".lua") then + files = os.files(path.join(referenceinfo.dir, name)) + else + files = os.files(path.join(referenceinfo.dir, name, "xmake.lua")) + end + + -- the addon is installed, but it does not provide this file, we cannot ignore it + if not files or #files == 0 then + os.raise("includes(%s) not found!", reference) + end + return files +end + -- get the payload directories of the given kind from all installed addons -- -- @param kind the payload kind, e.g. "plugins", "rules" |
