mix plushie.build (Plushie v0.6.0)

Copy Markdown View Source

Build the plushie binary and/or WASM renderer from source.

Generates a Cargo workspace and builds it. When a local source checkout is available (PLUSHIE_SOURCE_PATH), dependencies use local paths for development. Otherwise, dependencies are pulled from crates.io using the :binary_version from mix.exs.

When native widgets are detected, the workspace includes each widget's Rust crate and the generated main.rs registers them at startup.

Prerequisites

Usage

mix plushie.build              # build native binary (default)
mix plushie.build --release    # optimized release build
mix plushie.build --wasm       # build WASM renderer only
mix plushie.build --bin --wasm # build both
mix plushie.build --verbose    # print cargo output on success

Options

  • --bin -- Build the native binary
  • --wasm -- Build the WASM renderer via wasm-pack
  • --bin-file PATH -- Override native binary destination
  • --wasm-dir PATH -- Override WASM output directory
  • --release -- Build with optimizations (also implied by MIX_ENV=prod)
  • --verbose -- Print full cargo output on successful builds

Config

Artifact selection and output paths can be set in config.exs:

config :plushie,
  artifacts: [:bin, :wasm],       # which artifacts to build
  bin_file: "priv/bin/plushie-renderer",  # binary destination
  wasm_dir: "priv/static"         # WASM output directory

CLI flags override config. Default artifacts: [:bin].

Native widgets

Native widgets are auto-detected via the Plushie.Widget protocol. Any module that implements the protocol and exports native_crate/0 is included in the build. No explicit configuration is needed.

The task validates that no two widgets claim the same type name. A Cargo workspace is generated under the Mix build directory with a main.rs that registers each native widget.

Summary

Functions

Raises Mix.Error if any two native widgets claim the same type name.

Raises Mix.Error if any two native widgets produce the same Cargo crate name.

Functions

check_collisions!(widgets)

@spec check_collisions!(widgets :: [module()]) :: :ok

Raises Mix.Error if any two native widgets claim the same type name.

check_crate_name_collisions!(widgets)

@spec check_crate_name_collisions!(widgets :: [module()]) :: :ok

Raises Mix.Error if any two native widgets produce the same Cargo crate name.

The crate name is Path.basename/1 of each widget's native_crate/0 path. Two widgets at native/widget/ and other/widget/ would both produce widget, causing a Cargo dependency conflict.