This document provides comprehensive guidance for Vix development, testing, and release processes.
- Development Environment Setup
- Build System
- Toolchain Management
- Testing and Quality Assurance
- Release Process
- Troubleshooting
- Elixir 1.11+ with OTP 21+
- C compiler (gcc/clang)
- Make
- pkg-config (for system libvips detection)
Vix supports three compilation modes controlled by the VIX_COMPILATION_MODE environment variable:
PRECOMPILED_NIF_AND_LIBVIPS(default) - Use precompiled NIFs and libvipsPRECOMPILED_LIBVIPS- Compile NIFs locally, use precompiled libvipsPLATFORM_PROVIDED_LIBVIPS- Use system-provided libvips
# Use system libvips (requires libvips-dev package)
export VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPS
# Force precompiled libvips build
export VIX_COMPILATION_MODE=PRECOMPILED_LIBVIPS# Clone and build
git clone https://github.com/akash-akya/vix.git
cd vix
make all
# Run tests
mix test
# Verify installation
iex -S mix# Build everything
make all
make compile
# Clean builds
make clean # Clean build artifacts
make deep_clean # Full clean including precompiled libvips
make clean_precompiled_libvips # Remove only precompiled libvips
# Debug and verbose builds
make debug # Show build configuration (from c_src/)
make V=1 all # Verbose compilation outputBuild behavior is controlled by several environment variables:
VIX_COMPILATION_MODE- Compilation strategyLIBVIPS_VERSION- Override default libvips versionCC_PRECOMPILER_CURRENT_TARGET- Override target platformELIXIR_MAKE_CACHE_DIR- Cache directory for precompiled binaries
Vix uses musl toolchains for cross-compilation. Due to instability of the upstream musl.cc website, we maintain mirrors via GitHub releases.
# Download cached toolchains with fallback
./scripts/download_toolchains.shThis script:
- First attempts to download from our GitHub release mirror
- Falls back to upstream musl.cc if mirror fails
- Downloads and extracts
x86_64-linux-musl-cross.tgzandaarch64-linux-musl-cross.tgz
# Mirror toolchains from upstream to local directory
./scripts/mirror_toolchains.shThis creates a toolchains/ directory with downloaded toolchain archives. To update the mirror:
- Run the mirror script
- Create a GitHub release tagged
toolchains-v{VERSION}(e.g.,toolchains-v11.2.1) - Upload the toolchain files as release assets
- Update version in scripts if needed
Precompiled libvips binaries are managed through our sharp-libvips fork.
Current configuration:
- libvips version:
8.15.3(defined inbuild_scripts/precompiler.exs:11) - Release tag:
8.15.3-rc3(defined inbuild_scripts/precompiler.exs:24)
Supported platforms:
- Linux x64 (gnu/musl)
- Linux ARM64 (gnu/musl)
- Linux ARMv7/ARMv6
- macOS x64/ARM64
# Standard test suite
mix test
# Test with cached precompiled binaries
ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache" mix test
# Test specific files
mix test test/vix/vips/image_test.exs
# Coverage reports
mix coveralls# Static analysis
make lint # or mix credo
make dialyxir # or mix dialyxir
# Code formatting
make format # or mix formatBefore committing changes, ensure:
# Clean build passes
make clean && make all
# All tests pass
mix test
# Code quality checks pass
make lint && make dialyxir
# Code is formatted
make formatFor releases without libvips changes:
-
Prepare Release
# Bump version in mix.exs git add mix.exs git commit -m "Bump version to X.Y.Z" git push origin master
-
Create GitHub Release
- Go to https://github.com/akash-akya/vix/releases
- Create new release with tag
vX.Y.Z - GitHub Actions automatically builds and uploads NIF artifacts
- Wait for all artifacts to be available (check all BEAM NIF versions: 2.16, 2.17, etc.)
-
Generate Checksums
# Clean local state rm -rf cache/ priv/* checksum.exs _build/*/lib/vix # Generate checksum file ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache" MIX_ENV=prod mix elixir_make.checksum --all # Verify checksum contents cat checksum.exs
-
Test and Publish
# Test precompiled packages ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache" mix test # Publish to Hex mix hex.publish
For releases with new precompiled libvips versions:
-
Update sharp-libvips Fork
cd ../sharp-libvips # Your fork directory # Pull latest stable upstream changes git remote add upstream https://github.com/lovell/sharp-libvips.git git fetch upstream git checkout upstream/main # Apply our patches for shared library compatibility git cherry-pick <our-patch-commits> # Create tag matching upstream version git tag v8.15.X git push origin v8.15.X
-
Wait for Artifacts
- GitHub Actions in sharp-libvips fork creates release and artifacts
- Verify all required platform artifacts are created
-
Update Vix Configuration
# Update build_scripts/precompiler.exs # - @vips_version (line 11) # - @release_tag (line 24)
-
Test Locally
# Clean and test with new libvips rm -rf _build/*/lib/vix cache/ priv/* checksum.exs export VIX_COMPILATION_MODE=PRECOMPILED_LIBVIPS mix compile mix test
-
Release
- Follow standard release process above
- Push libvips configuration changes
- Create Vix release and publish to Hex
"libvips not found"
# Install system libvips
sudo apt-get install libvips-dev # Ubuntu/Debian
brew install vips # macOS
# Or force precompiled mode
export VIX_COMPILATION_MODE=PRECOMPILED_LIBVIPS"NIF compilation failed"
# Clean and rebuild
make deep_clean
make all
# Check build configuration
cd c_src && make debug"Checksum verification failed"
# Clear cache and regenerate
rm -rf cache/ checksum.exs
ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache" MIX_ENV=prod mix elixir_make.checksum --all"Toolchain download failed"
# Check if mirror is working
curl -I https://github.com/akash-akya/vix/releases/download/toolchains-v11.2.1/x86_64-linux-musl-cross.tgz
# Manually download and extract
wget https://more.musl.cc/11.2.1/x86_64-linux-musl/x86_64-linux-musl-cross.tgz
tar -xzf x86_64-linux-musl-cross.tgz- Use
ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache"to cache precompiled binaries locally - Set
VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPSfor faster iteration during development - Run
make debugfromc_src/directory to see detailed build configuration - Use
mix test --tracefor verbose test output - Check GitHub Actions logs for CI build failures