-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle_macos_app.sh
executable file
·171 lines (157 loc) · 12 KB
/
bundle_macos_app.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
APP_NAME="Metro Bundler Launcher"
BUNDLE_DIR="build/${APP_NAME}.app"
BUNDLE_CONTENTS="${BUNDLE_DIR}/Contents"
EXECUTABLE="main"
SRC_DIR="src"
BUNDLE_FILE="${APP_NAME}.bundle"
ICONS_DIR="assets"
# Create the app bundle structure
mkdir -p "${BUNDLE_CONTENTS}/MacOS"
mkdir -p "${BUNDLE_CONTENTS}/Resources"
mkdir -p "${BUNDLE_CONTENTS}/Frameworks"
# Copy the executable
cp "build/${EXECUTABLE}" "${BUNDLE_CONTENTS}/MacOS/"
# Copy icon file if exists
cp "${ICONS_DIR}/icon.icns" "${BUNDLE_CONTENTS}/Resources/"
# Create the Info.plist file
cat <<EOF > "${BUNDLE_CONTENTS}/Info.plist"
<?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>CFBundleName</key>
<string>${APP_NAME}</string>
<key>CFBundleDisplayName</key>
<string>${APP_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.savaughn.${APP_NAME}</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>LSMinimumSystemVersion</key>
<string>12.0</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleExecutable</key>
<string>launcher.sh</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
</dict>
</plist>
EOF
# Create the launcher script
cat <<EOF > "${BUNDLE_CONTENTS}/MacOS/launcher.sh"
#!/bin/bash
# Set up environment variables needed for GTK applications
export GTK_PATH="\$(dirname "\$0")/../Frameworks"
export DYLD_LIBRARY_PATH="\$GTK_PATH:\$DYLD_LIBRARY_PATH"
# Default MacOS backend (Quartz)
# Execute the main application
exec "\$(dirname "\$0")/main" "\$@"
EOF
# Copy GTK and other dependencies
HOMEBREW_PREFIX="$(brew --prefix)"
GTK_ROOT="${HOMEBREW_PREFIX}/opt/gtk4"
cp -RL "${HOMEBREW_PREFIX}/lib/libgobject-2.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libglib-2.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${GTK_ROOT}/lib/libgtk-4.1.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libcairo.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libpangocairo-1.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libpango-1.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libharfbuzz.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libgdk_pixbuf-2.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libcairo-gobject.2.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libgraphene-1.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libgio-2.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libgobject-2.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libglib-2.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libintl.8.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libcairo.2.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libjansson.4.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libpng16.16.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libfontconfig.1.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libfreetype.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libx11.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
# libXext.6.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libXext.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libXrender.1.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libXrender.1.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
# libxcb.1.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libxcb.1.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libxcb-render.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libxcb-shm.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libpixman-1.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
cp -RL "${HOMEBREW_PREFIX}/lib/libgmodule-2.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libjpeg.8.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libjpeg.8.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libtiff.6.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libtiff.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libgraphite2.3.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libgraphite2.3.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libfribidi.0.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libfribidi.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libpangooft2-1.0.0.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libpangoft2-1.0.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libharfbuzz-gobject.0.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libharfbuzz-gobject.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libharfbuzz-subset.0.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libharfbuzz-subset.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libepoxy.0.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libepoxy.0.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libcairo-script-interpreter.2.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libcairo-script-interpreter.2.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#liblzo2.2.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/liblzo2.2.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libzstd.1.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libzstd.1.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libXau.6.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libXau.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
#libXdcmp.6.dylib
cp -RL "${HOMEBREW_PREFIX}/lib/libXdmcp.6.dylib" "${BUNDLE_CONTENTS}/Frameworks/"
install_name_tool -change "${GTK_ROOT}/lib/libgtk-4.1.dylib" @executable_path/../Frameworks/libgtk-4.1.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libpangocairo-1.0.0.dylib" @executable_path/../Frameworks/libpangocairo-1.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgobject-2.0.dylib" @executable_path/../Frameworks/libgobject-2.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libglib-2.0.dylib" @executable_path/../Frameworks/libglib-2.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libcairo.dylib" @executable_path/../Frameworks/libcairo.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libpango-1.0.0.dylib" @executable_path/../Frameworks/libpango-1.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libharfbuzz.0.dylib" @executable_path/../Frameworks/libharfbuzz.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgdk_pixbuf-2.0.0.dylib" @executable_path/../Frameworks/libgdk_pixbuf-2.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libcairo-gobject.2.dylib" @executable_path/../Frameworks/libcairo-gobject.2.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgraphene-1.0.0.dylib" @executable_path/../Frameworks/libgraphene-1.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgio-2.0.0.dylib" @executable_path/../Frameworks/libgio-2.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgobject-2.0.0.dylib" @executable_path/../Frameworks/libgobject-2.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libglib-2.0.0.dylib" @executable_path/../Frameworks/libglib-2.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libintl.8.dylib" @executable_path/../Frameworks/libintl.8.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libcairo.2.dylib" @executable_path/../Frameworks/libcairo.2.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libjansson.4.dylib" @executable_path/../Frameworks/libjansson.4.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libpng16.16.dylib" @executable_path/../Frameworks/libpng16.16.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libfontconfig.1.dylib" @executable_path/../Frameworks/libfontconfig.1.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libfreetype.6.dylib" @executable_path/../Frameworks/libfreetype.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libx11.6.dylib" @executable_path/../Frameworks/libx11.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libXext.6.dylib" @executable_path/../Frameworks/libXext.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libXrender.1.dylib" @executable_path/../Frameworks/libXrender.1.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libxcb.1.dylib" @executable_path/../Frameworks/libxcb.1.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libxcb-render.0.dylib" @executable_path/../Frameworks/libxcb-render.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libxcb-shm.0.dylib" @executable_path/../Frameworks/libxcb-shm.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libpixman-1.0.dylib" @executable_path/../Frameworks/libpixman-1.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgmodule-2.0.0.dylib" @executable_path/../Frameworks/libgmodule-2.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libjpeg.8.dylib" @executable_path/../Frameworks/libjpeg.8.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libtiff.6.dylib" @executable_path/../Frameworks/libtiff.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libgraphite2.3.dylib" @executable_path/../Frameworks/libgraphite2.3.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libfribidi.0.dylib" @executable_path/../Frameworks/libfribidi.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libpangoft2-1.0.0.dylib" @executable_path/../Frameworks/libpangoft2-1.0.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libharfbuzz-gobject.0.dylib" @executable_path/../Frameworks/libharfbuzz-gobject.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libharfbuzz-subset.0.dylib" @executable_path/../Frameworks/libharfbuzz-subset.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libepoxy.0.dylib" @executable_path/../Frameworks/libepoxy.0.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libcairo-script-interpreter.2.dylib" @executable_path/../Frameworks/libcairo-script-interpreter.2.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/liblzo2.2.dylib" @executable_path/../Frameworks/liblzo2.2.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libzstd.1.dylib" @executable_path/../Frameworks/libzstd.1.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libXau.6.dylib" @executable_path/../Frameworks/libXau.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
install_name_tool -change "${HOMEBREW_PREFIX}/lib/libXdmcp.6.dylib" @executable_path/../Frameworks/libXdmcp.6.dylib "${BUNDLE_CONTENTS}/MacOS/${EXECUTABLE}"
# make launcher.sh executable
chmod +x "${BUNDLE_CONTENTS}/MacOS/launcher.sh"
rm -rf build/main
# Final message
echo "Bundle created at: ${BUNDLE_DIR}"