oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1"""Bundle the local development app. Distribution signing is a separate step."""
2from pathlib import Path
3import plistlib
4import shutil
5import subprocess
6import sys
7
8configuration = sys.argv[1] if len(sys.argv) > 1 else 'debug'
9if configuration not in ('debug', 'release'): raise ValueError('invalid build configuration')
10root = Path(__file__).resolve().parent.parent
11products = Path(subprocess.check_output(['swift', 'build', '--package-path', str(root / 'apple'), '--configuration', configuration, '--show-bin-path'], text=True).strip())
12bundle = root / 'build/Calls.app/Contents'
13if bundle.parent.exists(): shutil.rmtree(bundle.parent)
14(bundle / 'MacOS').mkdir(parents=True, exist_ok=True)
15(bundle / 'Frameworks').mkdir(parents=True, exist_ok=True)
16(bundle / 'Resources').mkdir(parents=True, exist_ok=True)
17shutil.copy2(products / 'CallsMac', bundle / 'MacOS/CallsMac')
18subprocess.run(['swift', str(root / 'scripts/generate-mac-icon.swift')], check=True)
19icon = root / 'apple/Sources/CallsMac/Resources/MacIcon.png'
20shutil.copy2(icon, bundle / 'Resources/MacIcon.png')
21shutil.copy2(root / 'LICENSE.lucide', bundle / 'Resources/LICENSE.lucide')
22shutil.copy2(root / 'LICENSE.rnnoise', bundle / 'Resources/LICENSE.rnnoise')
23shutil.copy2(root / 'LICENSE.deepfilternet', bundle / 'Resources/LICENSE.deepfilternet')
24# The Rust crates libdf links (scripts/deepfilter-notices.py) and WebRTC's
25# own licence, for the LiveKitWebRTC framework embedded below.
26shutil.copy2(root / 'LICENSE.deepfilternet-crates', bundle / 'Resources/LICENSE.deepfilternet-crates')
27shutil.copy2(root / 'LICENSE.webrtc', bundle / 'Resources/LICENSE.webrtc')
28shutil.copy2(root / 'PATENTS.webrtc', bundle / 'Resources/PATENTS.webrtc')
29# The Mac's noise suppressor model (scripts/build-deepfilter.sh). Without
30# it the app falls back to RNNoise.
31shutil.copy2(root / 'build/DeepFilterNet3_onnx.tar.gz', bundle / 'Resources/DeepFilterNet3_onnx.tar.gz')
32# Finder reads the ICNS before the app launches; the PNG also supplies the
33# runtime Dock icon. Generate each required representation from the master.
34iconset = root / 'build/AppIcon.iconset'
35iconset.mkdir(parents=True, exist_ok=True)
36for size in (16, 32, 128, 256, 512):
37 for scale in (1, 2):
38 name = f'icon_{size}x{size}' + ('@2x' if scale == 2 else '') + '.png'
39 subprocess.run(['sips', '-z', str(size * scale), str(size * scale),
40 str(icon), '--out', str(iconset / name)],
41 check=True, stdout=subprocess.DEVNULL)
42subprocess.run(['iconutil', '-c', 'icns', str(iconset), '-o',
43 str(bundle / 'Resources/CallsMac.icns')], check=True)
44info = {
45 'CFBundleURLTypes': [{'CFBundleURLName': 'net.amadan.oficina.calls.join',
46 'CFBundleURLSchemes': ['oficina-calls']}],
47 'CFBundleName': 'Calls', 'CFBundleDisplayName': 'Calls',
48 'CFBundleIdentifier': 'net.amadan.oficina.calls',
49 'CFBundleExecutable': 'CallsMac', 'CFBundlePackageType': 'APPL',
50 'CFBundleIconFile': 'CallsMac.icns',
51 'CFBundleShortVersionString': '0.1.0', 'CFBundleVersion': '1',
52 'LSMinimumSystemVersion': '14.0', 'NSHighResolutionCapable': True,
53 'NSCameraUseContinuityCameraDeviceType': True,
54 'NSCameraUsageDescription': 'Calls uses your camera to share video in a meeting.',
55 'NSMicrophoneUsageDescription': 'Calls uses your microphone so people in the meeting can hear you.',
56}
57(bundle / 'Info.plist').write_bytes(plistlib.dumps(info))
58# SwiftPM links dynamic binary dependencies using @rpath. Embed just the macOS
59# slice rather than shipping iOS and simulator frameworks inside the Mac app.
60for xc in [root / 'build/CallsBridge.xcframework', *list((root / 'apple/.build/artifacts').rglob('LiveKitWebRTC.xcframework'))]:
61 manifest = plistlib.loads((xc / 'Info.plist').read_bytes())
62 for lib in manifest['AvailableLibraries']:
63 if lib['SupportedPlatform'] != 'macos':
64 continue
65 source = xc / lib['LibraryIdentifier'] / lib['LibraryPath']
66 binary = source / source.stem
67 if 'dynamically linked' not in subprocess.check_output(['file', str(binary)], text=True):
68 continue
69 dest = bundle / 'Frameworks' / source.name
70 if dest.exists(): shutil.rmtree(dest)
71 shutil.copytree(source, dest, symlinks=True)
72for resource in products.glob('*.bundle'):
73 shutil.copytree(resource, bundle / 'Resources' / resource.name, symlinks=True)
74subprocess.run(['install_name_tool', '-add_rpath', '@executable_path/../Frameworks', str(bundle / 'MacOS/CallsMac')], check=True)
75