-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_app_bundle.sh
More file actions
executable file
·110 lines (95 loc) · 3.15 KB
/
create_app_bundle.sh
File metadata and controls
executable file
·110 lines (95 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
set -e # Exit on error
echo "🔨 Building UntoldEditor app bundle..."
# Configuration
APP_NAME="Untold Engine Studio"
EXECUTABLE_NAME="UntoldEditor"
BUNDLE_ID="com.untoldengine.studio"
# Determine version (env -> release/* branch -> latest tag vX.Y.Z -> fallback)
detect_version() {
if [ -n "${VERSION:-}" ]; then
echo "$VERSION"; return
fi
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
if [[ "$branch" == release/* ]]; then
echo "${branch#release/}"; return
fi
tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [[ "$tag" == v* ]]; then
echo "${tag#v}"; return
fi
echo "0.0.0-dev"
}
VERSION="$(detect_version)"
BUILD_DIR=".build/arm64-apple-macosx/release"
APP_BUNDLE="$APP_NAME.app"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
UNTOLD_ENGINE_ROOT="$SCRIPT_DIR/../UntoldEngine"
METALLIB_PATH="$UNTOLD_ENGINE_ROOT/Sources/UntoldEngine/UntoldEngineKernels/UntoldEngineKernels.metallib"
# Clean previous bundle
echo "🧹 Cleaning previous bundle..."
rm -rf "$APP_BUNDLE"
# Build the executable with Swift Package Manager
echo "🔧 Building executable..."
swift build --configuration release
# Create app bundle structure
echo "📦 Creating app bundle structure..."
mkdir -p "$APP_BUNDLE/Contents/MacOS"
mkdir -p "$APP_BUNDLE/Contents/Resources"
# Copy the executable
echo "📋 Copying executable..."
cp "$BUILD_DIR/$EXECUTABLE_NAME" "$APP_BUNDLE/Contents/MacOS/$EXECUTABLE_NAME"
# Copy Metal shaders
if [ -f "$METALLIB_PATH" ]; then
echo "🎨 Copying Metal shaders..."
cp "$METALLIB_PATH" "$APP_BUNDLE/Contents/Resources/"
else
echo "⚠️ Warning: Metal shader library not found at $METALLIB_PATH"
fi
# Copy app icon if it exists
if [ -f "Resources/AppIcon.icns" ]; then
echo "🎨 Copying app icon..."
cp "Resources/AppIcon.icns" "$APP_BUNDLE/Contents/Resources/"
fi
# Create Info.plist
echo "📝 Creating Info.plist..."
# Check if icon exists to conditionally add it
ICON_ENTRY=""
if [ -f "Resources/AppIcon.icns" ]; then
ICON_ENTRY=" <key>CFBundleIconFile</key>\n <string>AppIcon</string>"
fi
cat > "$APP_BUNDLE/Contents/Info.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>$EXECUTABLE_NAME</string>
<key>CFBundleIdentifier</key>
<string>$BUNDLE_ID</string>
<key>CFBundleName</key>
<string>$APP_NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$VERSION</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
$(echo -e "$ICON_ENTRY")
</dict>
</plist>
EOF
# Make executable
chmod +x "$APP_BUNDLE/Contents/MacOS/$EXECUTABLE_NAME"
echo "✅ App bundle created successfully at: $APP_BUNDLE"
echo ""
echo "To test the app, run:"
echo " open $APP_BUNDLE"
echo ""
echo "Or double-click the app in Finder"