Builds escripts for batamanta packaging.
This module handles the generation of escripts using mix escript.build
and provides utilities for locating and validating the generated output.
escript_path = EscriptBuilder.build(config, banner_ctx, erts_path)
Escripts are lightweight executables that embed the Elixir runtime directly, unlike releases which include the full OTP system.
| Aspect | Escript | Release |
|---|---|---|
| Size | ~15-30 MB | ~80-150 MB |
| Startup | Fast | Slower |
| Supervisor Tree | No | Yes |
| Daemon Mode | No | Yes |
| Hot Upgrades | No | Yes |
Use escripts when:
- Building CLI tools
- Size is critical
- No need for full OTP supervision
Use releases when:
- Building services
- Need supervisor trees
- Need distributed Erlang
Summary
Functions
Builds an escript using mix escript.build.
Finds the escript path in the build directory.
Gets the main module from escript configuration.
Checks if the project has valid escript configuration.
Validates that the escript is a valid executable.
Functions
Builds an escript using mix escript.build.
config- Mix project config (fromMix.Project.config())banner_ctx- Banner context for loggingerts_path- Path to the ERTS that will be embedded (for build consistency)
Path to the generated escript binary.
Finds the escript path in the build directory.
Escripts are generated by default at:
./<app_name>(in project root, default for CLI tools)
Or at a custom path if specified in the :escript config.
Gets the main module from escript configuration.
Returns nil if not configured.
Checks if the project has valid escript configuration.
Validates that the escript is a valid executable.
- File exists
- File is executable
- File is not empty
- File has shebang or is an ELF binary