diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6b55ce6..c5c52e9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,6 +18,10 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - name: Build outside the checkout + # The doc scripts are to find what cargo built where cargo put it, + # which CARGO_TARGET_DIR or a configured target-dir moves out of target/. + run: echo "CARGO_TARGET_DIR=$RUNNER_TEMP/target" >> "$GITHUB_ENV" - uses: dtolnay/rust-toolchain@master with: toolchain: 1.97.1 diff --git a/changelog.d/+docs-target-dir.misc.md b/changelog.d/+docs-target-dir.misc.md new file mode 100644 index 0000000..1274171 --- /dev/null +++ b/changelog.d/+docs-target-dir.misc.md @@ -0,0 +1,2 @@ +`scripts/build-docs.sh` and `docs/examples/sidecar-demo.sh` ask `cargo metadata` for the target directory, so the book's transcripts and API docs come from the builds cargo just made when `CARGO_TARGET_DIR` or a configured target-dir moves them out of `target/`. +They read `target/` under the checkout, and ran stale binaries or none; the docs workflow now builds outside the checkout. diff --git a/docs/examples/sidecar-demo.sh b/docs/examples/sidecar-demo.sh index b3adbcf..dd3255f 100755 --- a/docs/examples/sidecar-demo.sh +++ b/docs/examples/sidecar-demo.sh @@ -3,9 +3,13 @@ set -euo pipefail root=$(cd "$(dirname "$0")/../.." && pwd) -sidecar="$root/target/debug/rfc9162-sidecar" -demo_key="$root/target/debug/demo_key" -show="$root/target/debug/show_checkpoint" +# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured +# target-dir moves them out of target/. +target=$(cd "$root" && cargo metadata --locked --format-version 1 --no-deps | + python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])') +sidecar="$target/debug/rfc9162-sidecar" +demo_key="$target/debug/demo_key" +show="$target/debug/show_checkpoint" work=$(mktemp -d) trap 'rm -rf "$work"' EXIT cd "$work" diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh index 0ae68cb..a823449 100755 --- a/scripts/build-docs.sh +++ b/scripts/build-docs.sh @@ -10,8 +10,13 @@ if ! command -v mdbook >/dev/null 2>&1; then exit 1 fi +# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured +# target-dir moves them out of target/. +target=$(cargo metadata --locked --format-version 1 --no-deps | + python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])') + export RUSTDOCFLAGS="-D warnings" -rm -rf "$root/target/doc" +rm -rf "$target/doc" cargo doc --locked --no-deps -p rfc9162 -p rfc9162-tiles -p rfc9162-log bash "$root/scripts/regen-doc-output.sh" @@ -28,4 +33,4 @@ rm -f "$err" rm -rf "$root/docs/book/api" mkdir -p "$root/docs/book/api" -cp -a "$root/target/doc/." "$root/docs/book/api/" +cp -a "$target/doc/." "$root/docs/book/api/"