navi

Obsidian-style interactive graph viewer for org-roam: a native window on macOS, Linux and Windows, no Emacs package required.
git clone https://codeberg.org/ganten1998/navi.git
Log | Files | Refs | README

build-cross.sh (1958B)


      1 #!/usr/bin/env bash
      2 # Cross-build Navi release artifacts for Linux and Windows from a macOS host.
      3 #
      4 #   scripts/build-cross.sh          # builds + packages everything into dist/
      5 #
      6 # Requirements (all via Homebrew/cargo):
      7 #   brew install zig
      8 #   cargo install cargo-zigbuild cargo-xwin
      9 #   rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-pc-windows-msvc
     10 #
     11 # Note: if Homebrew's rust is also installed, its cargo/rustc shadow rustup's
     12 # on PATH and cross-target std libs won't be found — hence the PATH prefix.
     13 set -euo pipefail
     14 
     15 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
     16 cd "$ROOT"
     17 
     18 VERSION="$(grep '^version' navi/Cargo.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/')"
     19 GLIBC="2.32"   # floor for released Linux binaries
     20 
     21 TOOLCHAIN_BIN="$(rustup which cargo 2>/dev/null | xargs dirname || true)"
     22 [ -n "$TOOLCHAIN_BIN" ] && export PATH="$TOOLCHAIN_BIN:$HOME/.cargo/bin:$PATH"
     23 
     24 mkdir -p dist
     25 
     26 package_linux() { # $1 = rust target, $2 = artifact arch name
     27   local target="$1" arch="$2"
     28   local stage="dist/navi-${VERSION}-linux-${arch}"
     29   cargo zigbuild --release --target "${target}.${GLIBC}" -p navi
     30   rm -rf "$stage"; mkdir -p "$stage"
     31   cp "target/${target}/release/navi" "$stage/"
     32   cp assets/navi.desktop "$stage/"
     33   cp assets/icon.png "$stage/"
     34   tar -C dist -czf "${stage}.tar.gz" "navi-${VERSION}-linux-${arch}"
     35   rm -rf "$stage"
     36   echo "==> ${stage}.tar.gz"
     37 }
     38 
     39 echo "==> Navi $VERSION — Linux x86_64"
     40 package_linux x86_64-unknown-linux-gnu x86_64
     41 
     42 echo "==> Navi $VERSION — Linux aarch64"
     43 package_linux aarch64-unknown-linux-gnu aarch64
     44 
     45 echo "==> Navi $VERSION — Windows x86_64"
     46 cargo xwin build --release --target x86_64-pc-windows-msvc -p navi
     47 rm -f "dist/navi-${VERSION}-windows-x86_64.zip"
     48 (cd target/x86_64-pc-windows-msvc/release && zip -q "$ROOT/dist/navi-${VERSION}-windows-x86_64.zip" navi.exe)
     49 echo "==> dist/navi-${VERSION}-windows-x86_64.zip"
     50 
     51 ls -lh dist/navi-${VERSION}-* 2>/dev/null | sed 's/^/    /'