From c4f68de1456ddb561f322b84e2ba1b790eec4c28 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 13 Aug 2012 12:08:22 +0200 Subject: TOOLS: add script for osx bundle generation Add a make task and python 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. The main svg icon was created by me and heavily inspired by Apple's iTunes and AppStore icon designs. We are still looking for something better. For the audio, movie and subtitles icons I added the main logo to MPlayer OSX Extended icons. Use with `make osxbundle` after running configure and make. --- TOOLS/osxbundle.py | 89 ++++++++ TOOLS/osxbundle/mpv.app/Contents/Info.plist | 248 +++++++++++++++++++++ TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep | 0 .../osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep | 0 TOOLS/osxbundle/mpv.app/Contents/PkgInfo | 1 + .../mpv.app/Contents/Resources/audio.icns | Bin 0 -> 64076 bytes .../osxbundle/mpv.app/Contents/Resources/icon.icns | Bin 0 -> 142486 bytes .../mpv.app/Contents/Resources/movie.icns | Bin 0 -> 157126 bytes .../mpv.app/Contents/Resources/subtitles.icns | Bin 0 -> 63323 bytes TOOLS/osxbundle/version.sh | 15 ++ 10 files changed, 353 insertions(+) create mode 100755 TOOLS/osxbundle.py create mode 100644 TOOLS/osxbundle/mpv.app/Contents/Info.plist create mode 100644 TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep create mode 100644 TOOLS/osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep create mode 100644 TOOLS/osxbundle/mpv.app/Contents/PkgInfo create mode 100644 TOOLS/osxbundle/mpv.app/Contents/Resources/audio.icns create mode 100644 TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns create mode 100644 TOOLS/osxbundle/mpv.app/Contents/Resources/movie.icns create mode 100644 TOOLS/osxbundle/mpv.app/Contents/Resources/subtitles.icns create mode 100755 TOOLS/osxbundle/version.sh (limited to 'TOOLS') diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py new file mode 100755 index 0000000000..9f2f29d88b --- /dev/null +++ b/TOOLS/osxbundle.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +import os +import re +import shutil +import sys + +def sh(command): + return os.popen(command).read() + +def dylib_lst(input_file): + return sh("otool -L %s | grep -e '\t' | awk '{ print $1 }'" % input_file) + +sys_re = re.compile("/System") +exe_re = re.compile("@executable_path") +binary_name = sys.argv[1] + +def is_user_lib(libname, input_file): + return not sys_re.match(libname) and \ + not exe_re.match(libname) and \ + not "libobjc" in libname and \ + not "libSystem" in libname and \ + not "libgcc" in libname and \ + not os.path.basename(input_file) in libname and \ + not libname == '' + +def user_dylib_lst(input_file): + return [lib for lib in dylib_lst(input_file).split("\n") if + is_user_lib(lib, input_file)] + +def bundle_name(): + return "%s.app" % binary_name + +def target_plist(): + return os.path.join(bundle_name(), 'Contents', 'Info.plist') + +def target_directory(): + return os.path.join(bundle_name(), 'Contents', 'MacOS') + +def target_binary(): + return os.path.join(target_directory(), binary_name) + +def copy_bundle(): + if os.path.isdir(bundle_name()): + shutil.rmtree(bundle_name()) + shutil.copytree( + os.path.join('TOOLS', 'osxbundle', bundle_name()), + bundle_name()) + +def copy_binary(): + shutil.copy(binary_name, target_binary()) + +def run_install_name_tool(target_file, dylib_path, destination_directory): + new_dylib_path = os.path.join("@executable_path", "lib", + os.path.basename(dylib_path)) + + sh("install_name_tool -change %s %s %s" % \ + (dylib_path, new_dylib_path, target_file)) + sh("install_name_tool -id %s %s" % \ + (new_dylib_path, os.path.join(destination_directory, + os.path.basename(dylib_path)))) + +def cp_dylibs(target_file, destination_directory): + for dylib_path in user_dylib_lst(target_file): + dylib_destination_path = os.path.join(destination_directory, + os.path.basename(dylib_path)) + shutil.copy(dylib_path, dylib_destination_path) + os.chmod(dylib_destination_path, 0o755) + cp_dylibs(dylib_destination_path, destination_directory) + +def fix_dylibs_paths(target_file, destination_directory): + for dylib_path in user_dylib_lst(target_file): + dylib_destination_path = os.path.join(destination_directory, + os.path.basename(dylib_path)) + run_install_name_tool(target_file, dylib_path, destination_directory) + fix_dylibs_paths(dylib_destination_path, destination_directory) + +def apply_plist_template(plist_file, version): + sh("sed -i -e 's/{{VERSION}}/%s/g' %s" % (version, plist_file)) + +version = sh("TOOLS/osxbundle/version.sh").strip() + +print("Creating Mac OS X application bundle (version: %s)..." % version) + +copy_bundle() +copy_binary() +apply_plist_template(target_plist(), version) +cp_dylibs(sys.argv[1], os.path.join(target_directory(), "lib")) +fix_dylibs_paths(target_binary(), os.path.join(target_directory(), "lib")) diff --git a/TOOLS/osxbundle/mpv.app/Contents/Info.plist b/TOOLS/osxbundle/mpv.app/Contents/Info.plist new file mode 100644 index 0000000000..472542fe92 --- /dev/null +++ b/TOOLS/osxbundle/mpv.app/Contents/Info.plist @@ -0,0 +1,248 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + AAC + AC3 + AIFF + M4A + MKA + MP3 + OGG + PCM + VAW + WAV + WAW + WMA + aac + ac3 + aiff + m4a + mka + mp3 + ogg + pcm + vaw + wav + waw + wma + + CFBundleTypeIconFile + audio.icns + CFBundleTypeName + Audio file + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + * + * + 3GP + 3IV + 3gp + 3iv + ASF + AVI + CPK + DAT + DIVX + DV + FLAC + FLI + FLV + H264 + I263 + M2TS + M4V + MKV + MOV + MP2 + MP4 + MPEG + MPG + MPG2 + MPG4 + NSV + NUT + NUV + OGG + OGM + QT + RM + RMVB + VCD + VFW + VOB + WMV + asf + avi + cpk + dat + divx + dv + flac + fli + flv + h264 + i263 + m2ts + m4v + mkv + mov + mp2 + mp4 + mpeg + mpg + mpg2 + mpg4 + nsv + nut + nuv + ogg + ogm + qt + rm + rmvb + vcd + vfw + vob + wmv + + CFBundleTypeIconFile + movie.icns + CFBundleTypeName + Movie file + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleTypeExtensions + + AQT + ASS + JSS + RT + SMI + SRT + SSA + SUB + TXT + UTF + aqt + ass + jss + rt + smi + srt + ssa + sub + txt + utf + + CFBundleTypeIconFile + subtitles.icns + CFBundleTypeName + Subtitles file + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + + CFBundleExecutable + mpv + CFBundleIconFile + icon + CFBundleIdentifier + org.mpv-player.standalone + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + mpv + CFBundlePackageType + APPL + CFBundleShortVersionString + {{VERSION}} + NSHighResolutionCapable + + CFBundleURLTypes + + + CFBundleTypeRole + Viewer + CFBundleURLName + Real Time (Streaming) Protocol + CFBundleURLSchemes + + rtp + rtsp + + + + CFBundleTypeRole + Viewer + CFBundleURLName + File over HTTP/FTP/UDP + CFBundleURLSchemes + + icyx + udp + ftp + http_proxy + http + + + + CFBundleTypeRole + Viewer + CFBundleURLName + Microsoft Media Services + CFBundleURLSchemes + + mms + + + + CFBundleTypeRole + Viewer + CFBundleURLName + Cuesheet + CFBundleURLSchemes + + cue + + + + CFBundleTypeRole + Viewer + CFBundleURLName + CD/DVD Media + CFBundleURLSchemes + + dvdnav + dvd + vcd + + + + + diff --git a/TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep b/TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/TOOLS/osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep b/TOOLS/osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/TOOLS/osxbundle/mpv.app/Contents/PkgInfo b/TOOLS/osxbundle/mpv.app/Contents/PkgInfo new file mode 100644 index 0000000000..bd04210fb4 --- /dev/null +++ b/TOOLS/osxbundle/mpv.app/Contents/PkgInfo @@ -0,0 +1 @@ +APPL???? \ No newline at end of file diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/audio.icns b/TOOLS/osxbundle/mpv.app/Contents/Resources/audio.icns new file mode 100644 index 0000000000..239b9bab12 Binary files /dev/null and b/TOOLS/osxbundle/mpv.app/Contents/Resources/audio.icns differ diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns b/TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns new file mode 100644 index 0000000000..eb056f5a15 Binary files /dev/null and b/TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns differ diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/movie.icns b/TOOLS/osxbundle/mpv.app/Contents/Resources/movie.icns new file mode 100644 index 0000000000..8c495894a4 Binary files /dev/null and b/TOOLS/osxbundle/mpv.app/Contents/Resources/movie.icns differ diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/subtitles.icns b/TOOLS/osxbundle/mpv.app/Contents/Resources/subtitles.icns new file mode 100644 index 0000000000..f4c7270691 Binary files /dev/null and b/TOOLS/osxbundle/mpv.app/Contents/Resources/subtitles.icns differ diff --git a/TOOLS/osxbundle/version.sh b/TOOLS/osxbundle/version.sh new file mode 100755 index 0000000000..ff6bb1b5fd --- /dev/null +++ b/TOOLS/osxbundle/version.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Extract revision number from file used by daily tarball snapshots +# or from "git describe" output +git_revision=$(cat snapshot_version 2> /dev/null) +test $git_revision || test ! -d .git || \ +git_revision=`git describe --match "v[0-9]*" --always` +git_revision=$(expr "$git_revision" : v*'\(.*\)') +test $git_revision || git_revision=UNKNOWN + +# releases extract the version number from the VERSION file +version=$(cat VERSION 2> /dev/null) +test $version || version=$git_revision + +echo $version -- cgit v1.2.3