PulseCanvas / app · pulsecanvas.ai / scripts / verify-vision-bundle.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Verify a locally generated, native-only visionOS app payload.""" |
| 3 | import argparse |
| 4 | import hashlib |
| 5 | import json |
| 6 | import plistlib |
| 7 | import subprocess |
| 8 | from pathlib import Path |
| 9 | |
| 10 | parser = argparse.ArgumentParser(description=__doc__) |
| 11 | parser.add_argument('app', type=Path) |
| 12 | args = parser.parse_args() |
| 13 | root = Path(__file__).resolve().parents[1] |
| 14 | app = args.app |
| 15 | info = plistlib.loads((app / 'Info.plist').read_bytes()) |
| 16 | assert info['CFBundleIdentifier'] == 'com.protomota.pulsecanvas' |
| 17 | assert info['UIDeviceFamily'] == [7] |
| 18 | assert not (app / 'Resources').exists(), 'Flat visionOS bundle must not use the legacy Resources layout' |
| 19 | payload = app / 'NativeAssets' |
| 20 | source = root / 'Sources/PulseCanvas/Resources' |
| 21 | expected = {x.name for x in source.glob('*.metal')} | {'Audio/PulseCanvas.mp3', 'NativeVisualizers.json'} |
| 22 | actual = {x.relative_to(payload).as_posix() for x in payload.rglob('*') if x.is_file()} |
| 23 | assert actual == expected |
| 24 | for relative in expected - {'NativeVisualizers.json'}: |
| 25 | assert (payload / relative).read_bytes() == (source / relative).read_bytes(), relative |
| 26 | catalog = json.loads((payload / 'NativeVisualizers.json').read_text()) |
| 27 | assert catalog == json.loads((source / 'NativeVisualizers.json').read_text()) |
| 28 | assert (app / 'Legal/PulseCanvas-LICENSE.txt').read_bytes() == (root / 'LICENSE').read_bytes() |
| 29 | assert (app / 'PrivacyInfo.xcprivacy').read_bytes() == (root / 'macOS/PrivacyInfo.xcprivacy').read_bytes() |
| 30 | assert not any(x.suffix.lower() in {'.milk', '.dylib'} or 'projectm' in x.name.lower() |
| 31 | or 'sparkle' in x.name.lower() for x in app.rglob('*')) |
| 32 | links = subprocess.check_output(['otool', '-L', str(app / info['CFBundleExecutable'])], text=True) |
| 33 | assert not any(x in links.lower() for x in ['projectm', 'sparkle', 'opengl']) |
| 34 | print(json.dumps(dict(nativeEffects=catalog['activeCount'], shaderFiles=len(expected)-2, |
| 35 | exactNativeBytes=True, noExternalEngineOrAssets=True, legalAndPrivacy=True, |
| 36 | executableSHA256=hashlib.sha256((app / info['CFBundleExecutable']).read_bytes()).hexdigest()), indent=2)) |