Skip to content

Wire up rustler_precompiled for v0.3.0#2

Draft
qweliant wants to merge 1 commit into
mainfrom
wire-up-rustler-precompiled
Draft

Wire up rustler_precompiled for v0.3.0#2
qweliant wants to merge 1 commit into
mainfrom
wire-up-rustler-precompiled

Conversation

@qweliant

Copy link
Copy Markdown
Owner

What changed

lib/lib_raw/nif.ex

Switched from use Rustler to use RustlerPrecompiled. On install, Hex will
now download a precompiled .so from the GitHub release instead of invoking
the Rust toolchain. Key options:

Option Value
crate libraw_nif
version read from Mix.Project.config()[:version] (currently "0.3.0")
base_url https://github.com/qweliant/libraw/releases/download/v<version>
nif_versions ["2.15", "2.16", "2.17"] (OTP 23 / 24-25 / 26+)
targets see table below
force_build true when LIBRAW_BUILD=1 (source-build opt-in)

:rustler is kept as a dep — rustler_precompiled needs it for source-build fallback.

.github/workflows/release.yml

Triggers on any v* tag push. Build matrix: 4 targets × 3 NIF versions = 12 jobs, all on native runners.

Target Runner libraw install
aarch64-apple-darwin macos-latest (Apple Silicon) brew install libraw
x86_64-apple-darwin macos-13 (Intel) brew install libraw
x86_64-unknown-linux-gnu ubuntu-22.04 apt-get install libraw-dev
aarch64-unknown-linux-gnu ubuntu-24.04-arm (native ARM64) apt-get install libraw-dev

Uses philss/rustler-precompiled-action@v1 to compile and package each NIF artifact, then a separate release job collects all artifacts and publishes the GitHub Release via softprops/action-gh-release@v1.

README.md

  • Prerequisites: clarified that libraw is always required but Rust is not (for supported targets).
  • Installation: version constraint updated to ~> 0.3, new "Supported Platforms" table, LIBRAW_BUILD=1 source-build instructions.

mix.exs

@version bumped "0.2.0""0.3.0".

CHANGELOG.md

Added v0.3.0 entry.


libraw-still-required caveat

libraw is dynamically linked at runtime (LGPL). Every machine that runs
:libraw must have the shared library installed:

# macOS
brew install libraw

# Debian / Ubuntu
apt install libraw-dev

The precompiled NIF does not bundle or statically link libraw. This is by design.


MUSL / Alpine

Intentionally excluded — libraw is not reliable on musl libc.


Pre-merge checklist

  • Cut a v0.3.0-rc1 tag and verify all 12 workflow jobs pass
  • Confirm .tar.gz + .sha256sum artifacts appear on the draft GitHub Release
  • Test mix deps.get && mix deps.compile on a clean macOS machine without Rust — should download precompiled NIF, no Rust invocation
  • Test same on a clean Linux x86_64 machine without Rust
  • Test LIBRAW_BUILD=1 mix deps.compile forces a source build (requires Rust + libraw-dev)
  • Verify LibRaw.decode/2 and LibRaw.metadata/1 work end-to-end after precompiled install
  • Confirm mix hex.publish package includes checksum.exs (generated by mix rustler_precompiled.download LibRaw.NIF --all --print)
  • Remove draft status and merge
  • Publish to Hex (mix hex.publish)

Generated by Claude Code

Switch lib/lib_raw/nif.ex from plain Rustler to RustlerPrecompiled so
end users on supported targets (aarch64/x86_64 macOS and Linux gnu)
download a precompiled NIF instead of compiling Rust from source.
libraw is still dynamically linked at runtime (LGPL compliance).

Add .github/workflows/release.yml: builds NIF artifacts across all four
targets on native runners (macos-latest, macos-13, ubuntu-22.04,
ubuntu-24.04-arm) for NIF versions 2.15/2.16/2.17, then publishes a
GitHub Release containing every .tar.gz artifact.

https://claude.ai/code/session_01WCfYosaDqCSoSDbK5vLUSx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants