Skip to content

Commit da31bd3

Browse files
committed
Add escriptize provider
Requires support for AtomVM: atomvm/AtomVM#1948 NB: it's currently incompatible with JIT Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent d687c9f commit da31bd3

File tree

10 files changed

+638
-3
lines changed

10 files changed

+638
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Added dialyzer task to simplify running dialyzer on AtomVM applications.
2121
- Added support for rp2350 devices to allow for default detection of the device mount path.
2222
- Added configuration paramenter for setting the path to picotool for the pico_flash task.
23+
- Added escriptize task to build escriptize-like bundled binaries with AtomVM.
2324

2425
### Changed
2526
- The `uf2create` task now creates `universal` format uf2 files by default, suitable for both

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ The [`rebar3`](https://rebar3.org) plugin provides the following tasks under the
6969
* `version` Print the version of the [`atomvm_rebar3_plugin`](https://atomvm.github.io/atomvm_rebar3_plugin) to the console.
7070
* `bootstrap` Compile Erlang files that `rebar3` otherwise cannot compile. Typically, such files include modules from the OTP `kernel` or `stdlib` application that `rebar3` uses internally for its own implementation.
7171
* `dialyzer` Use dialyzer for static analysis of AtomVM applications.
72+
* `escriptize` Generate a standalone binary for the current host, using AtomVM.
7273

7374
> IMPORTANT! Some of the above tasks were previously located under the default [`rebar3`](https://rebar3.org) namespace; however, the commands under the default namespace have been DEPRECATED. Users will get a warning message on the console when using deprecated tasks, and any deprecated tasks may be removed in the future without warning. Be sure to migrate any scripts or code you have to use the `atomvm` namespace.
7475
@@ -615,7 +616,29 @@ Example:
615616

616617
Any setting specified on the command line take precedence over entries in `rebar.config`, which in turn take precedence over the default values specified above.
617618

619+
### The `escriptize` task
618620

621+
Use the `escriptize` task to generate a standalone binary combining AtomVM virtual machine and the application. The binary can then be copied to another host with the same architecture and would work provided that mbedtls and zlib are installed.
622+
623+
To use this task, you need to define a module that exports a `main/1` function, following `rebar3` `escriptize` command. This function is invoked with the command line parameters, as strings.
624+
625+
`-spec main(Args :: [string()]) -> ok | 0 | any().`
626+
627+
If the function returns ok or 0, the `main` entry point will return 0 as its exit code. Otherwise, it will return 1. Please note that AtomVM does not implement `erlang:halt/1` as of this writing.
628+
629+
The module that exports this `main/1` function should be declared in `rebar.config` file with either:
630+
- `start` option of `packbeam` task (see above):
631+
```
632+
{atomvm_rebar3_plugin, [{packbeam, [{start, main_module}]}]}.`
633+
```
634+
- `rebar3` standard `escript_name`:
635+
```
636+
{escript_name, main_module}.
637+
```
638+
- `rebar3` standard `escript_main_app` which `escript_name` defaults to:
639+
```
640+
{escript_main_app, main_module}.
641+
```
619642

620643
## AtomVM App Template
621644

0 commit comments

Comments
 (0)