Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tools/macos-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions tools/release/find-scanner.sh
Original file line number Diff line number Diff line change
@@ -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-<hash>/out/build/ (Cargo 1.99 and earlier)
# build/dstudio-engine/<hash>/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 <cargo profile dir, e.g. target/release>}
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"
3 changes: 1 addition & 2 deletions tools/release/package-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/release/package-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion tools/release/package-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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-<hash>\out; 1.100 and later: build\dstudio-engine\<hash>\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
Expand Down
41 changes: 41 additions & 0 deletions tools/release/test-find-scanner.sh
Original file line number Diff line number Diff line change
@@ -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"
Loading