1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

make: add osxbundle-skip-deps

This adds a way to generate a Mac OS X application bundle without the bundled
dependencies.

fixes #57
This commit is contained in:
Stefano Pigozzi 2013-04-08 21:44:46 +02:00
parent a95a5bcf2f
commit ae9e7b5a4a
2 changed files with 53 additions and 21 deletions

View File

@ -461,6 +461,9 @@ tags:
osxbundle:
@TOOLS/osxbundle.py mpv
osxbundle-skip-deps:
@TOOLS/osxbundle.py --skip-deps mpv
-include $(DEP_FILES)
.PHONY: all *install* *clean .version

View File

@ -4,6 +4,7 @@ import os
import re
import shutil
import sys
from optparse import OptionParser
def sh(command):
return os.popen(command).read()
@ -28,27 +29,27 @@ 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():
def bundle_name(binary_name):
return "%s.app" % binary_name
def target_plist():
return os.path.join(bundle_name(), 'Contents', 'Info.plist')
def target_plist(binary_name):
return os.path.join(bundle_name(binary_name), 'Contents', 'Info.plist')
def target_directory():
return os.path.join(bundle_name(), 'Contents', 'MacOS')
def target_directory(binary_name):
return os.path.join(bundle_name(binary_name), 'Contents', 'MacOS')
def target_binary():
return os.path.join(target_directory(), binary_name)
def target_binary(binary_name):
return os.path.join(target_directory(binary_name), binary_name)
def copy_bundle():
if os.path.isdir(bundle_name()):
shutil.rmtree(bundle_name())
def copy_bundle(binary_name):
if os.path.isdir(bundle_name(binary_name)):
shutil.rmtree(bundle_name(binary_name))
shutil.copytree(
os.path.join('TOOLS', 'osxbundle', bundle_name()),
bundle_name())
os.path.join('TOOLS', 'osxbundle', bundle_name(binary_name)),
bundle_name(binary_name))
def copy_binary():
shutil.copy(binary_name, target_binary())
def copy_binary(binary_name):
shutil.copy(binary_name, target_binary(binary_name))
def run_install_name_tool(target_file, dylib_path, dest_dir, root=True):
new_dylib_path = os.path.join("@executable_path", "lib",
@ -83,12 +84,40 @@ def fix_dylibs_paths(target_file, dest_dir, root=True):
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()
def bundle_dependencies(binary_name):
lib_bundle_directory = os.path.join(target_directory(binary_name), "lib")
cp_dylibs(binary_name, lib_bundle_directory)
fix_dylibs_paths(target_binary(binary_name), lib_bundle_directory)
print("Creating Mac OS X application bundle (version: %s)..." % version)
def main():
version = sh("TOOLS/osxbundle/version.sh").strip()
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"))
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
parser.add_option("-s", "--skip-deps", action="store_false", dest="deps",
default=True,
help="don't bundle the dependencies")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
else:
binary_name = args[0]
print("Creating Mac OS X application bundle (version: %s)..." % version)
print("> copying bundle skeleton")
copy_bundle(binary_name)
print("> copying binary")
copy_binary(binary_name)
print("> generating Info.plist")
apply_plist_template(target_plist(binary_name), version)
if options.deps:
print("> bundling dependencies")
bundle_dependencies(binary_name)
print("done.")
if __name__ == "__main__":
main()