Skip to content

Commit acc7e05

Browse files
committed
Update documentation with --lib option
Adds documentation for the newly added `lib` option for both cli and api usage. Signed-off-by: Winford <winford@object.stream>
1 parent a2f9479 commit acc7e05

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ On-line help is available via the `help` sub-command:
8282
[<input-file>]+ is a list of one or more input files,
8383
and <options> are among the following:
8484
[--prune|-p] Prune dependencies
85+
[--lib|-l] Create a library avm, with no start module
8586
[--start|-s <module>] Start module
8687
[--remove_lines|-r] Remove line number information from AVM files
8788

@@ -135,11 +136,21 @@ Note that beam files specified are stripped of their path information, inside of
135136

136137
#### Start Entrypoint
137138

138-
If you are building an application that provides a start entrypoint (as opposed to a library, suitable for inclusion in another AVM file), then at least one beam module in an AVM file must contain a `start/0` entry-point, i.e., a function called `start` with arity 0. AtomVM will use this entry-point as the first function to execute, when starting.
139+
If you are building an application that provides a start entrypoint (as opposed to a library,
140+
suitable for inclusion in another AVM file), then at least one beam module in an AVM file must
141+
contain a `start/0` (i.e., a function called `start` with arity 0) or `main/1` entry-point. AtomVM
142+
will use this entry-point as the first function to execute, when starting.
139143

140-
> Note. It is conventional, but not required, that the first beam file in an AVM file contains the `start/0` entry-point. AtomVM will use the first BEAM file that contains an exported `start/0` function as the entry-point for the application.
144+
When explicitly setting the `--start` module no other module will be tagged as an entrypoint, even
145+
if multiple modules export `start/0`.
141146

142-
If your application has multiple modules with exported `start/0` functions, you may use the `--start <module>` (alternatively, `-s <module>`) option to specify the module you would like placed first in your AVM file. The `<module>` parameter should be the module name (without the `.beam` suffix, e.g., `main`).
147+
> Note. It is conventional, but not required, that the first beam file in an AVM file contains the
148+
`start/0` entry-point.
149+
150+
If your application has multiple modules with exported `start/0` functions, or you are creating an
151+
escript with a `main/1`, you may use the `--start <module>` (alternatively, `-s <module>`) option
152+
to specify the entrypoint module. The `<module>` parameter should be the module name (without the
153+
`.beam` suffix, e.g., `main`).
143154

144155
A previously created AVM file file may be supplied as input (including the same file specified as output, for example). The contents of any input AVM files will be included in the output AVM file. For example, if you are building a library of BEAM files (for example, none of which contain a `start/0` entry-point), you may want to archive these into an AVM file, which can be used for downstream applications.
145156

@@ -149,6 +160,12 @@ In addition, you may specify a "normal" (i.e., non-beam or non-AVM) file. Norma
149160

150161
> Note. It is conventional in AtomVM for normal files to have the path `<module-name>/priv/<file-name>`.
151162
163+
#### Creating Libraries
164+
165+
Libraries can be packed using the `--lib` (alternatively, `-l`) option. This will create a packed
166+
avm archive without auto selecting a start module, even if one or more of the included modules
167+
export `start/0`.
168+
152169
#### Pruning
153170

154171
If you specify the `--prune` (alternatively, `-p`) flag, then `packbeam` will only include beam files that are transitively dependent on the entry-point beam. Transitive dependencies are determined by imports, as well as use of an atom in a module (e.g, as the result of a dynamic function call, based on a module name).
@@ -241,6 +258,7 @@ Alternatively, you may specify a set of options with the `packbeam_api:create/3`
241258
| Key | Type | Default | Description |
242259
|-----|------|---------|-------------|
243260
| `prune` | `boolean()` | `false` | Specify whether to prune the output AVM file. Pruned AVM files can take considerably less space and hence may lead to faster development times. |
261+
| `lib` | `boolean()` | `false` | Create a library (no entrypoint) |
244262
| `start` | `module()` | n/a | Specify the start module, if it can't be determined automatically from the application. |
245263
| `application` | `module()` | n/a | Specify the application module. The `<application>.app` file will be encoded and included as an element in the AVM file with the path `<module>/priv/application.bin` |
246264
| `include_lines` | `boolean()` | `true` | Specify whether to include line number information in generated AVM files. |

0 commit comments

Comments
 (0)