mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-05-22 23:41:44 +03:00
MacOS support (#225)
This commit is contained in:
30
packaging/create_icon.sh
Normal file
30
packaging/create_icon.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Create icon.icns from icon.ico for macOS app
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
python3 -c "
|
||||
from PIL import Image
|
||||
img = Image.open('$PROJECT_DIR/icon.ico')
|
||||
img = img.resize((1024, 1024), Image.LANCZOS)
|
||||
img.save('$PROJECT_DIR/icon_1024.png', 'PNG')
|
||||
"
|
||||
|
||||
mkdir -p "$PROJECT_DIR/icon.iconset"
|
||||
sips -z 16 16 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_16x16.png"
|
||||
sips -z 32 32 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_16x16@2x.png"
|
||||
sips -z 32 32 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_32x32.png"
|
||||
sips -z 64 64 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_32x32@2x.png"
|
||||
sips -z 128 128 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_128x128.png"
|
||||
sips -z 256 256 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_128x128@2x.png"
|
||||
sips -z 256 256 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_256x256.png"
|
||||
sips -z 512 512 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_256x256@2x.png"
|
||||
sips -z 512 512 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_512x512.png"
|
||||
sips -z 1024 1024 "$PROJECT_DIR/icon_1024.png" --out "$PROJECT_DIR/icon.iconset/icon_512x512@2x.png"
|
||||
iconutil -c icns "$PROJECT_DIR/icon.iconset" -o "$PROJECT_DIR/icon.icns"
|
||||
|
||||
rm -rf "$PROJECT_DIR/icon.iconset" "$PROJECT_DIR/icon_1024.png"
|
||||
|
||||
echo "icon.icns created: $PROJECT_DIR/icon.icns"
|
||||
83
packaging/macos.spec
Normal file
83
packaging/macos.spec
Normal file
@@ -0,0 +1,83 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
[os.path.join(os.path.dirname(SPEC), os.pardir, 'macos.py')],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'rumps',
|
||||
'objc',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'PyObjCTools',
|
||||
'PyObjCTools.AppHelper',
|
||||
'cryptography.hazmat.primitives.ciphers',
|
||||
'cryptography.hazmat.primitives.ciphers.algorithms',
|
||||
'cryptography.hazmat.primitives.ciphers.modes',
|
||||
'cryptography.hazmat.backends.openssl',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
cipher=block_cipher,
|
||||
)
|
||||
|
||||
icon_path = os.path.join(os.path.dirname(SPEC), os.pardir, 'icon.icns')
|
||||
if not os.path.exists(icon_path):
|
||||
icon_path = None
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='TgWsProxy',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=False,
|
||||
console=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=False,
|
||||
upx_exclude=[],
|
||||
name='TgWsProxy',
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
coll,
|
||||
name='TG WS Proxy.app',
|
||||
icon=icon_path,
|
||||
bundle_identifier='com.tgwsproxy.app',
|
||||
info_plist={
|
||||
'CFBundleName': 'TG WS Proxy',
|
||||
'CFBundleDisplayName': 'TG WS Proxy',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'LSMinimumSystemVersion': '10.15',
|
||||
'LSUIElement': True,
|
||||
'NSHighResolutionCapable': True,
|
||||
'NSAppleEventsUsageDescription':
|
||||
'TG WS Proxy needs to display dialogs.',
|
||||
},
|
||||
)
|
||||
64
packaging/merge_universal2.sh
Normal file
64
packaging/merge_universal2.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Merge arm64 and x86_64 .app bundles into a universal2 .app and create DMG
|
||||
set -e
|
||||
|
||||
ARM_APP="$1"
|
||||
INTEL_APP="$2"
|
||||
OUT_APP="$3"
|
||||
|
||||
if [ -z "$ARM_APP" ] || [ -z "$INTEL_APP" ] || [ -z "$OUT_APP" ]; then
|
||||
echo "Usage: $0 <arm64.app> <x86_64.app> <output.app>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
DIST_DIR="$PROJECT_DIR/dist"
|
||||
APP_NAME="$(basename "$OUT_APP" .app)"
|
||||
DMG_NAME="TgWsProxy"
|
||||
|
||||
# --- Merge ---
|
||||
|
||||
echo "Merging '$ARM_APP' + '$INTEL_APP' -> '$OUT_APP'"
|
||||
|
||||
rm -rf "$OUT_APP"
|
||||
cp -R "$ARM_APP" "$OUT_APP"
|
||||
|
||||
find "$OUT_APP" -type f | while read -r file; do
|
||||
rel="${file#"$OUT_APP"/}"
|
||||
intel_file="$INTEL_APP/$rel"
|
||||
|
||||
[ -f "$intel_file" ] || continue
|
||||
|
||||
if file "$file" | grep -qE "Mach-O (64-bit )?executable|Mach-O (64-bit )?dynamically linked|Mach-O (64-bit )?bundle"; then
|
||||
arm_arch=$(lipo -archs "$file" 2>/dev/null || echo "")
|
||||
intel_arch=$(lipo -archs "$intel_file" 2>/dev/null || echo "")
|
||||
if [ "$arm_arch" = "$intel_arch" ]; then
|
||||
# same arch (e.g. local test with two arm64 copies) — skip
|
||||
continue
|
||||
fi
|
||||
lipo -create "$file" "$intel_file" -output "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Merge done: $OUT_APP"
|
||||
|
||||
# --- Create DMG ---
|
||||
|
||||
DMG_TEMP="$DIST_DIR/dmg_temp"
|
||||
rm -rf "$DMG_TEMP"
|
||||
mkdir -p "$DMG_TEMP"
|
||||
|
||||
cp -R "$OUT_APP" "$DMG_TEMP/"
|
||||
ln -s /Applications "$DMG_TEMP/Applications"
|
||||
|
||||
hdiutil create \
|
||||
-volname "$APP_NAME" \
|
||||
-srcfolder "$DMG_TEMP" \
|
||||
-ov \
|
||||
-format UDZO \
|
||||
"$DIST_DIR/$DMG_NAME.dmg"
|
||||
|
||||
rm -rf "$DMG_TEMP"
|
||||
|
||||
echo "DMG created: $DIST_DIR/$DMG_NAME.dmg"
|
||||
Reference in New Issue
Block a user