forked from silverweed/lifish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeapp_osx.sh
executable file
·77 lines (66 loc) · 2.14 KB
/
makeapp_osx.sh
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
#!/bin/bash
# Create a Mac OSX app bundle.
# MUST be launched from the lifish directory
# The lifish executable MUST already exist.
if [[ $# < 1 ]]; then
echo "Usage: $0 <version>"
exit 1
fi
OUT_ZIP="lifish_BOOM_${1}_osx.zip"
APPNAME=Lifish
MACOS=(lifish)
RESOURCES=(assets levels.json)
FRAMEWORK_PATH=/Library/Frameworks
FRAMEWORKS=({FLAC,ogg,freetype,OpenAL,vorbis{,enc,file},sfml-{window,graphics,system,audio}}.framework)
for i in ${MACOS[@]} ${RESOURCES[@]}; do
[[ -e $i ]] || {
echo "$i not found in this directory." >&2
exit 1
}
done
for i in ${FRAMEWORKS[@]}; do
[[ -d "$FRAMEWORK_PATH/$i" ]] || {
echo "$i not found in $FRAMEWORK_PATH". >&2
exit 1
}
done
set -x
rm -rf "$APPNAME.app"
mkdir -p "$APPNAME.app"/Contents/{MacOS,Resources,Frameworks}
for i in ${FRAMEWORKS[@]}; do
cp -R "$FRAMEWORK_PATH/$i" "$APPNAME.app"/Contents/Frameworks/.
done
cat > "$APPNAME.app"/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>lifish</string>
<key>CFBundleIdentifier</key>
<string>github.com/silverweed/lifish</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>0.0</string>
<key>CFBundleName</key>
<string>lifish</string>
<key>CFBundleDisplayName</key>
<string>Lifish</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleIconFile</key>
<string>Lifish.icns</string>
</dict>
</plist>
EOF
cp -r ${MACOS[@]} "$APPNAME.app"/Contents/MacOS/.
cp -r ${RESOURCES[@]} "$APPNAME.app"/Contents/Resources/.
mkdir "$APPNAME.app"/Contents/Resources/{assets,saves}
cp -r ${ASSETS[@]} "$APPNAME.app"/Contents/Resources/assets/
cp osx/Lifish.icns Lifish.app/Contents/Resources/.
pushd "$APPNAME.app"/Contents/MacOS
ln -s ../Resources/assets
ln -s ../Resources/saves
ln -s ../Resources/levels.json
popd
find "$APPNAME.app" -type f -exec install_name_tool -add_rpath "@executable_path/../Frameworks" {} \; 2>&1 | grep -v "not a Mach-O"
zip -r "$OUT_ZIP" "$APPNAME.app"