mix batamanta (batamanta v1.5.0)

Copy Markdown View Source

Main Mix task to generate the monolithic binary.

This task orchestrates the fetching of ERTS, packaging of the release/escript, and compilation of the Rust wrapper.

Batamanta supports two output formats:

  • :release (default) - Full OTP release with supervisor tree
  • :escript - Lightweight escript with embedded Elixir runtime

For projects using mix escript.build, use:

batamanta: [
  format: :escript
]

User specifies, user owns. If you specify otp_version, that exact version is used. If not specified (auto mode), a conservative fallback is used.

batamanta: [
]

In auto mode (no version specified), the system tries:

  • 28.0 → 28.1 → 28.2 → ... (fallback to first available)

Batamanta handles its own garbage. After each successful compilation, it:

  • Removes bat_cargo_cache from the system temp directory
  • Deletes bat_pkg_* and bat_build_* intermediate folders
  • Preserves the ERTS cache (~/.cache/batamanta) for sub-second repeat builds

To manually wipe the entire cache (including downloaded ERTS), use mix batamanta.clean.

Use :erts_target for unified platform specification:

batamanta: [
  execution_mode: :cli,
  compression: 3,
]
Target AtomDescription
:autoAuto-detect host platform (default)
:ubuntu_22_04_x86_64Linux x86_64 glibc (Debian, Ubuntu, Arch, CachyOS)
:ubuntu_22_04_arm64Linux aarch64 glibc
:alpine_3_19_x86_64Linux x86_64 musl (Alpine)
:alpine_3_19_arm64Linux aarch64 musl
:macos_12_x86_64macOS Intel
:macos_12_arm64macOS Apple Silicon
:windows_x86_64Windows x86_64

Force specific platform regardless of host:

batamanta: [
  force_arch: "x86_64",
  force_libc: "musl",
]

You can force the binary name by setting :binary_name in the config:

batamanta: [
  binary_name: "my_custom_binary"
]

mix batamanta
  • --erts-target - Override ERTS target atom
  • --otp-version - Specify exact OTP version (e.g., "28.1")
  • --force-os - Force OS (linux, macos, windows)
  • --force-arch - Force architecture (x86_64, aarch64)
  • --force-libc - Force libc (gnu, musl) - Linux only
  • --compression - Zstd compression level (1-19)
  • --format - Output format: escript or release (default: release)

Summary

Functions

Builds override config from options and config.

Parses command-line options.

Resolves ERTS target from options and config.

Resolves the output format from options, config, or auto-detection.

Resolves OTP version from options and config.

Validates required system tools

Functions

build_override_config(opts, bata_config)

Builds override config from options and config.

parse_options(args)

Parses command-line options.

resolve_erts_target(opts, bata_config)

Resolves ERTS target from options and config.

resolve_format(opts, bata_config, project_config)

Resolves the output format from options, config, or auto-detection.

Priority:

  1. CLI option --format
  2. Config format: key
  3. Auto-detect: if project has :escript config, use :escript, else :release

resolve_otp_version(opts, bata_config)

Resolves OTP version from options and config.

Returns a tuple with:

  • version string

  • mode: :explicit (user specified) or :auto (detected from system)

  • If user specifies otp_version in config or CLI, that exact version is used

  • If no version specified (auto mode), uses conservative fallback (tries 28.0, 28.1, etc.)

validate_toolchain!()

Validates required system tools