ExclosuredPrecompiled (exclosured_precompiled v0.1.0)
Copy MarkdownDownload precompiled WASM modules for Exclosured libraries.
Library authors compile their Rust code to .wasm and .js files once,
upload them to a GitHub Release, and publish checksums to Hex. Consumers
get precompiled WASM without needing Rust, cargo, or wasm-bindgen.
Since all Exclosured modules target wasm32-unknown-unknown, there is
only one compilation target. No platform detection needed.
Environment Variables
HTTP_PROXYorhttp_proxy- HTTP proxy configurationHTTPS_PROXYorhttps_proxy- HTTPS proxy configurationHEX_CACERTS_PATH- Custom CA certificates file path. Defaults toCAStore.file_path/0if CAStore is available.MIX_XDG- If present, uses:filename.basedir/3with:linuxfor resolving the user cache directory.EXCLOSURED_PRECOMPILED_GLOBAL_CACHE_PATH- Override the global cache directory. Useful for systems that cannot download at compile time (e.g., NixOS). Artifacts must be pre-downloaded to this path.EXCLOSURED_PRECOMPILED_FORCE_BUILD_ALL- Set to"1"or"true"to force building from source for all packages, ignoring precompiled downloads. Equivalent toconfig :exclosured_precompiled, force_build_all: true.
For library authors
See the Precompilation Guide for a step-by-step walkthrough.
defmodule MyLibrary.Precompiled do
use ExclosuredPrecompiled,
otp_app: :my_library,
base_url: "https://github.com/user/repo/releases/download/v0.1.0",
version: "0.1.0",
modules: [:my_processor, :my_filter]
endFor library consumers
Just add the library to your deps. If it uses ExclosuredPrecompiled,
WASM files are downloaded automatically during mix compile.
To force building from source:
config :exclosured_precompiled, force_build: trueOr per-module:
config :exclosured_precompiled, force_build: [:my_module]
Summary
Functions
Generate the archive filename for a module.
Path to the cached archive in the global cache directory.
Path to the checksum file for a module.
Compute the SHA-256 checksum of a file.
Download a file from a URL. Returns :ok or {:error, reason}.
Build the download URL for an archive.
Download a file from a URL to a local path with retry support.
Download precompiled WASM modules if not already present.
Called at compile time from the __using__ macro.
Extract a tar.gz archive to a directory.
Returns the reason for force build, or nil if precompiled download should be used.
Generate checksums for all archives in a directory.
Load checksums from the checksum file shipped with the Hex package.
Package a compiled WASM module into a tar.gz archive for publishing.
Check if force build is enabled for any of the given modules.
Verify the checksum of a downloaded archive against the checksum file.
Write checksums to a file.
Functions
Generate the archive filename for a module.
Format: MODULE-vVERSION-wasm32.tar.gz
Since all Exclosured modules compile to wasm32-unknown-unknown,
there is only one archive per module per version.
Path to the cached archive in the global cache directory.
Path to the checksum file for a module.
Compute the SHA-256 checksum of a file.
Returns a string in the format "sha256:HEX_HASH".
Download a file from a URL. Returns :ok or {:error, reason}.
Build the download URL for an archive.
Download a file from a URL to a local path with retry support.
Retries up to 3 times with exponential backoff on failure.
Respects HTTP_PROXY, HTTPS_PROXY, and HEX_CACERTS_PATH environment
variables.
Download precompiled WASM modules if not already present.
Called at compile time from the __using__ macro.
Extract a tar.gz archive to a directory.
Writes a .sha256 file next to each extracted file for independent
integrity verification.
Returns the reason for force build, or nil if precompiled download should be used.
Pre-release versions (containing -dev, -rc, etc.) automatically
trigger a force build since no precompiled binaries exist for them.
Generate checksums for all archives in a directory.
Returns a map of %{"filename" => "sha256:hex_hash"}.
Load checksums from the checksum file shipped with the Hex package.
Package a compiled WASM module into a tar.gz archive for publishing.
Returns the path to the created archive.
Check if force build is enabled for any of the given modules.
Force build is triggered by:
EXCLOSURED_PRECOMPILED_FORCE_BUILD_ALLenv var set to"1"or"true"config :exclosured_precompiled, force_build_all: trueconfig :exclosured_precompiled, force_build: trueconfig :exclosured_precompiled, force_build: [:module_name]
Verify the checksum of a downloaded archive against the checksum file.
Write checksums to a file.