#!/usr/bin/env bash # Stage another checkout of the base board as target/board, so that cargo's `paths` # override can put it in place of the pinned pcengine-rust for this crate and the add-ons. # # Why a staged copy and not a [patch] line: cargo replaces a package only by one of # the same package name. The # add-on crates ask for the package `pcengine-rust`; the speed fork's package is # `pcengine-rust-fast` (its library is pcengine_rust, as wanted). So its manifest is # copied here with the one name changed, and its sources beside it, untouched. Once # the fork's package carries the base's name (or the boards are pinned by git and the # fork is a branch), this script goes and the override is one line. # Usage: scripts/stage-board.sh ../pcengine-rust-fast set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT" FROM=$(cd "$1" && pwd) [ -f "$FROM/Cargo.toml" ] && [ -d "$FROM/src" ] || { echo "$1 is not a board checkout"; exit 1; } grep -q '^name = "pcengine_rust"' "$FROM/Cargo.toml" || { echo "$1 does not build the library pcengine_rust"; exit 1; } mkdir -p target/board rsync -a --delete "$FROM/src/" target/board/src/ # The package's name, and its path dependencies made absolute (they were relative to the checkout). sed -e '0,/^name = ".*"/s//name = "pcengine-rust"/' \ -e "s#path = \"\\.\\./#path = \"$(dirname "$FROM")/#g" \ "$FROM/Cargo.toml" > target/board/Cargo.toml echo "staged $FROM ($(git -C "$FROM" rev-parse --short HEAD 2>/dev/null || echo "no commit")) as target/board"