@@ -22,30 +22,18 @@ architectures, a reworked template distribution, and a `pkg` package manager for
2222An addon extends ** xmake itself** . Where a package provides libraries for your program, an
2323addon provides new abilities for the build tool.
2424
25- ``` sh
26- $ xmake addon --install esp32-devel
27- $ xmake create -t esp32.blink -l c blink
28- $ cd blink
29- $ xmake f --board=esp32c3
30- $ xmake
31- $ xmake install # flash it to the board
32- ```
33-
34- Those five lines are the whole ESP32 setup: the addon carried the cross toolchain, the build
35- rules, the flashing logic and the project template.
36-
3725#### What an addon can carry
3826
3927Every payload is optional, an addon ships only what it provides:
4028
4129| Payload | What it becomes | Used as |
4230| --- | --- | --- |
43- | ` plugins/ ` | a new xmake command | ` xmake monitor ` |
44- | ` rules/ ` | a build rule | ` add_rules("@addon/esp32-devel /app") ` |
45- | ` toolchains/ ` | a toolchain | ` set_toolchains("@addon/esp32-devel/esp32 ") ` |
46- | ` templates/ ` | a project template | ` xmake create -t esp32.blink ` |
47- | ` modules/ ` | importable lua modules | ` import("@addon.serial-tools.serial ") ` |
48- | ` includes/ ` | includable configuration | ` includes("@addon/esp32-devel /board") ` |
31+ | ` plugins/ ` | a new xmake command | ` xmake hello ` |
32+ | ` rules/ ` | a build rule | ` add_rules("@addon/my-addon /app") ` |
33+ | ` toolchains/ ` | a toolchain | ` set_toolchains("@addon/my-addon/mycc ") ` |
34+ | ` templates/ ` | a project template | ` xmake create -t myapp ` |
35+ | ` modules/ ` | importable lua modules | ` import("@addon.my-addon.utils ") ` |
36+ | ` includes/ ` | includable configuration | ` includes("@addon/my-addon /board") ` |
4937
5038The payloads are namespaced through ` @addon/<name>/... ` , so two addons never collide. Plugins
5139and templates are the exception — a command name is global — and an install which would
@@ -54,14 +42,14 @@ shadow another addon's command is rejected.
5442#### Managing addons
5543
5644``` sh
57- $ xmake addon --install esp32-devel # from the repository index
58- $ xmake addon --install github:xmake-addons/esp32-devel # from github, `#branch` works too
45+ $ xmake addon --install my-addon # from the repository index
46+ $ xmake addon --install github:myrepo/my-addon # from github, `#branch` works too
5947$ xmake addon --install https://github.com/user/repo.git # from any git url
6048$ xmake addon --install /path/to/my-addon # from a local directory
6149
6250$ xmake addon --list
63- $ xmake addon --search esp32
64- $ xmake addon --remove esp32-devel
51+ $ xmake addon --search my
52+ $ xmake addon --remove my-addon
6553$ xmake addon --upgrade
6654```
6755
@@ -71,12 +59,12 @@ A project can declare what it needs, so a fresh clone does not have to install a
7159hand — xmake fetches the missing addons when the project is loaded:
7260
7361``` lua
74- add_addons (" esp32-devel 1.0.x" )
62+ add_addons (" my-addon 1.0.x" )
7563
76- includes (" @addon/esp32-devel /board" )
64+ includes (" @addon/my-addon /board" )
7765
78- target (" blink " )
79- add_rules (" @addon/esp32-devel /app" )
66+ target (" hello " )
67+ add_rules (" @addon/my-addon /app" )
8068 add_files (" src/*.c" )
8169```
8270
@@ -153,7 +141,7 @@ Three places, a handful of interfaces:
153141
154142``` lua
155143-- 1. in xmake.lua, what a project needs
156- add_addons (" esp32-devel 1.0.x" )
144+ add_addons (" my-addon 1.0.x" )
157145```
158146
159147``` lua
@@ -164,7 +152,7 @@ addon("my-addon")
164152 set_license (" Apache-2.0" )
165153 set_sourcedir (" src" ) -- the payload root inside the repository
166154 add_deps (" serial-tools" ) -- other addons this one needs
167- add_globalmodules (" detect.tools.find_avrdude " ) -- only for the lookups xmake does by name
155+ add_globalmodules (" detect.tools.find_mytool " ) -- only for the lookups xmake does by name
168156```
169157
170158``` lua
@@ -206,10 +194,10 @@ carries the package recipes and exposes them through an includes file:
206194
207195``` lua
208196-- src/includes/packages/xmake.lua
209- package (" avr-gcc " )
197+ package (" mycc " )
210198 set_kind (" toolchain" )
211- add_urls (" https://.../avr-gcc- $(version).tar.bz2 " )
212- add_versions (" 7.3 .0" , " <sha256>" )
199+ add_urls (" https://.../mycc- $(version).tar.gz " )
200+ add_versions (" 1.0 .0" , " <sha256>" )
213201 on_install (function (package )
214202 os .cp (" *" , package :installdir ())
215203 end )
@@ -219,11 +207,11 @@ package_end()
219207``` lua
220208-- src/includes/board/xmake.lua
221209includes (" ../packages" )
222- option (" board" , {default = " uno " , description = " Set the target board." })
223- add_requires (" avr-gcc " , " avrdude " )
210+ option (" board" , {default = " myboard " , description = " Set the target board." })
211+ add_requires (" mycc " , " myflasher " )
224212```
225213
226- The project writes one line — ` includes("@addon/avr-devel /board") ` — and gets the options,
214+ The project writes one line — ` includes("@addon/my-addon /board") ` — and gets the options,
227215the toolchain and the flash tool.
228216
229217#### The official addons
@@ -240,6 +228,18 @@ The first batch is already in xmake-repo:
240228| ` format-plugin ` / ` doxygen-plugin ` / ` macro-plugin ` | the former builtin commands |
241229| ` basic-templates ` | the templates which need an external sdk (sdl, qt, verilator) |
242230
231+ ` esp32-devel ` , for instance, carries the cross toolchain, the build rules, the flashing logic
232+ and the project template, so the whole ESP32 setup is:
233+
234+ ``` sh
235+ $ xmake addon --install esp32-devel
236+ $ xmake create -t esp32.blink -l c blink
237+ $ cd blink
238+ $ xmake f --board=esp32c3
239+ $ xmake
240+ $ xmake install # flash it to the board
241+ ```
242+
243243### xmake ai, an Agent Written in Xmake Lua
244244
245245[ xmake-harness] ( https://github.com/xmake-addons/xmake-harness ) is the addon that shows how far
@@ -375,8 +375,8 @@ New architectures for the cross and linux platforms, e.g. SPARC64.
375375### Reworked Template Distribution
376376
377377The templates directory was reorganized and the distribution reworked, which is what makes the
378- ` templates/ ` payload of an addon possible — ` xmake create -t esp32.blink ` comes from an addon,
379- not from the xmake installation.
378+ ` templates/ ` payload of an addon possible — the templates behind ` xmake create -t ` can now come
379+ from an addon instead of being built into the xmake installation.
380380
381381### pkg Package Manager for BSD
382382
0 commit comments