Skip to content

Commit 38e14a9

Browse files
pigozUoti Urpala
authored and
Uoti Urpala
committed
TOOLS: add script for OSX bundle generation
Add a make task and shell script to create a Mac OS X Application Bundle to be used when compiling with the --enable-macosx-finder and --enable-macosx-bundle configure flags.
1 parent 8eb157b commit 38e14a9

File tree

12 files changed

+354
-0
lines changed

12 files changed

+354
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/config.mak
88
/config.log
99
/mplayer
10+
/mplayer2.app
1011
/version.h
1112
/codecs.conf.h
1213
/codec-cfg

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ realcodecs: CFLAGS += -g
765765
%.so.6.0: %.o
766766
ld -shared -o $@ $< -ldl -lc
767767

768+
osxbundle:
769+
@TOOLS/osxbundle.py mplayer
768770

769771

770772
-include $(DEP_FILES)

TOOLS/osxbundle.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import re
5+
import shutil
6+
import sys
7+
8+
def sh(command):
9+
return os.popen(command).read()
10+
11+
def dylib_lst(input_file):
12+
return sh("otool -L %s | grep -e '\t' | awk '{ print $1 }'" % input_file)
13+
14+
sys_re = re.compile("/System")
15+
exe_re = re.compile("@executable_path")
16+
17+
def is_user_lib(libname, input_file):
18+
return not sys_re.match(libname) and \
19+
not exe_re.match(libname) and \
20+
not "libobjc" in libname and \
21+
not "libSystem" in libname and \
22+
not "libgcc" in libname and \
23+
not os.path.basename(input_file) in libname and \
24+
not libname == ''
25+
26+
def user_dylib_lst(input_file):
27+
return [lib for lib in dylib_lst(input_file).split("\n") if
28+
is_user_lib(lib, input_file)]
29+
30+
def bundle_name():
31+
return "mplayer2.app"
32+
33+
def target_plist():
34+
return os.path.join(bundle_name(), 'Contents', 'Info.plist')
35+
36+
def target_directory():
37+
return os.path.join(bundle_name(), 'Contents', 'MacOS')
38+
39+
def target_binary():
40+
return os.path.join(target_directory(), 'mplayer2')
41+
42+
def copy_bundle():
43+
if os.path.isdir(bundle_name()):
44+
shutil.rmtree(bundle_name())
45+
shutil.copytree(
46+
os.path.join('TOOLS', 'osxbundle', bundle_name()),
47+
bundle_name())
48+
49+
def copy_binary():
50+
shutil.copy('mplayer', target_binary())
51+
52+
def run_install_name_tool(target_file, dylib_path, dest_dir, root=True):
53+
new_dylib_path = os.path.join("@executable_path", "lib",
54+
os.path.basename(dylib_path))
55+
56+
sh("install_name_tool -change %s %s %s" % \
57+
(dylib_path, new_dylib_path, target_file))
58+
if root:
59+
sh("install_name_tool -id %s %s" % \
60+
(new_dylib_path, os.path.join(dest_dir,
61+
os.path.basename(dylib_path))))
62+
63+
def cp_dylibs(target_file, dest_dir):
64+
for dylib_path in user_dylib_lst(target_file):
65+
dylib_dest_path = os.path.join(dest_dir, os.path.basename(dylib_path))
66+
shutil.copy(dylib_path, dylib_dest_path)
67+
os.chmod(dylib_dest_path, 0o755)
68+
cp_dylibs(dylib_dest_path, dest_dir)
69+
70+
def fix_dylibs_paths(target_file, dest_dir, root=True):
71+
for dylib_path in user_dylib_lst(target_file):
72+
dylib_dest_path = os.path.join(dest_dir, os.path.basename(dylib_path))
73+
run_install_name_tool(target_file, dylib_path, dest_dir, root)
74+
fix_dylibs_paths(dylib_dest_path, dest_dir, False)
75+
76+
def apply_plist_template(plist_file, version):
77+
sh("sed -i -e 's/{{VERSION}}/%s/g' %s" % (version, plist_file))
78+
79+
version = sh("TOOLS/osxbundle/version.sh").strip()
80+
81+
print("Creating Mac OS X application bundle (version: %s)..." % version)
82+
83+
copy_bundle()
84+
copy_binary()
85+
apply_plist_template(target_plist(), version)
86+
cp_dylibs(sys.argv[1], os.path.join(target_directory(), "lib"))
87+
fix_dylibs_paths(target_binary(), os.path.join(target_directory(), "lib"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleDocumentTypes</key>
8+
<array>
9+
<dict>
10+
<key>CFBundleTypeExtensions</key>
11+
<array>
12+
<string>AAC</string>
13+
<string>AC3</string>
14+
<string>AIFF</string>
15+
<string>M4A</string>
16+
<string>MKA</string>
17+
<string>MP3</string>
18+
<string>OGG</string>
19+
<string>PCM</string>
20+
<string>VAW</string>
21+
<string>WAV</string>
22+
<string>WAW</string>
23+
<string>WMA</string>
24+
<string>aac</string>
25+
<string>ac3</string>
26+
<string>aiff</string>
27+
<string>m4a</string>
28+
<string>mka</string>
29+
<string>mp3</string>
30+
<string>ogg</string>
31+
<string>pcm</string>
32+
<string>vaw</string>
33+
<string>wav</string>
34+
<string>waw</string>
35+
<string>wma</string>
36+
</array>
37+
<key>CFBundleTypeIconFile</key>
38+
<string>audio.icns</string>
39+
<key>CFBundleTypeName</key>
40+
<string>Audio file</string>
41+
<key>CFBundleTypeRole</key>
42+
<string>Viewer</string>
43+
<key>LSTypeIsPackage</key>
44+
<false/>
45+
<key>NSPersistentStoreTypeKey</key>
46+
<string>XML</string>
47+
</dict>
48+
<dict>
49+
<key>CFBundleTypeExtensions</key>
50+
<array>
51+
<string>*</string>
52+
<string>*</string>
53+
<string>3GP</string>
54+
<string>3IV</string>
55+
<string>3gp</string>
56+
<string>3iv</string>
57+
<string>ASF</string>
58+
<string>AVI</string>
59+
<string>CPK</string>
60+
<string>DAT</string>
61+
<string>DIVX</string>
62+
<string>DV</string>
63+
<string>FLAC</string>
64+
<string>FLI</string>
65+
<string>FLV</string>
66+
<string>H264</string>
67+
<string>I263</string>
68+
<string>M2TS</string>
69+
<string>M4V</string>
70+
<string>MKV</string>
71+
<string>MOV</string>
72+
<string>MP2</string>
73+
<string>MP4</string>
74+
<string>MPEG</string>
75+
<string>MPG</string>
76+
<string>MPG2</string>
77+
<string>MPG4</string>
78+
<string>NSV</string>
79+
<string>NUT</string>
80+
<string>NUV</string>
81+
<string>OGG</string>
82+
<string>OGM</string>
83+
<string>QT</string>
84+
<string>RM</string>
85+
<string>RMVB</string>
86+
<string>VCD</string>
87+
<string>VFW</string>
88+
<string>VOB</string>
89+
<string>WMV</string>
90+
<string>asf</string>
91+
<string>avi</string>
92+
<string>cpk</string>
93+
<string>dat</string>
94+
<string>divx</string>
95+
<string>dv</string>
96+
<string>flac</string>
97+
<string>fli</string>
98+
<string>flv</string>
99+
<string>h264</string>
100+
<string>i263</string>
101+
<string>m2ts</string>
102+
<string>m4v</string>
103+
<string>mkv</string>
104+
<string>mov</string>
105+
<string>mp2</string>
106+
<string>mp4</string>
107+
<string>mpeg</string>
108+
<string>mpg</string>
109+
<string>mpg2</string>
110+
<string>mpg4</string>
111+
<string>nsv</string>
112+
<string>nut</string>
113+
<string>nuv</string>
114+
<string>ogg</string>
115+
<string>ogm</string>
116+
<string>qt</string>
117+
<string>rm</string>
118+
<string>rmvb</string>
119+
<string>vcd</string>
120+
<string>vfw</string>
121+
<string>vob</string>
122+
<string>wmv</string>
123+
</array>
124+
<key>CFBundleTypeIconFile</key>
125+
<string>movie.icns</string>
126+
<key>CFBundleTypeName</key>
127+
<string>Movie file</string>
128+
<key>CFBundleTypeRole</key>
129+
<string>Viewer</string>
130+
<key>LSTypeIsPackage</key>
131+
<false/>
132+
<key>NSPersistentStoreTypeKey</key>
133+
<string>XML</string>
134+
</dict>
135+
<dict>
136+
<key>CFBundleTypeExtensions</key>
137+
<array>
138+
<string>AQT</string>
139+
<string>ASS</string>
140+
<string>JSS</string>
141+
<string>RT</string>
142+
<string>SMI</string>
143+
<string>SRT</string>
144+
<string>SSA</string>
145+
<string>SUB</string>
146+
<string>TXT</string>
147+
<string>UTF</string>
148+
<string>aqt</string>
149+
<string>ass</string>
150+
<string>jss</string>
151+
<string>rt</string>
152+
<string>smi</string>
153+
<string>srt</string>
154+
<string>ssa</string>
155+
<string>sub</string>
156+
<string>txt</string>
157+
<string>utf</string>
158+
</array>
159+
<key>CFBundleTypeIconFile</key>
160+
<string>subtitles.icns</string>
161+
<key>CFBundleTypeName</key>
162+
<string>Subtitles file</string>
163+
<key>CFBundleTypeRole</key>
164+
<string>Viewer</string>
165+
<key>LSTypeIsPackage</key>
166+
<false/>
167+
<key>NSPersistentStoreTypeKey</key>
168+
<string>XML</string>
169+
</dict>
170+
</array>
171+
<key>CFBundleExecutable</key>
172+
<string>mplayer2</string>
173+
<key>CFBundleIconFile</key>
174+
<string>icon</string>
175+
<key>CFBundleIdentifier</key>
176+
<string>org.mplayer2.mplayer2.standalone</string>
177+
<key>CFBundleInfoDictionaryVersion</key>
178+
<string>6.0</string>
179+
<key>CFBundleName</key>
180+
<string>mplayer2</string>
181+
<key>CFBundlePackageType</key>
182+
<string>APPL</string>
183+
<key>CFBundleShortVersionString</key>
184+
<string>{{VERSION}}</string>
185+
<key>NSHighResolutionCapable</key>
186+
<true/>
187+
<key>CFBundleURLTypes</key>
188+
<array>
189+
<dict>
190+
<key>CFBundleTypeRole</key>
191+
<string>Viewer</string>
192+
<key>CFBundleURLName</key>
193+
<string>Real Time (Streaming) Protocol</string>
194+
<key>CFBundleURLSchemes</key>
195+
<array>
196+
<string>rtp</string>
197+
<string>rtsp</string>
198+
</array>
199+
</dict>
200+
<dict>
201+
<key>CFBundleTypeRole</key>
202+
<string>Viewer</string>
203+
<key>CFBundleURLName</key>
204+
<string>File over HTTP/FTP/UDP</string>
205+
<key>CFBundleURLSchemes</key>
206+
<array>
207+
<string>icyx</string>
208+
<string>udp</string>
209+
<string>ftp</string>
210+
<string>http_proxy</string>
211+
<string>http</string>
212+
</array>
213+
</dict>
214+
<dict>
215+
<key>CFBundleTypeRole</key>
216+
<string>Viewer</string>
217+
<key>CFBundleURLName</key>
218+
<string>Microsoft Media Services</string>
219+
<key>CFBundleURLSchemes</key>
220+
<array>
221+
<string>mms</string>
222+
</array>
223+
</dict>
224+
<dict>
225+
<key>CFBundleTypeRole</key>
226+
<string>Viewer</string>
227+
<key>CFBundleURLName</key>
228+
<string>Cuesheet</string>
229+
<key>CFBundleURLSchemes</key>
230+
<array>
231+
<string>cue</string>
232+
</array>
233+
</dict>
234+
<dict>
235+
<key>CFBundleTypeRole</key>
236+
<string>Viewer</string>
237+
<key>CFBundleURLName</key>
238+
<string>CD/DVD Media</string>
239+
<key>CFBundleURLSchemes</key>
240+
<array>
241+
<string>dvdnav</string>
242+
<string>dvd</string>
243+
<string>vcd</string>
244+
</array>
245+
</dict>
246+
</array>
247+
</dict>
248+
</plist>

TOOLS/osxbundle/mplayer2.app/Contents/MacOS/.gitkeep

Whitespace-only changes.

TOOLS/osxbundle/mplayer2.app/Contents/MacOS/lib/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APPL????
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

TOOLS/osxbundle/version.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# Extract revision number from file used by daily tarball snapshots
4+
# or from "git describe" output
5+
git_revision=$(cat snapshot_version 2> /dev/null)
6+
test $git_revision || test ! -d .git || \
7+
git_revision=`git describe --match "v[0-9]*" --always`
8+
git_revision=$(expr "$git_revision" : v*'\(.*\)')
9+
test $git_revision || git_revision=UNKNOWN
10+
11+
# releases extract the version number from the VERSION file
12+
version=$(cat VERSION 2> /dev/null)
13+
test $version || version=$git_revision
14+
15+
echo $version

0 commit comments

Comments
 (0)