From 869c44a1be0ac635b9b9b2e7548284d83f21f7a9 Mon Sep 17 00:00:00 2001 From: Chris Laupama <42254688+chrislaupama@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:19:04 +0000 Subject: [PATCH] Release packaging: find the plugin scanner under Cargo 1.100's build layout Rust 1.100 (Nov 12) moved build script output from build/-/out to build///out. The release packaging looked for the plugin scanner with the old glob, so every package job (Linux, macOS, Windows) failed with "plugin scanner not found" as soon as the runners picked up the new stable toolchain. tools/release/find-scanner.sh now finds it under either layout and fails with a clear message; the Linux and macOS packaging scripts, the macOS build job and tools/macos-bundle.sh use it, and the Windows script matches both layouts. tools/release/test-find-scanner.sh checks both layouts, a Windows name, the newest of two builds and the failure cases, and runs in lint. --- .github/workflows/ci.yml | 2 ++ .github/workflows/release.yml | 8 ++---- tools/macos-bundle.sh | 2 +- tools/release/find-scanner.sh | 22 ++++++++++++++++ tools/release/package-linux.sh | 3 +-- tools/release/package-macos.sh | 2 +- tools/release/package-windows.ps1 | 3 ++- tools/release/test-find-scanner.sh | 41 ++++++++++++++++++++++++++++++ 8 files changed, 72 insertions(+), 11 deletions(-) create mode 100755 tools/release/find-scanner.sh create mode 100755 tools/release/test-find-scanner.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ba38830..f6f763dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,6 +90,8 @@ jobs: run: shellcheck -S warning tools/ci/*.sh tools/release/*.sh tools/*.sh - name: Change detection (tools/ci/changes.sh) run: tools/ci/test-changes.sh + - name: Release scanner lookup (tools/release/find-scanner.sh) + run: tools/release/test-find-scanner.sh - name: Agent skills run: python3 tools/agents/check_skills.py # Formatting is checked with a pinned toolchain (RUST_LINT_TOOLCHAIN, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee14de9c..ce38424b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,12 +130,8 @@ jobs: set -euo pipefail mkdir -p "build/macos-${{ matrix.arch }}" cp "target/${{ matrix.triple }}/release/device-studio" "build/macos-${{ matrix.arch }}/" - scanners=(target/${{ matrix.triple }}/release/build/dstudio-engine-*/out/build/dstudio_plugin_scanner) - if [ "${#scanners[@]}" -ne 1 ] || [ ! -f "${scanners[0]}" ]; then - echo "expected one plugin scanner, found: ${scanners[*]}" >&2 - exit 1 - fi - cp "${scanners[0]}" "build/macos-${{ matrix.arch }}/" + scanner=$(bash tools/release/find-scanner.sh "target/${{ matrix.triple }}/release") + cp "$scanner" "build/macos-${{ matrix.arch }}/" lipo -info "build/macos-${{ matrix.arch }}"/* - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: diff --git a/tools/macos-bundle.sh b/tools/macos-bundle.sh index 100bfd8f..b4ffa549 100755 --- a/tools/macos-bundle.sh +++ b/tools/macos-bundle.sh @@ -15,7 +15,7 @@ exe="${DSTUDIO_APP_EXE:-$release/device-studio}" scanner="${DSTUDIO_SCANNER_EXE:-}" if [ -z "$scanner" ]; then # build.rs builds the scanner in the engine's CMake tree under target/.../build. - scanner="$(ls -t "$(dirname "$exe")"/build/dstudio-engine-*/out/build/dstudio_plugin_scanner 2>/dev/null | head -1 || true)" + scanner="$(bash "$(dirname "$0")/release/find-scanner.sh" "$(dirname "$exe")" 2>/dev/null || true)" fi version="$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -1)" app="$out/Device.app" diff --git a/tools/release/find-scanner.sh b/tools/release/find-scanner.sh new file mode 100755 index 00000000..78793d19 --- /dev/null +++ b/tools/release/find-scanner.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Prints the plugin scanner that the dstudio-engine build script built under one Cargo +# profile directory (the newest, if there are several). +# +# tools/release/find-scanner.sh target/release +# tools/release/find-scanner.sh target/aarch64-apple-darwin/release +# +# The scanner sits in the build script's OUT_DIR, whose layout depends on the Cargo version: +# build/dstudio-engine-/out/build/ (Cargo 1.99 and earlier) +# build/dstudio-engine//out/build/ (Cargo 1.100 and later) +# Both are searched. Fails with a message when there is none. +set -euo pipefail +profile_dir=${1:?usage: find-scanner.sh } +name=dstudio_plugin_scanner +found=$(find "$profile_dir/build" -type f \( -name "$name" -o -name "$name.exe" \) \ + \( -path '*/build/dstudio-engine-*/out/build/*' -o -path '*/build/dstudio-engine/*/out/build/*' \) \ + -exec ls -t {} + 2>/dev/null | head -1 || true) +if [ -z "$found" ]; then + echo "error: no $name under $profile_dir/build (looked in dstudio-engine-*/out/build and dstudio-engine/*/out/build)" >&2 + exit 1 +fi +printf '%s\n' "$found" diff --git a/tools/release/package-linux.sh b/tools/release/package-linux.sh index 86446acf..9ca65bad 100755 --- a/tools/release/package-linux.sh +++ b/tools/release/package-linux.sh @@ -18,8 +18,7 @@ stage="$work/$name" mkdir -p "$stage/bin" "$stage/share/applications" "$out" install -m 755 "$release/device-studio" "$stage/bin/device-studio" -scanner="$(ls -t "$release"/build/dstudio-engine-*/out/build/dstudio_plugin_scanner 2>/dev/null | head -1)" -[ -n "$scanner" ] || { echo "plugin scanner not found under $release/build" >&2; exit 1; } +scanner="$(bash "$root/tools/release/find-scanner.sh" "$release")" install -m 755 "$scanner" "$stage/bin/dstudio_plugin_scanner" strip --strip-debug "$stage/bin/device-studio" "$stage/bin/dstudio_plugin_scanner" for doc in LICENSE README.md; do diff --git a/tools/release/package-macos.sh b/tools/release/package-macos.sh index d41a1ca0..8c740ea5 100755 --- a/tools/release/package-macos.sh +++ b/tools/release/package-macos.sh @@ -19,7 +19,7 @@ trap 'rm -rf "$work"' EXIT mkdir -p "$out" scanner_of() { # the scanner build.rs built for one target triple - ls -t "$target/$1"/release/build/dstudio-engine-*/out/build/dstudio_plugin_scanner 2>/dev/null | head -1 + bash "$root/tools/release/find-scanner.sh" "$target/$1/release" 2>/dev/null || true } if [ -n "${DSTUDIO_MACOS_ARM_DIR:-}" ] || [ -n "${DSTUDIO_MACOS_X86_DIR:-}" ]; then arm_app="${DSTUDIO_MACOS_ARM_DIR:?set both DSTUDIO_MACOS_ARM_DIR and DSTUDIO_MACOS_X86_DIR}/device-studio" diff --git a/tools/release/package-windows.ps1 b/tools/release/package-windows.ps1 index 41c1ed17..850a97de 100644 --- a/tools/release/package-windows.ps1 +++ b/tools/release/package-windows.ps1 @@ -24,8 +24,9 @@ if (Test-Path $stage) { Remove-Item -Recurse -Force $stage } New-Item -ItemType Directory -Path $stage | Out-Null Copy-Item (Join-Path $release 'device-studio.exe') $stage +# Cargo 1.99 and earlier: build\dstudio-engine-\out; 1.100 and later: build\dstudio-engine\\out. $scanner = Get-ChildItem -Path (Join-Path $release 'build') -Filter 'dstudio_plugin_scanner.exe' -Recurse | - Where-Object { $_.FullName -match 'dstudio-engine-[^\\]+\\out\\build\\' } | + Where-Object { $_.FullName -match 'dstudio-engine(-[^\\]+|\\[^\\]+)\\out\\build\\' } | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if (-not $scanner) { throw 'plugin scanner not found under the release build directory' } Copy-Item $scanner.FullName $stage diff --git a/tools/release/test-find-scanner.sh b/tools/release/test-find-scanner.sh new file mode 100755 index 00000000..aa8d400d --- /dev/null +++ b/tools/release/test-find-scanner.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Tests tools/release/find-scanner.sh against both Cargo build-directory layouts. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +fail=0 +expect() { # name, expected path ("" = failure), profile dir + local got + got=$(bash "$here/find-scanner.sh" "$3" 2>/dev/null) || got="" + if [ "$got" != "$2" ]; then + echo "FAIL $1: got [$got], want [$2]" + fail=1 + fi +} +put() { mkdir -p "$(dirname "$1")" && : > "$1"; } + +old="$tmp/old/release/build/dstudio-engine-0123abcd/out/build/dstudio_plugin_scanner" +put "$old" +expect "Cargo 1.99 layout" "$old" "$tmp/old/release" + +new="$tmp/new/release/build/dstudio-engine/0123abcd/out/build/dstudio_plugin_scanner" +put "$new" +expect "Cargo 1.100 layout" "$new" "$tmp/new/release" + +win="$tmp/win/release/build/dstudio-engine/0123abcd/out/build/dstudio_plugin_scanner.exe" +put "$win" +expect "Windows name" "$win" "$tmp/win/release" + +put "$tmp/two/release/build/dstudio-engine/aaaa/out/build/dstudio_plugin_scanner" +touch -d '2026-01-01' "$tmp/two/release/build/dstudio-engine/aaaa/out/build/dstudio_plugin_scanner" +newest="$tmp/two/release/build/dstudio-engine/bbbb/out/build/dstudio_plugin_scanner" +put "$newest" +expect "newest of two" "$newest" "$tmp/two/release" + +put "$tmp/other/release/build/some-other-crate/0123/out/build/dstudio_plugin_scanner" +expect "another crate's file" "" "$tmp/other/release" +expect "no build dir" "" "$tmp/missing/release" + +[ "$fail" = 0 ] && echo "find-scanner: all checks passed" +exit "$fail"