[config]
default_to_workspace = false
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
[tasks.clean]
description = "Clean all build artifacts"
dependencies = ["clean-rust", "clean-mobile", "clean-wasm", "python-clean", "clean-ruby", "npm-clean"]
[tasks.clean-rust]
description = "Clean Rust build artifacts"
command = "cargo"
args = ["clean"]
[tasks.build]
description = "Build Rust CLI and library"
dependencies = ["build-rust"]
[tasks.build-rust]
description = "Build Rust CLI"
command = "cargo"
args = ["build", "--release"]
[tasks.build-debug]
description = "Build Rust CLI in debug mode"
command = "cargo"
args = ["build"]
[tasks.test]
description = "Run all tests"
dependencies = ["test-rust", "test-integration", "test-cli"]
[tasks.test-rust]
description = "Run Rust unit tests"
command = "cargo"
args = ["test"]
[tasks.test-integration]
description = "Run integration tests"
script = '''
echo "Running integration tests..."
cargo test --test integration_tests
'''
[tasks.test-cli]
description = "Test all CLI implementations"
dependencies = ["test-rust-cli", "test-python-cli", "test-ruby-cli", "test-node-cli"]
[tasks.test-rust-cli]
description = "Test Rust CLI"
script = '''
echo "Testing Rust CLI..."
./target/release/proofmode --version
./target/release/proofmode check --help
./target/release/proofmode generate --help
'''
dependencies = ["build-rust"]
[tasks.test-python-cli]
description = "Test Python CLI"
script = '''
echo "Testing Python CLI..."
cd examples/python
if [ -f proofmode-cli ]; then
./proofmode-cli version
else
echo "Python CLI not built. Run 'cargo make setup-python' first."
fi
'''
[tasks.test-ruby-cli]
description = "Test Ruby CLI"
script = '''
echo "Testing Ruby CLI..."
cd examples/ruby
if [ -f proofmode-cli ]; then
ruby --version
echo "Ruby CLI wrapper exists. Full test requires ffi gem."
else
echo "Ruby CLI not built. Run 'cargo make setup-ruby' first."
fi
'''
[tasks.test-node-cli]
description = "Test Node.js CLI"
dependencies = ["wasm-pack-node"]
script = '''
echo "Testing Node.js CLI..."
cd cli/node
node --version
if [ -f cli.js ]; then
echo "Testing CLI help..."
node cli.js --help
echo "Node.js CLI test completed"
else
echo "Node.js CLI not found."
fi
'''
[tasks.wasm-pack]
description = "Build the WASM version and NPM package"
command = "wasm-pack"
args = [
"build",
"--target",
"web",
"--scope",
"guardianproject",
"--",
"--no-default-features",
"--features",
"wasm"
]
[tasks.wasm-pack-web]
description = "Build WASM for web browsers"
command = "wasm-pack"
args = [
"build",
"--target",
"web",
"--scope",
"guardianproject",
"--out-dir",
"pkg-web",
"--",
"--no-default-features",
"--features",
"wasm"
]
[tasks.wasm-pack-node]
description = "Build WASM for Node.js"
command = "wasm-pack"
args = [
"build",
"--target",
"nodejs",
"--scope",
"guardianproject",
"--out-dir",
"pkg-node",
"--",
"--no-default-features",
"--features",
"wasm"
]
[tasks.wasm-pack-all]
description = "Build WASM for all targets"
dependencies = ["wasm-pack-web", "wasm-pack-node"]
[tasks.wasm-publish]
description = "Publish WASM package to npm"
dependencies = ["wasm-pack"]
command = "wasm-pack"
args = ["publish"]
[tasks.build-uniffi]
description = "Build Rust library with UniFFI support (no clap)"
command = "cargo"
args = ["build", "--release", "--no-default-features", "--features", "uniffi,sequoia-openpgp,polars,c2pa"]
[tasks.generate-bindings]
description = "Generate UniFFI bindings for all platforms"
dependencies = ["generate-ios-bindings", "generate-android-bindings", "generate-python-bindings", "generate-ruby-bindings"]
[tasks.generate-ios-bindings]
description = "Generate iOS bindings"
dependencies = ["build-uniffi"]
script = '''
echo "Generating iOS bindings..."
mkdir -p bindings/ios bindings/generated
# Build uniffi-bindgen if needed
if [ ! -f target/debug/uniffi-bindgen ] && [ ! -f target/release/uniffi-bindgen ]; then
echo "Building uniffi-bindgen..."
cargo build --bin uniffi-bindgen --features uniffi
fi
UNIFFI_BIN="./target/debug/uniffi-bindgen"
if [ ! -f "$UNIFFI_BIN" ]; then
UNIFFI_BIN="./target/release/uniffi-bindgen"
fi
# Generate Swift bindings
$UNIFFI_BIN generate \
--library target/release/libproofmode.so \
--language swift \
--out-dir bindings/generated \
--no-format
echo "iOS bindings generated in bindings/generated/"
'''
[tasks.generate-android-bindings]
description = "Generate Android bindings"
dependencies = ["build-uniffi"]
script = '''
echo "Generating Android bindings..."
mkdir -p bindings/android bindings/generated
# Build uniffi-bindgen if needed
if [ ! -f target/debug/uniffi-bindgen ] && [ ! -f target/release/uniffi-bindgen ]; then
echo "Building uniffi-bindgen..."
cargo build --bin uniffi-bindgen --features uniffi
fi
UNIFFI_BIN="./target/debug/uniffi-bindgen"
if [ ! -f "$UNIFFI_BIN" ]; then
UNIFFI_BIN="./target/release/uniffi-bindgen"
fi
# Generate Kotlin bindings
$UNIFFI_BIN generate \
--library target/release/libproofmode.so \
--language kotlin \
--out-dir bindings/generated \
--no-format
echo "Android bindings generated in bindings/generated/"
'''
[tasks.install-android-targets]
description = "Install Android targets"
script = '''
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
'''
[tasks.install-ios-targets]
description = "Install iOS targets"
script = '''
rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
'''
[tasks.build-android]
description = "Build for Android (all architectures) using cross"
dependencies = ["install-android-targets"]
script = '''
echo "Building Android libraries using cross..."
# Build for all Android architectures using cross with uniffi feature only
echo "Building for Android ARM64..."
cross build --release --target aarch64-linux-android --no-default-features --features uniffi,polars,c2pa
echo "Building for Android ARMv7..."
cross build --release --target armv7-linux-androideabi --no-default-features --features uniffi,polars,c2pa
echo "Building for Android x86..."
cross build --release --target i686-linux-android --no-default-features --features uniffi,polars,c2pa
echo "Building for Android x86_64..."
cross build --release --target x86_64-linux-android --no-default-features --features uniffi,polars,c2pa
# Create JNI directory structure
mkdir -p target/android/jniLibs/arm64-v8a
mkdir -p target/android/jniLibs/armeabi-v7a
mkdir -p target/android/jniLibs/x86
mkdir -p target/android/jniLibs/x86_64
# Copy libraries to JNI structure
cp target/aarch64-linux-android/release/libproofmode.so target/android/jniLibs/arm64-v8a/
cp target/armv7-linux-androideabi/release/libproofmode.so target/android/jniLibs/armeabi-v7a/
cp target/i686-linux-android/release/libproofmode.so target/android/jniLibs/x86/
cp target/x86_64-linux-android/release/libproofmode.so target/android/jniLibs/x86_64/
echo "Android libraries built successfully in target/android/"
'''
[tasks.build-ios]
description = "Build for iOS (all targets)"
dependencies = ["install-ios-targets"]
script = '''
echo "Building iOS libraries..."
# Build for iOS simulator (x86_64)
echo "Building for iOS simulator (x86_64)..."
cargo build --release --target x86_64-apple-ios --no-default-features --features uniffi,polars,c2pa
# Build for iOS simulator (ARM64)
echo "Building for iOS simulator (ARM64)..."
cargo build --release --target aarch64-apple-ios-sim --no-default-features --features uniffi,polars,c2pa
# Build for iOS device (ARM64)
echo "Building for iOS device (ARM64)..."
cargo build --release --target aarch64-apple-ios --no-default-features --features uniffi,polars,c2pa
# Create universal library
echo "Creating universal library..."
mkdir -p target/universal/ios
# Use lipo to create universal binary for simulator
lipo -create \
target/x86_64-apple-ios/release/libproofmode.a \
target/aarch64-apple-ios-sim/release/libproofmode.a \
-output target/universal/ios/libproofmode_sim.a
# Copy device library
cp target/aarch64-apple-ios/release/libproofmode.a target/universal/ios/libproofmode_device.a
echo "iOS libraries built successfully in target/universal/ios/"
'''
[tasks.create-xcframework]
description = "Create XCFramework for iOS"
dependencies = ["build-ios", "generate-ios-bindings"]
script = '''
echo "Creating XCFramework..."
# Create directory structure
mkdir -p ./target/xcframework/headers
# Copy headers from bindings
cp ./bindings/generated/*.h ./target/xcframework/headers/
cp ./bindings/generated/*.modulemap ./target/xcframework/headers/
# Create fat binary for simulator (already created in build-ios)
# Use the universal libraries
cp ./target/universal/ios/libproofmode_sim.a ./target/libproofmode_sim.a
# Create xcframework
xcodebuild -create-xcframework \
-library ./target/universal/ios/libproofmode_device.a \
-headers ./target/xcframework/headers \
-library ./target/libproofmode_sim.a \
-headers ./target/xcframework/headers \
-output ./target/xcframework/ProofMode.xcframework
echo "XCFramework created at ./target/xcframework/ProofMode.xcframework"
'''
[tasks.create-aar]
description = "Create AAR for Android"
dependencies = ["build-android", "generate-android-bindings"]
script = '''
echo "Creating AAR structure..."
# Create AAR structure
mkdir -p ./target/aar/src/main/jniLibs/armeabi-v7a
mkdir -p ./target/aar/src/main/jniLibs/arm64-v8a
mkdir -p ./target/aar/src/main/jniLibs/x86
mkdir -p ./target/aar/src/main/jniLibs/x86_64
mkdir -p ./target/aar/src/main/java
# Copy native libraries from JNI structure
cp ./target/android/jniLibs/armeabi-v7a/libproofmode.so ./target/aar/src/main/jniLibs/armeabi-v7a/
cp ./target/android/jniLibs/arm64-v8a/libproofmode.so ./target/aar/src/main/jniLibs/arm64-v8a/
cp ./target/android/jniLibs/x86/libproofmode.so ./target/aar/src/main/jniLibs/x86/
cp ./target/android/jniLibs/x86_64/libproofmode.so ./target/aar/src/main/jniLibs/x86_64/
# Copy Kotlin sources from bindings
cp -r ./bindings/generated/* ./target/aar/src/main/java/
# Create AndroidManifest.xml
cat > ./target/aar/src/main/AndroidManifest.xml << 'EOF'
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.witness.proofmode">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34" />
</manifest>
EOF
# Create build.gradle
cat > ./target/aar/build.gradle << 'EOF'
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
implementation "net.java.dev.jna:jna:5.14.0"
}
EOF
echo "AAR structure created at ./target/aar"
echo "To build the AAR, use Android Studio or Gradle with the generated build.gradle"
'''
[tasks.create-swift-package]
description = "Create Swift Package"
dependencies = ["create-xcframework"]
script = '''
echo "Creating Swift Package..."
# Create Swift Package structure
mkdir -p ./target/ProofMode/Sources/ProofMode
mkdir -p ./target/ProofMode/Sources/ProofModeFFI
# Copy Swift source files from bindings
cp ./bindings/generated/*.swift ./target/ProofMode/Sources/ProofMode/
# Copy headers to FFI module
cp ./bindings/generated/*.h ./target/ProofMode/Sources/ProofModeFFI/
cp ./bindings/generated/*.modulemap ./target/ProofMode/Sources/ProofModeFFI/
# Copy XCFramework
cp -r ./target/xcframework/ProofMode.xcframework ./target/ProofMode/
# Create Package.swift
cat > ./target/ProofMode/Package.swift << 'EOF'
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "ProofMode",
platforms: [
.iOS(.v13),
.macOS(.v11)
],
products: [
.library(
name: "ProofMode",
targets: ["ProofMode", "ProofModeFFI"]
),
],
targets: [
.target(
name: "ProofMode",
dependencies: ["ProofModeFFI"],
path: "Sources/ProofMode"
),
.binaryTarget(
name: "ProofModeFFI",
path: "ProofMode.xcframework"
)
]
)
EOF
echo "Swift Package created at ./target/ProofMode"
'''
[tasks.mobile]
description = "Build all mobile targets"
dependencies = ["generate-bindings", "create-aar", "create-swift-package"]
[tasks.clean-mobile]
description = "Clean mobile build artifacts"
script = '''
echo "Cleaning mobile build artifacts..."
rm -rf ./target/android
rm -rf ./target/uniffi
rm -rf ./target/universal
rm -rf ./target/xcframework
rm -rf ./target/aar
rm -rf ./target/ProofMode
rm -rf ./bindings
rm -f ./target/libproofmode_sim.a
echo "Mobile artifacts cleaned"
'''
[tasks.docs]
description = "Generate documentation"
command = "cargo"
args = ["doc", "--open"]
[tasks.generate-makefile]
description = "Generate Makefile from Makefile.toml"
command = "cargo"
args = ["run", "--bin", "generate_makefile"]
[tasks.python-dev]
description = "Build Python package for development"
script = '''
echo "Building Python package for development..."
pip install -e . --force-reinstall
echo "Python package installed in development mode"
'''
[tasks.python-build]
description = "Build Python wheels using maturin"
script = '''
echo "Building Python wheels..."
pip install maturin
maturin build --release
echo "Python wheels built in target/wheels/"
'''
[tasks.python-build-dev]
description = "Build Python package in debug mode"
script = '''
echo "Building Python package in debug mode..."
pip install maturin
maturin develop
echo "Python package built and installed"
'''
[tasks.python-test]
description = "Run Python tests"
dependencies = ["python-build-dev"]
script = '''
echo "Running Python tests..."
pip install pytest pytest-asyncio
pytest python/tests -v
'''
[tasks.python-lint]
description = "Lint Python code"
script = '''
echo "Linting Python code..."
pip install black ruff mypy
black python/
ruff check python/
mypy python/proofmode/
'''
[tasks.python-publish]
description = "Publish Python package to PyPI"
dependencies = ["python-build"]
script = '''
echo "Publishing Python package to PyPI..."
pip install twine
twine upload target/wheels/*
'''
[tasks.python-clean]
description = "Clean Python build artifacts"
script = '''
echo "Cleaning Python build artifacts..."
rm -rf target/wheels
rm -rf python/proofmode/__pycache__
rm -rf python/proofmode.egg-info
rm -rf build/
rm -rf dist/
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -delete
echo "Python artifacts cleaned"
'''
[tasks.npm-install]
description = "Install NPM CLI dependencies"
cwd = "cli/node"
command = "npm"
args = ["install"]
[tasks.npm-install-web]
description = "Install web example dependencies"
cwd = "examples/web"
command = "pnpm"
args = ["install"]
[tasks.npm-test]
description = "Run NPM CLI tests"
dependencies = ["wasm-pack-node", "npm-install"]
cwd = "cli/node"
command = "npm"
args = ["test"]
[tasks.npm-pack]
description = "Create NPM tarball for testing"
dependencies = ["wasm-pack", "npm-install"]
cwd = "examples/node"
command = "npm"
args = ["pack"]
[tasks.npm-publish]
description = "Publish NPM CLI package"
dependencies = ["wasm-pack", "npm-test"]
cwd = "examples/node"
script = '''
echo "Ready to publish NPM CLI package!"
echo ""
echo "Steps to publish:"
echo "1. cd npm"
echo "2. npm login (if not already logged in)"
echo "3. npm publish --access public"
echo ""
echo "To test locally first:"
echo "1. npm pack"
echo "2. npm install -g guardianproject-proofmode-cli-*.tgz"
echo "3. proofmode --help"
'''
[tasks.npm-link]
description = "Link NPM CLI package for local development"
dependencies = ["wasm-pack", "npm-install"]
cwd = "examples/node"
command = "npm"
args = ["link"]
[tasks.npm-clean]
description = "Clean NPM artifacts"
script = '''
echo "Cleaning NPM artifacts..."
rm -rf cli/node/node_modules
rm -f cli/node/package-lock.json
rm -f cli/node/*.tgz
rm -rf examples/web/node_modules
rm -f examples/web/pnpm-lock.yaml
rm -rf examples/web/.next
echo "NPM artifacts cleaned"
'''
[tasks.clean-ruby]
description = "Clean Ruby artifacts"
script = '''
echo "Cleaning Ruby artifacts..."
rm -rf examples/ruby/.bundle
rm -rf examples/ruby/vendor
rm -f examples/ruby/Gemfile.lock
rm -f examples/ruby/*.gem
echo "Ruby artifacts cleaned"
'''
[tasks.clean-wasm]
description = "Clean WASM build artifacts"
script = '''
echo "Cleaning WASM artifacts..."
rm -rf pkg/
rm -rf pkg-web/
rm -rf pkg-node/
rm -rf target/wasm32-unknown-unknown/
echo "WASM artifacts cleaned"
'''
[tasks.docker-build]
description = "Build Docker image for current architecture"
command = "docker"
args = ["build", "-t", "proofmode-rust:local", "."]
[tasks.docker-buildx]
description = "Build multi-architecture Docker image"
script = '''
echo "Building multi-architecture Docker image..."
docker buildx create --use --name proofmode-builder || true
docker buildx build --platform linux/amd64,linux/arm64 -t proofmode:multiarch --load .
docker buildx rm proofmode-builder
echo "Multi-architecture image built"
'''
[tasks.docker-test]
description = "Test Docker image"
dependencies = ["docker-build"]
script = '''
echo "Testing Docker image..."
docker run --rm proofmode-rust:local --version
docker run --rm proofmode-rust:local --help
docker run --rm -e RUST_LOG=debug proofmode-rust:local check --help
echo "Docker image tests passed"
'''
[tasks.docker-run]
description = "Run Docker container interactively"
dependencies = ["docker-build"]
command = "docker"
args = ["run", "-it", "--rm", "--user", "$(id -u):$(id -g)", "-v", "${PWD}/media:/app/input", "-v", "${PWD}/proofs:/app/output", "proofmode-rust:local"]
[tasks.docker-examples]
description = "Run Docker examples"
dependencies = ["docker-build"]
script = '''
echo "Running Docker examples..."
cd examples/docker
./run-example.sh all
echo "Docker examples completed"
'''
[tasks.docker-compose-up]
description = "Start services with docker-compose"
command = "docker-compose"
args = ["up", "-d"]
[tasks.docker-compose-down]
description = "Stop services with docker-compose"
command = "docker-compose"
args = ["down"]
[tasks.docker-compose-logs]
description = "View docker-compose logs"
command = "docker-compose"
args = ["logs", "-f"]
[tasks.docker-push]
description = "Push Docker image to registry"
script = '''
echo "To push Docker images:"
echo "1. docker tag proofmode:local guardianproject/proofmode:latest"
echo "2. docker push guardianproject/proofmode:latest"
echo ""
echo "For automated builds, use GitHub Actions workflow"
'''
[tasks.docker-clean]
description = "Clean Docker build cache"
script = '''
echo "Cleaning Docker build cache..."
docker system prune -f
docker builder prune -f
echo "Docker cache cleaned"
'''
[tasks.setup]
description = "Complete development environment setup"
dependencies = ["install-tools", "install-targets", "setup-python", "setup-ruby", "setup-node"]
[tasks.install-tools]
description = "Install required development tools"
script = '''
echo "Installing development tools..."
# Check for wasm-pack
if ! command -v wasm-pack &> /dev/null; then
echo "Installing wasm-pack..."
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
fi
# Check for cross (for Android builds)
if ! command -v cross &> /dev/null; then
echo "Installing cross..."
cargo install cross --git https://github.com/cross-rs/cross
fi
# Build uniffi-bindgen
echo "Building uniffi-bindgen..."
cargo build --bin uniffi-bindgen --features uniffi
echo "All tools installed!"
'''
[tasks.install-targets]
description = "Install all compilation targets"
dependencies = ["install-android-targets", "install-ios-targets", "install-wasm-target"]
[tasks.install-wasm-target]
description = "Install WASM target"
command = "rustup"
args = ["target", "add", "wasm32-unknown-unknown"]
[tasks.setup-python]
description = "Setup Python CLI environment"
script = '''
cd examples/python
if [ -f setup_python_cli.sh ]; then
bash setup_python_cli.sh
else
echo "Creating Python virtual environment..."
python3 -m venv venv
source venv/bin/activate
pip install click rich
fi
'''
[tasks.setup-ruby]
description = "Setup Ruby CLI environment"
script = '''
cd examples/ruby
if [ -f setup.sh ]; then
bash setup.sh
else
echo "Ruby setup requires bundler and ffi gem"
fi
'''
[tasks.setup-node]
description = "Setup Node.js CLI environment"
dependencies = ["wasm-pack-node"]
script = '''
cd cli/node
npm install
echo "Node.js CLI environment setup completed"
'''
[tasks.build-all]
description = "Build everything"
dependencies = ["build-rust", "wasm-pack-all", "build-mobile", "generate-bindings"]
[tasks.build-mobile]
description = "Build all mobile targets"
dependencies = ["build-android", "build-ios-sim"]
[tasks.build-ios-sim]
description = "Build iOS for simulator (Linux-compatible check)"
script = '''
if [[ "$OSTYPE" == "darwin"* ]]; then
cargo make build-ios
else
echo "iOS builds require macOS. Skipping on Linux."
fi
'''
[tasks.cli-python]
description = "Run Python CLI"
script = '''
cd examples/python
if [ -f proofmode-cli ]; then
./proofmode-cli "$@"
else
echo "Python CLI not setup. Run: cargo make setup-python"
fi
'''
[tasks.cli-ruby]
description = "Run Ruby CLI"
script = '''
cd examples/ruby
if [ -f proofmode-cli ]; then
./proofmode-cli "$@"
else
echo "Ruby CLI not setup. Run: cargo make setup-ruby"
fi
'''
[tasks.cli-node]
description = "Run Node.js CLI"
script = '''
cd examples/node
node cli.js "$@"
'''
[tasks.cli-rust]
description = "Run Rust CLI"
command = "cargo"
args = ["run", "--release", "--"]
[tasks.web-dev]
description = "Start web development server"
dependencies = ["wasm-pack-web", "npm-install-web"]
cwd = "examples/web"
command = "pnpm"
args = ["dev"]
[tasks.web-build]
description = "Build web application for production"
dependencies = ["wasm-pack-web", "npm-install-web"]
cwd = "examples/web"
command = "pnpm"
args = ["build"]
[tasks.web-test]
description = "Build and serve web application locally"
dependencies = ["web-build"]
script = '''
echo "Web application built successfully"
echo "To serve locally: cd examples/web && pnpm start"
'''
[tasks.test-all]
description = "Run all tests including CLI tests"
dependencies = ["test", "test-cli", "test-examples"]
[tasks.test-examples]
description = "Test all example CLIs"
script = '''
echo "Testing example CLIs..."
# Test Python
echo "Testing Python CLI..."
cd examples/python
if [ -f proofmode-cli ]; then
./proofmode-cli version
fi
cd ../..
# Test Ruby
echo "Testing Ruby CLI..."
cd examples/ruby
if [ -f proofmode-cli ]; then
echo "Ruby CLI exists (requires ffi gem for full test)"
fi
cd ../..
# Test Node
echo "Testing Node.js CLI..."
cd examples/node
if [ -f cli.js ]; then
echo "Node.js CLI exists (requires WASM module)"
fi
cd ../..
echo "Example tests complete!"
'''
[tasks.dist]
description = "Create distribution packages for all platforms"
dependencies = ["dist-rust", "dist-python", "dist-ruby", "dist-npm", "dist-mobile"]
[tasks.dist-rust]
description = "Create Rust binary distribution"
script = '''
cargo build --release
mkdir -p dist/rust
cp target/release/proofmode dist/rust/
cp README.md LICENSE dist/rust/
echo "Rust distribution created in dist/rust/"
'''
[tasks.dist-python]
description = "Create Python wheel distribution"
dependencies = ["generate-python-bindings"]
script = '''
cd examples/python
if [ -f ../../target/release/libproofmode.so ]; then
cp ../../target/release/libproofmode.so python/proofmode/
fi
python3 -m build
mkdir -p ../../dist/python
cp dist/*.whl ../../dist/python/
echo "Python distribution created in dist/python/"
'''
[tasks.dist-ruby]
description = "Create Ruby gem distribution"
dependencies = ["generate-ruby-bindings"]
script = '''
cd examples/ruby
if [ -f ../../target/release/libproofmode.so ]; then
cp ../../target/release/libproofmode.so lib/
fi
gem build proofmode.gemspec
mkdir -p ../../dist/ruby
cp *.gem ../../dist/ruby/
echo "Ruby distribution created in dist/ruby/"
'''
[tasks.dist-npm]
description = "Create NPM package distribution"
dependencies = ["wasm-pack-all"]
script = '''
mkdir -p dist/npm-web dist/npm-node
cp -r pkg-web/* dist/npm-web/
cp -r pkg-node/* dist/npm-node/
echo "NPM distributions created in dist/npm-web/ and dist/npm-node/"
'''
[tasks.dist-mobile]
description = "Create mobile distributions"
dependencies = ["create-aar", "create-xcframework"]
script = '''
mkdir -p dist/android dist/ios
if [ -d target/aar ]; then
cp -r target/aar/* dist/android/
fi
if [ -d target/xcframework ]; then
cp -r target/xcframework/* dist/ios/
fi
echo "Mobile distributions created in dist/android/ and dist/ios/"
'''
[tasks.generate-python-bindings]
description = "Generate Python UniFFI bindings"
dependencies = ["build-uniffi"]
script = '''
echo "Generating Python bindings..."
mkdir -p bindings/generated
# Build uniffi-bindgen if needed
if [ ! -f target/debug/uniffi-bindgen ] && [ ! -f target/release/uniffi-bindgen ]; then
echo "Building uniffi-bindgen..."
cargo build --bin uniffi-bindgen --features uniffi
fi
UNIFFI_BIN="./target/debug/uniffi-bindgen"
if [ ! -f "$UNIFFI_BIN" ]; then
UNIFFI_BIN="./target/release/uniffi-bindgen"
fi
$UNIFFI_BIN generate \
--library target/release/libproofmode.so \
--language python \
--out-dir bindings/generated
echo "Python bindings generated in bindings/generated/"
'''
[tasks.generate-ruby-bindings]
description = "Generate Ruby UniFFI bindings"
dependencies = ["build-uniffi"]
script = '''
echo "Generating Ruby bindings..."
mkdir -p bindings/generated
# Build uniffi-bindgen if needed
if [ ! -f target/debug/uniffi-bindgen ] && [ ! -f target/release/uniffi-bindgen ]; then
echo "Building uniffi-bindgen..."
cargo build --bin uniffi-bindgen --features uniffi
fi
UNIFFI_BIN="./target/debug/uniffi-bindgen"
if [ ! -f "$UNIFFI_BIN" ]; then
UNIFFI_BIN="./target/release/uniffi-bindgen"
fi
$UNIFFI_BIN generate \
--library target/release/libproofmode.so \
--language ruby \
--out-dir bindings/generated
echo "Ruby bindings generated in bindings/generated/"
'''
[tasks.ruby-build]
description = "Build Ruby gem with native library"
dependencies = ["build-uniffi", "generate-ruby-bindings"]
script = '''
echo "Building Ruby gem..."
# Copy native library and generated bindings into ruby/lib/
cp target/release/libproofmode.so ruby/lib/
cp bindings/generated/proofmode.rb ruby/lib/
# Build the gem
cd ruby
gem build proofmode.gemspec
echo "Ruby gem built in ruby/"
'''
[tasks.docs-all]
description = "Generate all documentation"
dependencies = ["docs", "docs-examples"]
[tasks.docs-examples]
description = "Generate documentation for examples"
script = '''
echo "Generating example documentation..."
for example in examples/*; do
if [ -d "$example" ]; then
echo "Documentation for $example"
if [ -f "$example/README.md" ]; then
echo " README.md exists"
fi
fi
done
'''
[tasks.lint]
description = "Run all linters"
dependencies = ["fmt-check", "clippy", "python-lint"]
[tasks.fmt]
description = "Format Rust code"
command = "cargo"
args = ["fmt"]
[tasks.fmt-all]
description = "Format all code"
dependencies = ["fmt", "fmt-python"]
[tasks.fmt-check]
description = "Check Rust formatting"
command = "cargo"
args = ["fmt", "--", "--check"]
[tasks.clippy]
description = "Run Rust linter"
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]
[tasks.fmt-python]
description = "Format Python code"
script = '''
if command -v black &> /dev/null; then
black examples/python/
else
echo "black not installed. Skipping Python formatting."
fi
'''
[tasks.update]
description = "Update all dependencies"
script = '''
echo "Updating Rust dependencies..."
cargo update
echo "Updating Node.js CLI dependencies..."
cd cli/node && npm update
echo "Updating web example dependencies..."
cd ../../examples/web && pnpm update
echo "Dependencies updated!"
'''
[tasks.serve-docs]
description = "Serve documentation locally"
dependencies = ["docs"]
script = '''
echo "Serving documentation at http://localhost:8000"
python3 -m http.server 8000 --directory target/doc
'''
[tasks.size]
description = "Show binary sizes"
script = '''
echo "Binary sizes:"
ls -lh target/release/proofmode 2>/dev/null || echo "Rust binary not built"
ls -lh target/release/*.so 2>/dev/null || echo "Shared libraries not built"
ls -lh pkg/*.wasm 2>/dev/null || echo "WASM not built"
'''
[tasks.todo]
description = "Show TODO items in code"
script = '''
echo "TODO items in code:"
grep -r "TODO" src/ --exclude-dir=target || echo "No TODOs found"
'''
[tasks.verify-setup]
description = "Verify development setup"
script = '''
echo "Verifying development setup..."
echo ""
echo "Rust: $(rustc --version)"
echo "Cargo: $(cargo --version)"
echo "Python: $(python3 --version 2>/dev/null || echo 'not found')"
echo "Ruby: $(ruby --version 2>/dev/null || echo 'not found')"
echo "Node.js: $(node --version 2>/dev/null || echo 'not found')"
echo "pnpm: $(pnpm --version 2>/dev/null || echo 'not found')"
echo "wasm-pack: $(wasm-pack --version 2>/dev/null || echo 'not found')"
echo "cross: $(cross --version 2>/dev/null || echo 'not found')"
echo "Docker: $(docker --version 2>/dev/null || echo 'not found')"
echo ""
echo "Checking targets..."
rustup target list --installed
echo ""
echo "Checking WASM packages..."
ls -la pkg-web/ 2>/dev/null || echo "Web WASM package not built"
ls -la pkg-node/ 2>/dev/null || echo "Node WASM package not built"
'''
[tasks.dev-web]
description = "Full web development setup"
dependencies = ["wasm-pack-web", "web-dev"]
[tasks.dev-cli]
description = "CLI development setup"
dependencies = ["build-rust", "wasm-pack-node", "setup-node"]
[tasks.dev-mobile]
description = "Mobile development setup"
dependencies = ["install-targets", "build-mobile", "generate-bindings"]
[tasks.quick-test]
description = "Quick test suite for development"
dependencies = ["test-rust", "test-cli"]
[tasks.dev]
description = "Start development (build and watch)"
dependencies = ["build-debug"]
script = '''
echo "Development build complete. Use 'cargo make watch' for auto-rebuild."
'''
[tasks.ci]
description = "Run full CI pipeline"
dependencies = ["fmt-check", "clippy", "test", "build", "wasm-pack-all", "docker-test"]
[tasks.publish-all]
description = "Publish to all package registries"
script = '''
echo "Publishing packages..."
echo "1. Rust: cargo publish"
echo "2. Python: cargo make python-publish"
echo "3. Ruby: cd examples/ruby && gem push *.gem"
echo "4. NPM: cargo make wasm-publish"
echo ""
echo "Run each command when ready to publish."
'''
[tasks.set-version]
description = "Set version across all packages. Usage: cargo make set-version 0.9.0"
script = '''
VERSION="${@}"
if [ -z "$VERSION" ]; then
echo "Usage: cargo make set-version <version>"
echo "Example: cargo make set-version 0.9.0"
exit 1
fi
echo "Setting version to ${VERSION}..."
# Cargo.toml (line 3: version = "...")
sed -i "0,/^version = \".*\"/s//version = \"${VERSION}\"/" Cargo.toml
# pyproject.toml files
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" cli/python/pyproject.toml
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" scripts/pyproject.toml
# Ruby gemspec
sed -i "s/s\.version = \".*\"/s.version = \"${VERSION}\"/" ruby/proofmode.gemspec
# Node package.json files
for f in cli/node/package.json; do
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" "$f"
done
# GitLab CI
sed -i "s/PACKAGE_VERSION: \".*\"/PACKAGE_VERSION: \"${VERSION}\"/" .gitlab-ci.yml
# Update Cargo.lock
cargo generate-lockfile 2>/dev/null
echo "Version updated to ${VERSION} in all packages."
echo ""
echo "Files updated:"
echo " - Cargo.toml"
echo " - Cargo.lock"
echo " - pyproject.toml"
echo " - cli/python/pyproject.toml"
echo " - scripts/pyproject.toml"
echo " - ruby/proofmode.gemspec"
echo " - cli/node/package.json"
echo " - .gitlab-ci.yml"
'''
[tasks.b]
alias = "build"
[tasks.t]
alias = "test"
[tasks.r]
alias = "run"
[tasks.c]
alias = "check"