From 461157bbc98eec0f7d89797a2e31c2013164e80f Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 1 Mar 2010 12:13:11 +0000 Subject: [PATCH] Mac build & deploy updates. --- CMakeLists.txt | 4 +++ macdeploy.py | 89 ++++++++++++++++++++++++++++++++++++---------- src/CMakeLists.txt | 14 ++------ 3 files changed, 77 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfd9939d3..84fc38b2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ endif (LIBNOTIFY_FOUND) find_library(LASTFM_LIBRARY_DIRS lastfm) find_path(LASTFM_INCLUDE_DIRS lastfm/ws.h) +if (APPLE) + find_library(GROWL Growl) +endif (APPLE) + if(${CMAKE_BUILD_TYPE} MATCHES "Release") add_definitions(-DNDEBUG) add_definitions(-DQT_NO_DEBUG_OUTPUT) diff --git a/macdeploy.py b/macdeploy.py index 215cc865e..ba2b68ec3 100755 --- a/macdeploy.py +++ b/macdeploy.py @@ -5,12 +5,12 @@ import re import subprocess import sys -FRAMEWORK_SEARCH_PATH=['/Library/Frameworks', '~/Library/Frameworks'] +FRAMEWORK_SEARCH_PATH=['/Library/Frameworks', os.path.join(os.environ['HOME'], 'Library/Frameworks')] LIBRARY_SEARCH_PATH=['/usr/local/lib', '/sw/lib'] XINE_PLUGINS = [ - #'xineplug_decode_vorbis.so', - #'xineplug_dmx_ogg.so', + 'xineplug_decode_vorbis.so', + 'xineplug_dmx_ogg.so', 'xineplug_ao_out_coreaudio.so', 'xineplug_decode_a52.so', 'xineplug_decode_dts.so', @@ -32,6 +32,25 @@ XINEPLUGIN_SEARCH_PATH=[ '/sw/lib/xine/plugins', ] +QT_PLUGINS = [ + 'accessible/libqtaccessiblewidgets.dylib', + 'codecs/libqcncodecs.dylib', + 'codecs/libqjpcodecs.dylib', + 'codecs/libqkrcodecs.dylib', + 'codecs/libqtwcodecs.dylib', + 'iconengines/libqsvgicon.dylib', + 'imageformats/libqgif.dylib', + 'imageformats/libqico.dylib', + 'imageformats/libqjpeg.dylib', + 'imageformats/libqmng.dylib', + 'imageformats/libqsvg.dylib', + 'imageformats/libqtiff.dylib', + 'sqldrivers/libqsqlite.dylib', +] +QT_PLUGINS_SEARCH_PATH=[ + '/Developer/Applications/Qt/plugins', +] + class Error(Exception): pass @@ -49,6 +68,10 @@ class CouldNotFindXinePluginError(Error): pass +class CouldNotFindQtPluginError(Error): + pass + + if len(sys.argv) < 2: print 'Usage: %s ' % sys.argv[0] @@ -56,15 +79,18 @@ bundle_dir = sys.argv[1] bundle_name = bundle_dir.split('.')[0] +commands = [] + frameworks_dir = os.path.join(bundle_dir, 'Contents', 'Frameworks') +commands.append(['mkdir', '-p', frameworks_dir]) resources_dir = os.path.join(bundle_dir, 'Contents', 'Resources') +commands.append(['mkdir', '-p', resources_dir]) plugins_dir = os.path.join(bundle_dir, 'Contents', 'PlugIns') binary = os.path.join(bundle_dir, 'Contents', 'MacOS', bundle_name) fixed_libraries = [] fixed_frameworks = [] - def GetBrokenLibraries(binary): output = subprocess.Popen(['otool', '-L', binary], stdout=subprocess.PIPE).communicate()[0] broken_libs = { @@ -82,7 +108,10 @@ def GetBrokenLibraries(binary): elif re.match(r'^\s*\w+\.framework', line): broken_libs['frameworks'].append(line) elif re.match(r'^\s*@executable_path', line): - continue # Already fixed library + # Potentially already fixed library + relative_path = os.path.join(*line.split('/')[3:]) + if not os.path.exists(os.path.join(frameworks_dir, relative_path)): + broken_libs['frameworks'].append(relative_path) else: broken_libs['libs'].append(line) @@ -144,13 +173,11 @@ def FixLibrary(path): for library in broken_libs['libs']: FixLibraryInstallPath(library, new_path) -def FixPlugin(path): - abs_path = FindXinePlugin(path) +def FixPlugin(abs_path, subdir): broken_libs = GetBrokenLibraries(abs_path) FixAllLibraries(broken_libs) - new_path = CopyPlugin(abs_path) - FixLibraryId(new_path) + new_path = CopyPlugin(abs_path, subdir) for framework in broken_libs['frameworks']: FixFrameworkInstallPath(framework, new_path) for library in broken_libs['libs']: @@ -167,13 +194,15 @@ def FixBinary(path): def CopyLibrary(path): new_path = os.path.join(frameworks_dir, os.path.basename(path)) args = ['cp', '-f', path, new_path] - print ' '.join(args) + commands.append(args) return new_path -def CopyPlugin(path): - new_path = os.path.join(plugins_dir, os.path.basename(path)) +def CopyPlugin(path, subdir): + new_path = os.path.join(plugins_dir, subdir, os.path.basename(path)) + args = ['mkdir', '-p', os.path.dirname(new_path)] + commands.append(args) args = ['cp', '-f', path, new_path] - print ' '.join(args) + commands.append(args) return new_path def CopyFramework(path): @@ -183,15 +212,15 @@ def CopyFramework(path): full_path = os.path.join(frameworks_dir, *parts[i:-1]) break args = ['mkdir', '-p', full_path] - print ' '.join(args) - args = ['cp', '-fR', path, full_path] - print ' '.join(args) + commands.append(args) + args = ['cp', '-f', path, full_path] + commands.append(args) return os.path.join(frameworks_dir, path) def FixId(path, library_name): id = '@executable_path/../Frameworks/%s' % library_name args = ['install_name_tool', '-id', id, path] - print ' '.join(args) + commands.append(args) def FixLibraryId(path): library_name = os.path.basename(path) @@ -202,7 +231,7 @@ def FixFrameworkId(path, id): def FixInstallPath(library_path, library, new_path): args = ['install_name_tool', '-change', library_path, new_path, library] - print ' '.join(args) + commands.append(args) def FixLibraryInstallPath(library_path, library): new_path = '@executable_path/../Frameworks/%s' % os.path.basename(library_path) @@ -221,10 +250,32 @@ def FindXinePlugin(name): raise CouldNotFindXinePluginError(name) +def FindQtPlugin(name): + for path in QT_PLUGINS_SEARCH_PATH: + if os.path.exists(path): + if os.path.exists(os.path.join(path, name)): + return os.path.join(path, name) + raise CouldNotFindQtPluginError(name) + + FixBinary(binary) for plugin in XINE_PLUGINS: - FixPlugin(plugin) + FixPlugin(FindXinePlugin(plugin), 'xine') + +for plugin in QT_PLUGINS: + FixPlugin(FindQtPlugin(plugin), os.path.dirname(plugin)) + +print 'Would run %d commands:' % len(commands) +for command in commands: + print ' '.join(command) + +print 'OK?' +raw_input() + +for command in commands: + p = subprocess.Popen(command) + os.waitpid(p.pid, 0) qtconf = open(os.path.join(resources_dir, 'qt.conf'), 'w') qtconf.write('''[Paths] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b95d5d1ef..8900c0f29 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,7 @@ if (APPLE) target_link_libraries(clementine_lib ${GROWL} ) + include_directories(${GROWL}/Headers) endif (APPLE) add_dependencies(clementine_lib qtsingleapplication qxt) @@ -180,7 +181,7 @@ target_link_libraries(clementine clementine_lib) set_property(TARGET clementine PROPERTY COMPILE_FLAGS - "-Werror=non-virtual-dtor -Woverloaded-virtual -Wall" + "-Wnon-virtual-dtor -Woverloaded-virtual -Wall" ) set_target_properties(clementine PROPERTIES @@ -189,14 +190,5 @@ set_target_properties(clementine PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1" ) -add_custom_target(bundle - mkdir -p Frameworks/ - COMMAND mkdir -p PlugIns/xine - COMMAND mkdir -p Resources/ - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../clementine.app/Contents/ -) -add_dependencies(bundle clementine) - install(TARGETS clementine - BUNDLE DESTINATION bin - RUNTIME DESTINATION bin) + BUNDLE DESTINATION bin)