#!/usr/bin/env bash # Kitedesk fork, 2026: builds macos/test/texture_rgba_renderer_plugin_test.m with # the plugin sources of macos/Classes against FlutterMacOS.framework, by default # the darwin-x64 engine artifacts of the Flutter SDK on PATH (or FLUTTER_ROOT) as # `flutter precache --macos` leaves them, and runs each test in its own process. # Swift 5 mode, as the podspec. No app, window or screen capture; Metal is used # without a display. # run_tests.sh plain build # run_tests.sh --asan the same with AddressSanitizer # run_tests.sh --tsan the same with ThreadSanitizer # FLUTTER_MACOS_FRAMEWORKS: the directory holding FlutterMacOS.framework. # OUT_DIR (default: a new temporary directory) receives the build. set -euo pipefail here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) classes=$here/../Classes if [ -z "${FLUTTER_MACOS_FRAMEWORKS:-}" ]; then root=${FLUTTER_ROOT:-$(dirname "$(dirname "$(readlink -f "$(command -v flutter)")")")} FLUTTER_MACOS_FRAMEWORKS=$root/bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.xcframework/macos-arm64_x86_64 fi frameworks=$FLUTTER_MACOS_FRAMEWORKS [ -f "$frameworks/FlutterMacOS.framework/Headers/FlutterTexture.h" ] || { echo "no FlutterMacOS.framework in $frameworks" \ "(flutter precache --macos, or set FLUTTER_MACOS_FRAMEWORKS)" >&2 exit 2 } out=${OUT_DIR:-$(mktemp -d)} mkdir -p "$out/include/texture_rgba_renderer" sanitizer=() case "${1:-}" in "") ;; --asan) sanitizer=(-sanitize=address) ;; --tsan) sanitizer=(-sanitize=thread) export TSAN_OPTIONS=${TSAN_OPTIONS:-halt_on_error=1} ;; *) echo "usage: $0 [--asan | --tsan]" >&2; exit 2 ;; esac clang_sanitizer=() [ ${#sanitizer[@]} -eq 0 ] || clang_sanitizer=("-f${sanitizer[0]#-}" -fno-omit-frame-pointer) cache=$out/module-cache xcrun swiftc -c -wmo -g -O -swift-version 5 -parse-as-library -module-name texture_rgba_renderer \ ${sanitizer[@]+"${sanitizer[@]}"} -F "$frameworks" -module-cache-path "$cache" \ -emit-objc-header-path "$out/include/texture_rgba_renderer/texture_rgba_renderer-Swift.h" \ "$classes"/*.swift -o "$out/plugin.o" objc=(xcrun clang -c -g -O1 -fobjc-arc -fmodules -fmodules-cache-path="$cache" ${clang_sanitizer[@]+"${clang_sanitizer[@]}"} -F "$frameworks" -I "$out/include") "${objc[@]}" "$classes/TextureRgbaApi.m" -o "$out/api.o" "${objc[@]}" -Wall -Werror "$here/texture_rgba_renderer_plugin_test.m" -o "$out/test.o" bin=$out/texture_rgba_renderer_plugin_test xcrun swiftc ${sanitizer[@]+"${sanitizer[@]}"} -F "$frameworks" -framework FlutterMacOS \ -framework CoreVideo -framework IOSurface -framework Metal -Xlinker -rpath -Xlinker "$frameworks" \ "$out/plugin.o" "$out/api.o" "$out/test.o" -o "$bin" count=0 failed=0 for test in $("$bin" --list); do count=$((count + 1)) if "$bin" "$test"; then echo "PASS $test" else echo "FAIL $test" failed=$((failed + 1)) fi done echo "$count tests, $((count - failed)) passed, $failed failed" [ "$failed" -eq 0 ]