87 lines
3.5 KiB
Bash
Executable File
87 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# dev-sync.sh — manage the lum_ccc_rust dependency in lum_ccc_fplugin
|
|
#
|
|
# Usage:
|
|
# ./scripts/dev-sync.sh --update After pushing changes to lum_ccc_rust:
|
|
# updates Cargo.lock to the new HEAD of trunk
|
|
# and clears the Cargokit build cache.
|
|
#
|
|
# ./scripts/dev-sync.sh --local Switch Cargo.toml to path deps for fast
|
|
# local iteration (no git fetch, no lock churn).
|
|
#
|
|
# ./scripts/dev-sync.sh --git Switch Cargo.toml back to git deps for
|
|
# CI / Flutter builds.
|
|
#
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
RUST_DIR="$PLUGIN_ROOT/rust"
|
|
FLUTTER_APP="${FLUTTER_APP:-/Volumes/LUM/source/letusmsg_proj/app/letusmsg_app/flutter_src}"
|
|
CARGOKIT_BUILD_CACHE="$FLUTTER_APP/build/ccc_cryptography"
|
|
|
|
CARGO_TOML="$RUST_DIR/Cargo.toml"
|
|
LOCAL_CORE_PATH="/Volumes/LUM/source/letusmsg_proj/app/lum_ccc_rust/crates/ccc-crypto-core"
|
|
LOCAL_WOLFSSL_PATH="/Volumes/LUM/source/letusmsg_proj/app/lum_ccc_rust/crates/ccc-crypto-wolfssl"
|
|
GIT_URL="ssh://git@10.0.5.109/j3g/lum_ccc_rust.git"
|
|
GIT_BRANCH="trunk"
|
|
|
|
usage() {
|
|
sed -n '/^# Usage:/,/^[^#]/p' "$0" | grep '^#' | sed 's/^# \?//'
|
|
exit 1
|
|
}
|
|
|
|
cmd_update() {
|
|
echo "==> Fetching latest $GIT_BRANCH from $GIT_URL ..."
|
|
cd "$RUST_DIR"
|
|
cargo update -p ccc-crypto-core -p ccc-crypto-wolfssl
|
|
NEW_HASH="$(grep -A2 'name = "ccc-crypto-wolfssl"' Cargo.lock | grep -o '#[a-f0-9]*' | head -1)"
|
|
|
|
if [ -d "$CARGOKIT_BUILD_CACHE" ]; then
|
|
echo "==> Clearing Cargokit build cache at $CARGOKIT_BUILD_CACHE ..."
|
|
rm -rf "$CARGOKIT_BUILD_CACHE"
|
|
fi
|
|
|
|
# Collect all changed files relative to plugin root
|
|
cd "$PLUGIN_ROOT"
|
|
CHANGED="$(git diff --name-only HEAD)"
|
|
|
|
echo ""
|
|
echo "================================================================================"
|
|
echo " NEXT: commit and push lum_ccc_fplugin for changes to take effect"
|
|
echo "================================================================================"
|
|
}
|
|
|
|
cmd_local() {
|
|
echo "==> Switching to path dependencies (local dev mode) ..."
|
|
# Comment out git deps, uncomment path deps
|
|
sed -i '' \
|
|
-e 's|^ccc-crypto-core = { git = .*|# ccc-crypto-core = { git = "'"$GIT_URL"'", branch = "'"$GIT_BRANCH"'" }|' \
|
|
-e 's|^ccc-crypto-wolfssl = { git = .*|# ccc-crypto-wolfssl = { git = "'"$GIT_URL"'", branch = "'"$GIT_BRANCH"'" }|' \
|
|
-e 's|^# ccc-crypto-core = { path = |ccc-crypto-core = { path = |' \
|
|
-e 's|^# ccc-crypto-wolfssl = { path = |ccc-crypto-wolfssl = { path = |' \
|
|
"$CARGO_TOML"
|
|
echo "==> Done. Cargo.toml now uses local path deps."
|
|
echo " Run 'cargo build' directly in $RUST_DIR for fast iteration."
|
|
echo " Run '$0 --git' to switch back before committing."
|
|
}
|
|
|
|
cmd_git() {
|
|
echo "==> Switching back to git dependencies ..."
|
|
sed -i '' \
|
|
-e 's|^# ccc-crypto-core = { git = |ccc-crypto-core = { git = |' \
|
|
-e 's|^# ccc-crypto-wolfssl = { git = |ccc-crypto-wolfssl = { git = |' \
|
|
-e 's|^ccc-crypto-core = { path = |# ccc-crypto-core = { path = |' \
|
|
-e 's|^ccc-crypto-wolfssl = { path = |# ccc-crypto-wolfssl = { path = |' \
|
|
"$CARGO_TOML"
|
|
echo "==> Done. Cargo.toml now uses git deps."
|
|
echo " Run '$0 --update' if you want to pull the latest trunk commit."
|
|
}
|
|
|
|
case "${1:-}" in
|
|
--update) cmd_update ;;
|
|
--local) cmd_local ;;
|
|
--git) cmd_git ;;
|
|
*) usage ;;
|
|
esac
|