PulseCanvas / app · pulsecanvas.ai / scripts / build-creators-local.sh
| 1 | #!/bin/bash |
| 2 | set -euo pipefail |
| 3 | cd "$(dirname "$0")/.." |
| 4 | if [[ ! -f .build/projectm/install/lib/libprojectM-4.4.2.0.dylib ]]; then ./scripts/build-projectm.sh; fi |
| 5 | if [[ ! -d .build/sparkle/Sparkle.framework ]]; then python3 scripts/prepare-sparkle.py; fi |
| 6 | python3 scripts/native-visualizer-catalog.py --output Sources/PulseCanvas/Resources/NativeVisualizers.json |
| 7 | app="${1:-$PWD/build/local-testing/PulseCanvas Studio Creators Local.app}" |
| 8 | if [[ -e "$app" ]]; then mv "$app" "$app.previous-$(date +%Y%m%d-%H%M%S)"; fi |
| 9 | mkdir -p "$app/Contents/MacOS" "$app/Contents/Frameworks" "$app/Contents/Resources" |
| 10 | swiftpm=(--scratch-path "$PWD/.build/creators-local" --arch arm64 -c release |
| 11 | -Xswiftc -D -Xswiftc DIRECT_BUILD -Xswiftc -D -Xswiftc LOCAL_BUILD |
| 12 | -Xswiftc -F -Xswiftc "$PWD/.build/sparkle" |
| 13 | -Xlinker -rpath -Xlinker @executable_path/../Frameworks) |
| 14 | swift build "${swiftpm[@]}" |
| 15 | products="$(swift build "${swiftpm[@]}" --show-bin-path)" |
| 16 | cp "$products/PulseCanvas" "$app/Contents/MacOS/PulseCanvas" |
| 17 | for bundle in PulseCanvas_PulseCanvas ZIPFoundation_ZIPFoundation; do |
| 18 | ditto "$products/$bundle.bundle" "$app/Contents/Resources/$bundle.bundle" |
| 19 | done |
| 20 | ditto .build/sparkle/Sparkle.framework "$app/Contents/Frameworks/Sparkle.framework" |
| 21 | cp .build/projectm/install/lib/libprojectM-4.4.2.0.dylib "$app/Contents/Frameworks/libprojectM.dylib" |
| 22 | install_name_tool -id @rpath/libprojectM.dylib "$app/Contents/Frameworks/libprojectM.dylib" |
| 23 | xcrun xcstringstool compile Localization/Localizable.xcstrings --output-directory "$app/Contents/Resources" |
| 24 | ./scripts/prepare-legal-resources.sh "$app/Contents/Resources/Legal" |
| 25 | cp .build/sparkle/LICENSE "$app/Contents/Resources/Legal/Sparkle-LICENSE.txt" |
| 26 | cp macOS/PrivacyInfo.xcprivacy "$app/Contents/Resources/PrivacyInfo.xcprivacy" |
| 27 | xcrun swift scripts/build-icon.swift .build/AppIcon.iconset |
| 28 | xcrun iconutil -c icns .build/AppIcon.iconset -o "$app/Contents/Resources/AppIcon.icns" |
| 29 | python3 - "$app" <<'PY' |
| 30 | import json,plistlib,re,sys |
| 31 | from pathlib import Path |
| 32 | app=Path(sys.argv[1]);settings=dict(re.findall(r'^(\w+) = (.+)$',(Path('Version.xcconfig').read_text() + '\n' + Path('macOS/Release.xcconfig').read_text()),re.M)) |
| 33 | info=plistlib.loads(Path('macOS/Info.plist').read_bytes()) |
| 34 | info.update(CFBundleExecutable='PulseCanvas',CFBundleIdentifier='com.protomota.pulsecanvas.creators-local',CFBundleName='PulseCanvas Studio Creators Local',CFBundleDisplayName='PulseCanvas Studio Creators Local',CFBundleShortVersionString=settings['MARKETING_VERSION'],CFBundleVersion=settings['CURRENT_PROJECT_VERSION'],LSMinimumSystemVersion='14.0',PulseCanvasLocalTesting=True,SUEnableAutomaticChecks=False) |
| 35 | for key in ['SUFeedURL','SUPublicEDKey']:info.pop(key,None) |
| 36 | (app/'Contents/Info.plist').write_bytes(plistlib.dumps(info)) |
| 37 | PY |
| 38 | # Local-only ad-hoc signing needs no Keychain access or distribution credentials. |
| 39 | codesign --force --deep --sign - "$app" |
| 40 | codesign --verify --deep --strict "$app" |
| 41 | python3 scripts/preset-provenance.py --app "$app" |
| 42 | printf 'Local Creators app: %s\n' "$app" |