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"