mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
InspectionModel.inspect started a detached read per call and published status, report and busy whenever any of them finished. A slow first inspection that completed after a fast second one replaced the newer report and status, and could clear busy while the newer read was still running. - Each inspect call takes a request number; a completion is applied only while it is still the latest, so stale success and stale failure are discarded. Picker, drag and drop and Finder Open With all go through inspect and share this. - A new selection clears the previous report, and a failed inspection of the latest file is shown in red above its report. - The read is unchanged: size checked before reading, balanced security-scoped access, nothing executed. The reader is injectable only for the smoke check. - --smoke-inspection-order drives the model with an injected slow and fast reader: slow then fast with either outcome, and busy held for the newer request while an older read finishes. scripts/build-app.sh runs it after --smoke. All four checks fail without the change. Ported from XenoraOSS/Xenora#423. Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>
77 lines
3.6 KiB
Bash
Executable File
77 lines
3.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# Build BetterXen.app (native ARM64) into build/BetterXen.app and run its smoke check.
|
|
# Requires: macOS on Apple Silicon, Rust 1.100 (aarch64-apple-darwin), Swift 6 toolchain.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
root=$(pwd)
|
|
|
|
fail() { echo "build-app: $*" >&2; exit 1; }
|
|
[ "$(uname -s)" = Darwin ] || fail "macOS is required"
|
|
[ "$(uname -m)" = arm64 ] || fail "a native arm64 host is required"
|
|
[ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 0 ] || fail "running under Rosetta is not supported"
|
|
command -v cargo >/dev/null || fail "cargo not found; install Rust 1.100"
|
|
command -v swift >/dev/null || fail "swift not found; install the Xcode command line tools"
|
|
|
|
target=aarch64-apple-darwin
|
|
# Match the app's LSMinimumSystemVersion so the static library links cleanly.
|
|
MACOSX_DEPLOYMENT_TARGET=14.0 cargo build --locked --release -p xenora-ffi --target "$target"
|
|
swift build --package-path app -c release --arch arm64 \
|
|
-Xlinker -L -Xlinker "$root/target/$target/release"
|
|
|
|
bundle="$root/build/BetterXen.app"
|
|
rm -rf "$bundle"
|
|
mkdir -p "$bundle/Contents/MacOS"
|
|
cp "$(swift build --package-path app -c release --arch arm64 --show-bin-path)/BetterXen" "$bundle/Contents/MacOS/BetterXen"
|
|
cat > "$bundle/Contents/Info.plist" <<PLIST
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>CFBundleExecutable</key><string>BetterXen</string>
|
|
<key>CFBundleIdentifier</key><string>org.macosporters.betterxen</string>
|
|
<key>CFBundleName</key><string>BetterXen</string>
|
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
<key>CFBundleShortVersionString</key><string>0.1.0</string>
|
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
<key>NSHighResolutionCapable</key><true/>
|
|
<key>CFBundleDocumentTypes</key>
|
|
<array>
|
|
<dict>
|
|
<key>CFBundleTypeName</key><string>Windows Executable</string>
|
|
<key>CFBundleTypeRole</key><string>Viewer</string>
|
|
<key>LSHandlerRank</key><string>Alternate</string>
|
|
<key>LSItemContentTypes</key>
|
|
<array><string>com.microsoft.windows-executable</string></array>
|
|
</dict>
|
|
</array>
|
|
</dict>
|
|
</plist>
|
|
PLIST
|
|
# Ad-hoc signature for local development only. No entitlements are requested:
|
|
# this build executes no guest code, so it needs no JIT entitlement.
|
|
codesign --force --sign - "$bundle"
|
|
|
|
binary="$bundle/Contents/MacOS/BetterXen"
|
|
[ "$(lipo -archs "$binary")" = arm64 ] || fail "executable is not arm64-only: $(lipo -archs "$binary")"
|
|
file "$binary"
|
|
# Only system libraries may be linked: anything else would be a host dependency
|
|
# shipped or expected outside macOS, which this bundle does not carry. List the
|
|
# dependencies once, print that listing and check the same output.
|
|
dependencies=$(otool -L "$binary") || fail "otool -L failed for $binary"
|
|
printf '%s\n' "$dependencies"
|
|
dependencies=$(printf '%s\n' "$dependencies" | tail -n +2 | awk '{print $1}')
|
|
# Every Swift executable links at least libSystem, so an empty list is an error.
|
|
[ -n "$dependencies" ] || fail "otool -L listed no dependencies for $binary"
|
|
for dependency in $dependencies; do
|
|
case "$dependency" in
|
|
/System/Library/*|/usr/lib/*) ;;
|
|
@rpath/*|@executable_path/*|@loader_path/*)
|
|
fail "executable links a bundle-relative library, but this bundle ships none: $dependency" ;;
|
|
*) fail "executable links a non-system library: $dependency" ;;
|
|
esac
|
|
done
|
|
"$binary" --smoke
|
|
"$binary" --smoke-inspection-order
|
|
echo "build-app: built $bundle"
|