From 6f356592a58853defb42e0519684f2f7f53b9d52 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 15 Dec 2016 11:36:05 +0000 Subject: [PATCH 1/5] Fixes for cross compiling for mac. --- ext/clementine-spotifyblob/CMakeLists.txt | 2 +- ext/clementine-tagreader/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 11 +++++++++-- src/devices/devicemanager.cpp | 24 +++++++++++------------ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ext/clementine-spotifyblob/CMakeLists.txt b/ext/clementine-spotifyblob/CMakeLists.txt index 02c25e8ce..28ee96382 100644 --- a/ext/clementine-spotifyblob/CMakeLists.txt +++ b/ext/clementine-spotifyblob/CMakeLists.txt @@ -53,7 +53,7 @@ target_link_libraries(clementine-spotifyblob if(APPLE) target_link_libraries(clementine-spotifyblob - /System/Library/Frameworks/Foundation.framework + "-framework Foundation" ) endif(APPLE) diff --git a/ext/clementine-tagreader/CMakeLists.txt b/ext/clementine-tagreader/CMakeLists.txt index cb38cc495..f4c7bb01e 100644 --- a/ext/clementine-tagreader/CMakeLists.txt +++ b/ext/clementine-tagreader/CMakeLists.txt @@ -31,6 +31,7 @@ target_link_libraries(clementine-tagreader libclementine-tagreader ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} + z ) if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") @@ -41,7 +42,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") if(APPLE) target_link_libraries(clementine-tagreader - /System/Library/Frameworks/Foundation.framework + "-framework Foundation" ) endif(APPLE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f2905a166..570a8012d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -859,7 +859,6 @@ optional_source(APPLE core/macfslistener.mm core/macglobalshortcutbackend.mm core/mac_startup.mm - devices/macdevicelister.mm engines/osxdevicefinder.cpp networkremote/bonjour.mm ui/globalshortcutgrabber.mm @@ -869,10 +868,18 @@ optional_source(APPLE HEADERS core/macfslistener.h core/macglobalshortcutbackend.h - devices/macdevicelister.h ui/macsystemtrayicon.h ) +if(APPLE) + optional_source(HAVE_LIBMTP + SOURCES + devices/macdevicelister.mm + HEADERS + devices/macdevicelister.h + ) +endif() + # Platform specific - Windows optional_source(WIN32 SOURCES diff --git a/src/devices/devicemanager.cpp b/src/devices/devicemanager.cpp index 32ba33657..4ad840a09 100644 --- a/src/devices/devicemanager.cpp +++ b/src/devices/devicemanager.cpp @@ -29,10 +29,6 @@ #include #include "config.h" -#include "devicedatabasebackend.h" -#include "devicekitlister.h" -#include "devicestatefiltermodel.h" -#include "filesystemdevice.h" #include "core/application.h" #include "core/concurrentrun.h" #include "core/database.h" @@ -40,14 +36,18 @@ #include "core/musicstorage.h" #include "core/taskmanager.h" #include "core/utilities.h" +#include "devicedatabasebackend.h" +#include "devicekitlister.h" +#include "devicestatefiltermodel.h" +#include "filesystemdevice.h" #include "ui/iconloader.h" #ifdef HAVE_AUDIOCD -#include "cddalister.h" #include "cddadevice.h" +#include "cddalister.h" #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_DARWIN) and defined(HAVE_LIBMTP) #include "macdevicelister.h" #endif #ifdef HAVE_LIBGPOD @@ -169,7 +169,8 @@ DeviceManager::DeviceInfo::BestBackend() const { DeviceManager::DeviceManager(Application* app, QObject* parent) : QAbstractListModel(parent), app_(app), - not_connected_overlay_(IconLoader::Load("edit-delete", IconLoader::Base)) { + not_connected_overlay_( + IconLoader::Load("edit-delete", IconLoader::Base)) { thread_pool_.setMaxThreadCount(1); connect(app_->task_manager(), SIGNAL(TasksChanged()), SLOT(TasksChanged())); @@ -200,7 +201,7 @@ DeviceManager::DeviceManager(Application* app, QObject* parent) #ifdef HAVE_GIO AddLister(new GioLister); #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_DARWIN) and defined(HAVE_LIBMTP) AddLister(new MacDeviceLister); #endif @@ -322,8 +323,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const { if (!info.device_) { if (info.database_id_ == -1 && !info.BestBackend()->lister_->DeviceNeedsMount( - info.BestBackend()->unique_id_)) { - + info.BestBackend()->unique_id_)) { if (info.BestBackend()->lister_->AskForScan( info.BestBackend()->unique_id_)) { std::unique_ptr dialog(new QMessageBox( @@ -629,8 +629,8 @@ std::shared_ptr DeviceManager::Connect(int row) { return ret; } -std::shared_ptr DeviceManager::GetConnectedDevice(int row) - const { +std::shared_ptr DeviceManager::GetConnectedDevice( + int row) const { return devices_[row].device_; } From acc5e9f07c4973323b97d04c6a2875511379addc Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 15 Dec 2016 11:37:01 +0000 Subject: [PATCH 2/5] Use linux-compatible commands in mac script. --- dist/macdeploy.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/macdeploy.py b/dist/macdeploy.py index 5d83c2e4b..0cddcd9c9 100755 --- a/dist/macdeploy.py +++ b/dist/macdeploy.py @@ -31,7 +31,7 @@ FRAMEWORK_SEARCH_PATH=[ os.path.join(os.environ['HOME'], 'Library/Frameworks') ] -LIBRARY_SEARCH_PATH=['/target/lib', '/usr/local/lib', '/sw/lib'] +LIBRARY_SEARCH_PATH=['/target', '/target/lib', '/usr/local/lib', '/sw/lib'] GSTREAMER_PLUGINS=[ @@ -277,7 +277,7 @@ def FixBinary(path): def CopyLibrary(path): new_path = os.path.join(frameworks_dir, os.path.basename(path)) - args = ['ditto', '--arch=x86_64', path, new_path] + args = ['cp', path, new_path] commands.append(args) LOGGER.info("Copying library '%s'", path) return new_path @@ -286,7 +286,7 @@ 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 = ['ditto', '--arch=x86_64', path, new_path] + args = ['cp', path, new_path] commands.append(args) LOGGER.info("Copying plugin '%s'", path) return new_path @@ -310,7 +310,7 @@ def CopyFramework(src_binary): dest_binary = os.path.join(dest_dir, name) commands.append(['mkdir', '-p', dest_dir]) - commands.append(['ditto', '--arch=x86_64', src_binary, dest_binary]) + commands.append(['cp', src_binary, dest_binary]) # Copy special files from various places: # QtCore has Resources/qt_menu.nib (copy to app's Resources) @@ -334,13 +334,13 @@ def CopyFramework(src_binary): # Create symlinks in the Framework to make it look like # https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html - commands.append(['ln', '-sfh', + commands.append(['ln', '-sf', 'Versions/Current/%s' % name, os.path.join(dest_base, name)]) - commands.append(['ln', '-sfh', + commands.append(['ln', '-sf', 'Versions/Current/Resources', os.path.join(dest_base, 'Resources')]) - commands.append(['ln', '-sfh', + commands.append(['ln', '-sf', version, os.path.join(dest_base, 'Versions/Current')]) From ae4fac4b4f8cda89521f4dd0552bfdbf1f97265e Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 15 Dec 2016 11:43:47 +0000 Subject: [PATCH 3/5] Use cross version of install_name_tool if available. --- dist/macdeploy.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/dist/macdeploy.py b/dist/macdeploy.py index 0cddcd9c9..b83a8c381 100755 --- a/dist/macdeploy.py +++ b/dist/macdeploy.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Clementine. If not, see . +from distutils import spawn import logging import os import re @@ -107,15 +108,18 @@ QT_PLUGINS = [ 'imageformats/libqmng.dylib', 'imageformats/libqsvg.dylib', ] -QT_PLUGINS_SEARCH_PATH=[ +QT_PLUGINS_SEARCH_PATH = [ '/target/plugins', '/usr/local/Trolltech/Qt-4.7.0/plugins', '/Developer/Applications/Qt/plugins', ] -GIO_MODULES_SEARCH_PATH=[ - '/target/lib/gio/modules', -] +GIO_MODULES_SEARCH_PATH = ['/target/lib/gio/modules',] + +INSTALL_NAME_TOOL_APPLE = 'install_name_tool' +INSTALL_NAME_TOOL_CROSS = 'x86_64-apple-darwin-%s' % INSTALL_NAME_TOOL_APPLE +INSTALL_NAME_TOOL = INSTALL_NAME_TOOL_CROSS if spawn.find_executable( + INSTALL_NAME_TOOL_CROSS) else INSTALL_NAME_TOOL_APPLE class Error(Exception): @@ -334,34 +338,39 @@ def CopyFramework(src_binary): # Create symlinks in the Framework to make it look like # https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html - commands.append(['ln', '-sf', - 'Versions/Current/%s' % name, - os.path.join(dest_base, name)]) - commands.append(['ln', '-sf', - 'Versions/Current/Resources', - os.path.join(dest_base, 'Resources')]) - commands.append(['ln', '-sf', - version, - os.path.join(dest_base, 'Versions/Current')]) + commands.append([ + 'ln', '-sf', 'Versions/Current/%s' % name, os.path.join(dest_base, name) + ]) + commands.append([ + 'ln', '-sf', 'Versions/Current/Resources', + os.path.join(dest_base, 'Resources') + ]) + commands.append( + ['ln', '-sf', version, os.path.join(dest_base, 'Versions/Current')]) return dest_binary + def FixId(path, library_name): id = '@executable_path/../Frameworks/%s' % library_name - args = ['install_name_tool', '-id', id, path] + args = [INSTALL_NAME_TOOL, '-id', id, path] commands.append(args) + def FixLibraryId(path): library_name = os.path.basename(path) FixId(path, library_name) + def FixFrameworkId(path, id): FixId(path, id) + def FixInstallPath(library_path, library, new_path): - args = ['install_name_tool', '-change', library_path, new_path, library] + args = [INSTALL_NAME_TOOL, '-change', library_path, new_path, library] commands.append(args) + def FindSystemLibrary(library_name): for path in ['/lib', '/usr/lib']: full_path = os.path.join(path, library_name) From da90d1ccf222227541b194814c3e6b8fcce203eb Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 15 Dec 2016 18:45:51 +0000 Subject: [PATCH 4/5] Fix cross compiling for mac --- src/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 570a8012d..1afaaf707 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1330,13 +1330,13 @@ endif() if (APPLE) target_link_libraries(clementine_lib - /System/Library/Frameworks/AppKit.framework - /System/Library/Frameworks/Carbon.framework - /System/Library/Frameworks/CoreAudio.framework - /System/Library/Frameworks/DiskArbitration.framework - /System/Library/Frameworks/Foundation.framework - /System/Library/Frameworks/IOKit.framework - /System/Library/Frameworks/ScriptingBridge.framework + "-framework AppKit" + "-framework Carbon" + "-framework CoreAudio" + "-framework DiskArbitration" + "-framework Foundation" + "-framework IOKit" + "-framework ScriptingBridge" ) target_link_libraries(clementine_lib ${SPMEDIAKEYTAP_LIBRARIES}) if (HAVE_SPARKLE) From 6901c9b1b64f199069c678049eebf1568509eb5b Mon Sep 17 00:00:00 2001 From: Bigard Florian Date: Sun, 18 Dec 2016 16:48:08 +0100 Subject: [PATCH 5/5] Fix podcast episodes forgotten (#5560) --- src/internet/podcasts/podcastbackend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internet/podcasts/podcastbackend.cpp b/src/internet/podcasts/podcastbackend.cpp index c6657586e..665b7eb72 100644 --- a/src/internet/podcasts/podcastbackend.cpp +++ b/src/internet/podcasts/podcastbackend.cpp @@ -228,7 +228,7 @@ PodcastEpisodeList PodcastBackend::GetEpisodes(int podcast_id) { " WHERE podcast_id = :id" " ORDER BY publication_date DESC", db); - q.bindValue(":db", podcast_id); + q.bindValue(":id", podcast_id); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -251,7 +251,7 @@ PodcastEpisode PodcastBackend::GetEpisodeById(int id) { " FROM podcast_episodes" " WHERE ROWID = :id", db); - q.bindValue(":db", id); + q.bindValue(":id", id); q.exec(); if (!db_->CheckErrors(q) && q.next()) { ret.InitFromQuery(q);