Files
2026-05-19 03:31:07 -07:00

184 lines
5.5 KiB
Makefile

# Default recipe: list all available recipes
_default:
just --list
TEST_ENSEMBLE_KEY := "malformed-datebook doctrine-bovine shrug-omit rigid-playback"
TEST_ENSEMBLE_KEY_TWO := "thus-glutton easel-grandpa outcast-rockslide plethora-creation"
# Build the Rust library for Android
[group: "build"]
build-rust:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
export ANDROID_HOME="$HOME/Android/Sdk"
export NDK_HOME="$ANDROID_HOME/ndk/28.0.13004108"
export PATH="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH"
export TARGET_CC="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang"
export TARGET_AR="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
export RUSTFLAGS="-C linker=$TARGET_CC -C link-arg=-Wl,-z,max-page-size=16384"
cd rust && cargo build --target aarch64-linux-android --package synchronicity_lib --release
[group: "gui"]
slint-preview path:
slint-viewer --auto-reload {{path}}
# Generate Kotlin types from Rust using Typeshare (via Gradle)
[group: "build"]
generate-types:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
cd android && ./gradlew generateKotlinTypes
# Generate Kotlin types using uniffi
[group: "build"]
uniffi-bindgen-generate:
cd rust && cargo run --bin uniffi-bindgen -- generate \
--library target/aarch64-linux-android/release/libsynchronicity.so \
--language kotlin \
--out-dir ../android/app/src/main/java/com/gregshuflin/synchronicity/uniffi/
# Build Android app (debug)
[group: "build"]
android-build:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
cd android && ./gradlew assembleDebug
# Run any gradlew command with the correct JDK
[group: "android"]
gradlew *args:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
cd android && ./gradlew {{args}}
# Run the PC graphical application
[group: "run"]
[env("RUST_LOG", "info")]
gui *args:
cargo run --manifest-path rust/gui-app/Cargo.toml --bin syn-gui -- {{args}}
# Run the cli from source
[group: "run-cli"]
[env("RUST_LOG", "info")]
cli *args:
cargo run --manifest-path rust/Cargo.toml --bin syn-cli -- {{args}}
[doc: "Run the cli with the canonical ensemble directory in test/store-dirs"]
[group: "run-cli"]
canon-cli *args:
just cli -s test/store-dirs/canonical {{args}}
# Initialize the test ensemble key in some dir
[group: "run-cli"]
init-test-ensemble-cli directory:
just cli init --store {{directory}} --keyphrase=\"{{TEST_ENSEMBLE_KEY}}\"
# Run the command line program without cargo from the target/ directory
[group: "run-cli"]
[env("RUST_LOG", "info")]
cli-fast *args:
./rust/target/debug/syn-cli {{args}}
# Run the CLI daemon in the foreground
[group: "run-cli"]
[env("RUST_LOG", "info")]
daemon-cli *args:
just cli daemon --foreground {{args}}
# Launch the TUI
[group: "run"]
tui-cli *args:
just cli tui {{args}}
# Build all Rust binaries (native)
[group: "build"]
build-native:
cd rust && cargo build
# Build all Rust binaries in release mode (native)
[group: "build"]
build-native-release:
cd rust && cargo build --release
# Run all formatters
[group: "format"]
fmt-all: fmt-kotlin fmt-rust
# Format Kotlin code with ktfmt
[group: "format"]
fmt-kotlin:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
cd android && ./gradlew ktfmtFormat
# Check Kotlin formatting (fails if unformatted)
[group: "format"]
fmt-kotlin-check:
#!/usr/bin/env bash
export JAVA_HOME=/opt/android-studio/jbr
cd android && ./gradlew ktfmtCheck
[doc: "Format rust with cargo fmt"]
[group: "format"]
fmt-rust:
cd rust && cargo fmt
[doc: "Format slint files with slint-lsp"]
[group: "format"]
fmt-slint:
slint-lsp format -i ./rust/gui-app/ui/*.slint
# Run all rust unit tests
[group: "test"]
unit-tests-rust *args:
cd rust && cargo nextest run {{args}}
# Run P2P integration tests (requires internet access for pkarr DNS)
[group: "test"]
integration-tests-p2p:
cd rust && cargo test --test p2p_ping
[group: "test"]
integration-tests-ensemble-gossip:
cd rust && cargo test --test ensemble_gossip
# Install desktop entry and icon for Wayland (user-local)
[group: "install"]
install-desktop:
mkdir -p ~/.local/share/applications
mkdir -p ~/.local/share/icons/hicolor/256x256/apps
cp assets/synchronicity.desktop ~/.local/share/applications/synchronicity.desktop
cp assets/synchronicity-icon.png ~/.local/share/icons/hicolor/256x256/apps/synchronicity.png
update-desktop-database ~/.local/share/applications
gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor
@echo "Desktop entry and icon installed."
# Uninstall desktop entry and icon
[group: "install"]
uninstall-desktop:
rm -f ~/.local/share/applications/synchronicity.desktop
rm -f ~/.local/share/icons/hicolor/256x256/apps/synchronicity.png
# Create two test stores (node_a, node_b) with deterministic keypairs for local P2P experimentation.
# Pass `reset=true` to wipe and recreate existing stores.
[group: "dev"]
test-env-setup dir="test-nodes" reset="":
cargo run --manifest-path rust/Cargo.toml --example setup_test_nodes -- {{dir}} {{if reset != "" { "--reset" } else { "" }}}
# Start daemon for test node_a (run test-env-setup first)
[group: "dev"]
test-env-daemon-a dir="test-nodes":
just daemon-cli --store {{dir}}/node_a
# Start daemon for test node_b (run test-env-setup first)
[group: "dev"]
test-env-daemon-b dir="test-nodes":
just daemon-cli --store {{dir}}/node_b