Skip to content

Addons Introduction

An addon extends xmake itself. Where a package provides libraries for your program, an addon provides new abilities for the build tool: commands, build rules, toolchains, project templates and lua modules.

NOTE

Addons require xmake from the dev branch for now. Before them, only plugins could be distributed, through the older xmake plugin --install.

What an addon can carry

An addon ships one or more payloads, and every one of them is optional:

PayloadWhat it becomesUsed as
plugins/a new xmake commandxmake monitor
rules/a build ruleadd_rules("@addon/esp32-devel/app")
toolchains/a toolchainset_toolchains("@addon/esp32-devel/esp32")
templates/a project templatexmake create -t esp32.blink
modules/importable lua modulesimport("@addon.serial-tools.serial")
includes/includable configurationincludes("@addon/esp32-devel/board")

So one addon can be a complete development kit: the esp32-devel addon carries the cross toolchain, the build rules, the flashing logic and a blink template — installing it turns xmake into an ESP32 SDK.

Architecture

                       xmake-repo                     github / local dir
                     addons/e/esp32-devel/xmake.lua   github:user/my-addon

                     xmake addon --install <name>

     ~/.xmake/addons/<name>/<version>/{plugins,rules,toolchains,templates,modules,includes}
     ~/.xmake/addons/addons.conf     ← the registry xmake reads on startup

                    a project references the payloads it needs
             add_addons("esp32-devel")  +  @addon/esp32-devel/app

Three properties follow from this layout:

Installed once, per user. An addon lives in ~/.xmake/addons, not in the project. Several projects share the same installation, and the registry file means xmake does not scan the directory on every run.

Payloads are namespaced. Rules, toolchains, includes and modules are always referenced through @addon/<name>/..., so two addons never collide. Plugins and templates are the exception — a command name is global, so xmake rejects an install which would shadow another addon's command.

An addon names itself. The addon.lua manifest in the addon repository declares its name, description and payload root, so the name never depends on the repository or on the package that distributes it.

lua
-- addon.lua
addon("esp32-devel")
    set_homepage("https://github.com/xmake-addons/esp32-devel")
    set_description("The ESP32 development addon.")
    set_license("Apache-2.0")
    set_sourcedir("src")
    add_deps("serial-tools")

Addons vs plugins vs packages

Installed withLives inExtends
Packageadd_requires / xrepo install~/.xmake/packagesyour program (libs, headers, tools)
Plugin (legacy)xmake plugin --install~/.xmake/pluginsxmake, commands only
Addonxmake addon --install / add_addons~/.xmake/addonsxmake, all payload kinds

An addon is distributed as a package with set_kind("addon"), so it reuses the whole package infrastructure: repositories, versions, sha256 verification, dependencies and the xrepo download logic.

Next