From 45b05038961c49648e0ce5f8e75ae3eda66e4144 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sun, 10 Apr 2016 23:52:27 +0200 Subject: [PATCH] Include Mac OS X platform in installer project refs #615 --- install.pri | 73 ++++++++++++++----- mkspecs/features/common_post.prf | 17 ++++- mkspecs/features/libraries.pri | 2 +- samples/blackmiscdbus/sampleblackmiscdbus.pro | 1 - samples/blackmiscsim/sampleblackmiscsim.pro | 1 - samples/cliclient/samplecliclient.pro | 1 - samples/hotkey/samplehotkey.pro | 2 - samples/weatherdata/sampleweatherdata.pro | 1 - src/blackcore/application.cpp | 8 ++ src/blackcore/application.h | 4 + src/blackcore/pluginmanager.cpp | 3 +- src/blackcore/pluginmanagersimulator.cpp | 3 +- src/blackcore/pluginmanagerweatherdata.cpp | 3 +- src/blackmisc/buildconfig.cpp | 28 ++++++- src/blackmisc/buildconfig.h | 3 + .../simulatorxplaneconfigwindow.cpp | 3 +- .../simulator/xplaneconfig/xplaneconfig.pro | 2 +- src/swiftcore/swiftcore.pro | 1 - src/swiftdata/swiftdata.pro | 2 - src/swiftguistandard/swiftguistandard.pro | 7 -- src/swiftlauncher/swiftlauncher.pro | 7 -- 21 files changed, 121 insertions(+), 51 deletions(-) diff --git a/install.pri b/install.pri index da3dc9408..c789bef0f 100644 --- a/install.pri +++ b/install.pri @@ -23,8 +23,19 @@ win32 { qt5_target.path = $${PREFIX}/bin QT5_LIBRARY_DIR = $$[QT_INSTALL_BINS] } - -unix:!macx { +else:macx { + # OSX workaround using rsync. Otherwise all headers are also copied. + qt5_target.path = $${PREFIX}/lib/QtCore.framework + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtCore.framework/ $${PREFIX}/lib/QtCore.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtGui.framework/ $${PREFIX}/lib/QtGui.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtNetwork.framework/ $${PREFIX}/lib/QtNetwork.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtDBus.framework/ $${PREFIX}/lib/QtDBus.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtXml.framework/ $${PREFIX}/lib/QtXml.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtMultimedia.framework/ $${PREFIX}/lib/QtMultimedia.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtSvg.framework/ $${PREFIX}/lib/QtSvg.framework/ && + qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtWidgets.framework/ $${PREFIX}/lib/QtWidgets.framework/ +} +else:unix: { QT5_LIBRARIES *= libQt5Core.so.5 QT5_LIBRARIES *= libQt5DBus.so.5 QT5_LIBRARIES *= libQt5Gui.so.5 @@ -56,13 +67,9 @@ INSTALLS += qt5_target ############### Install Qt5 platform plugins ############## -win32 { - QT5_PLATFORM_PLUGINS *= qwindows$${DLL_DEBUG_SUFFIX}.dll -} - -unix:!macx { - QT5_PLATFORM_PLUGINS *= libqxcb.so -} +win32: QT5_PLATFORM_PLUGINS *= qwindows$${DLL_DEBUG_SUFFIX}.dll +else:macx: QT5_PLATFORM_PLUGINS *= libqcocoa.dylib +else:unix:QT5_PLATFORM_PLUGINS *= libqxcb.so qt5_plugin_target.path = $${PREFIX}/bin/platforms @@ -74,14 +81,16 @@ for (PLUGIN, QT5_PLATFORM_PLUGINS) { INSTALLS += qt5_plugin_target - ############### Install DBus ############## win32-g++ { DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS] - DBUS_BINARIES *= libdbus-1-3.dll DBUS_BINARIES *= dbus-daemon.exe - dbus_target.path = $${PREFIX}/bin + dbus_binary_target.path = $${PREFIX}/bin + + DBUS_LIBARY_SOURCE_DIR = $$[QT_INSTALL_BINS] + DBUS_LIBRARIES *= libdbus-1-3.dll + dbus_library_target.path = $${PREFIX}/bin DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/.. DBUS_CONFIG_FILES *= share/dbus-1/* @@ -90,20 +99,44 @@ win32-g++ { win32-msvc2015 { DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS] - DBUS_BINARIES *= expat.dll - DBUS_BINARIES *= dbus-1-3.dll DBUS_BINARIES *= dbus-daemon.exe - dbus_target.path = $${PREFIX}/bin + dbus_binary_target.path = $${PREFIX}/bin + + DBUS_LIBARY_SOURCE_DIR = $$[QT_INSTALL_BINS] + DBUS_LIBRARIES *= expat.dll + DBUS_LIBRARIES *= dbus-1-3.dll + dbus_library_target.path = $${PREFIX}/bin DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/.. DBUS_CONFIG_FILES *= share/dbus-1/* dbus_config_target.path = $${PREFIX}/share/dbus-1 } +macx { + DBUS_BINARY_SOURCE_DIR = /usr/local/bin + DBUS_BINARIES *= dbus-daemon + dbus_binary_target.path = $${PREFIX}/bin + + DBUS_LIBARY_SOURCE_DIR = /usr/local/lib + DBUS_LIBRARIES *= libdbus-1.3.dylib + dbus_library_target.path = $${PREFIX}/lib + + DBUS_CONFIG_SOURCE_DIR = /usr/local/share/dbus-1 + DBUS_CONFIG_FILES *= session.conf + DBUS_CONFIG_FILES *= system.conf + dbus_config_target.path = $${PREFIX}/share/dbus-1 +} + for (BINARY, DBUS_BINARIES) { BINARY_PATH = $${DBUS_BINARY_SOURCE_DIR}/$${BINARY} !exists($$BINARY_PATH): error("Cannot find $${BINARY_PATH}") - dbus_target.files *= $${BINARY_PATH} + dbus_binary_target.files *= $${BINARY_PATH} +} + +for (LIBRARY, DBUS_LIBRARIES) { + LIBRARY_PATH = $${DBUS_LIBARY_SOURCE_DIR}/$${LIBRARY} + !exists($$LIBRARY_PATH): error("Cannot find $${LIBRARY_PATH}") + dbus_library_target.files *= $${LIBRARY_PATH} } for (DBUS_CONFIG_FILE, DBUS_CONFIG_FILES) { @@ -112,7 +145,7 @@ for (DBUS_CONFIG_FILE, DBUS_CONFIG_FILES) { dbus_config_target.files *= $${DBUS_CONFIG_FILE_PATH} } -win32: INSTALLS += dbus_target dbus_config_target +win32|macx: INSTALLS += dbus_binary_target dbus_library_target dbus_config_target ############### Install VC runtime ############## @@ -183,11 +216,13 @@ bitrock_builder_bin = $$(BITROCK_BUILDER) create_updater.depends = copy_installer_project win32: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} windows - unix:!macx: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} linux-x64 + else:macx: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} osx + else:unix: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} linux-x64 QMAKE_EXTRA_TARGETS += create_updater create_installer.depends = create_updater win32: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} windows --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) - unix:!macx: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} linux-x64 --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) + else:macx: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} osx --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) + else:unix: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} linux-x64 --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) QMAKE_EXTRA_TARGETS += create_installer } diff --git a/mkspecs/features/common_post.prf b/mkspecs/features/common_post.prf index c193906b3..3c3539aed 100644 --- a/mkspecs/features/common_post.prf +++ b/mkspecs/features/common_post.prf @@ -5,11 +5,24 @@ equals (TEMPLATE, lib) { # Uncomment line below to supress the default RPATH # QMAKE_LFLAGS_RPATH = - QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN\'' + + macx: QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ + else:unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN\'' } equals (TEMPLATE, app) { - QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN/../lib\'' + # Uncomment line below to supress the default RPATH + # QMAKE_LFLAGS_RPATH = + + # Add rpath to externals to run tests without installing. + # DYLD_LIBRARY_PATH isn't working anymore since OS X 10.11. + unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'$$EXTERNALSDIR\'' + + macx { + contains(CONFIG, app_bundle): QMAKE_LFLAGS *= -Wl,-rpath,@executable_path/../../../../lib/ + else: QMAKE_LFLAGS *= -Wl,-rpath,@executable_path/../lib/ + } + else:unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN/../lib\'' } ################################ diff --git a/mkspecs/features/libraries.pri b/mkspecs/features/libraries.pri index 6de344985..3e7e918b1 100644 --- a/mkspecs/features/libraries.pri +++ b/mkspecs/features/libraries.pri @@ -3,7 +3,7 @@ LIBS *= -L$$DestRoot/lib unix:!macx { # Set the rpath-link to find dependent shared libraries when linking # Note: This does not add any rpath into the binaries. - LIBS += -Wl,-rpath-link,$$DestRoot/lib + LIBS += -Wl,-rpath-link,$$DestRoot/lib -Wl,-rpath-link,$$[QT_INSTALL_LIBS] } blackgui { diff --git a/samples/blackmiscdbus/sampleblackmiscdbus.pro b/samples/blackmiscdbus/sampleblackmiscdbus.pro index d49327136..6e1923cea 100644 --- a/samples/blackmiscdbus/sampleblackmiscdbus.pro +++ b/samples/blackmiscdbus/sampleblackmiscdbus.pro @@ -8,7 +8,6 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG += blackmisc blackcore -CONFIG -= app_bundle DEPENDPATH += . $$SourceRoot/src/blackmisc $$SourceRoot/src/blackcore INCLUDEPATH += . $$SourceRoot/src diff --git a/samples/blackmiscsim/sampleblackmiscsim.pro b/samples/blackmiscsim/sampleblackmiscsim.pro index 5fb74e263..752f6c435 100644 --- a/samples/blackmiscsim/sampleblackmiscsim.pro +++ b/samples/blackmiscsim/sampleblackmiscsim.pro @@ -6,7 +6,6 @@ TARGET = sampleblackmiscsim TEMPLATE = app CONFIG += console -CONFIG -= app_bundle CONFIG += blackmisc blacksim blackcore CONFIG -= app_bundle diff --git a/samples/cliclient/samplecliclient.pro b/samples/cliclient/samplecliclient.pro index 82b587d92..4f2d05c24 100644 --- a/samples/cliclient/samplecliclient.pro +++ b/samples/cliclient/samplecliclient.pro @@ -8,7 +8,6 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG += blackmisc blackcore -CONFIG -= app_bundle DEPENDPATH += . $$SourceRoot/src INCLUDEPATH += . $$SourceRoot/src diff --git a/samples/hotkey/samplehotkey.pro b/samples/hotkey/samplehotkey.pro index 6fc47c262..028713732 100644 --- a/samples/hotkey/samplehotkey.pro +++ b/samples/hotkey/samplehotkey.pro @@ -7,9 +7,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = samplehotkey TEMPLATE = app -CONFIG -= app_bundle CONFIG += blackmisc blackinput blackcore blackgui -CONFIG -= app_bundle DEPENDPATH += . $$SourceRoot/src INCLUDEPATH += . $$SourceRoot/src diff --git a/samples/weatherdata/sampleweatherdata.pro b/samples/weatherdata/sampleweatherdata.pro index 99d65aeb7..0bfe4dbb5 100644 --- a/samples/weatherdata/sampleweatherdata.pro +++ b/samples/weatherdata/sampleweatherdata.pro @@ -6,7 +6,6 @@ TARGET = sampleweatherdata TEMPLATE = app CONFIG += console -CONFIG -= app_bundle CONFIG += blackmisc blackcore CONFIG -= app_bundle diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 6473788b1..60a56fbb9 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -436,6 +436,14 @@ namespace BlackCore } } + QString CApplication::applicationDirPath() + { + QString appDirectoryString(qApp->applicationDirPath()); + if (appDirectoryString.endsWith("Contents/MacOS")) { appDirectoryString += "/../../.."; } + QDir appDirectory(appDirectoryString); + return appDirectory.absolutePath(); + } + bool CApplication::useContexts(const CCoreFacadeConfig &coreConfig) { Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing"); diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 3356544e8..fc9cc9e86 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -158,6 +158,10 @@ namespace BlackCore //! Clear the caches static QStringList clearCaches(); + //! Returns the directory of the application. In contrast to QCoreApplication::applicationDirPath() + //! it takes Mac OS X app bundles into account and returns the directory of the bundle. + static QString applicationDirPath(); + // ----------------------- parsing ---------------------------------------- //! \name parsing of command line options diff --git a/src/blackcore/pluginmanager.cpp b/src/blackcore/pluginmanager.cpp index 305693e56..7c821f976 100644 --- a/src/blackcore/pluginmanager.cpp +++ b/src/blackcore/pluginmanager.cpp @@ -8,6 +8,7 @@ */ #include "blackcore/pluginmanager.h" +#include "blackcore/application.h" #include "blackmisc/logmessage.h" #include "blackmisc/statusmessage.h" @@ -54,7 +55,7 @@ namespace BlackCore QString IPluginManager::pluginDirectory() const { - return qApp->applicationDirPath() % QStringLiteral("/plugins"); + return sApp->applicationDirPath() % QStringLiteral("/plugins"); } bool IPluginManager::isValid(const QJsonObject &metadata) const diff --git a/src/blackcore/pluginmanagersimulator.cpp b/src/blackcore/pluginmanagersimulator.cpp index 361a988e8..3cb6aaf90 100644 --- a/src/blackcore/pluginmanagersimulator.cpp +++ b/src/blackcore/pluginmanagersimulator.cpp @@ -7,6 +7,7 @@ * contained in the LICENSE file. */ +#include "blackcore/application.h" #include "blackcore/pluginmanagersimulator.h" #include "blackcore/simulator.h" @@ -134,7 +135,7 @@ namespace BlackCore QString CPluginManagerSimulator::pluginDirectory() const { - return qApp->applicationDirPath() % QStringLiteral("/plugins/simulator"); + return sApp->applicationDirPath() % QStringLiteral("/plugins/simulator"); } } diff --git a/src/blackcore/pluginmanagerweatherdata.cpp b/src/blackcore/pluginmanagerweatherdata.cpp index 9ede4cb79..5d36783ed 100644 --- a/src/blackcore/pluginmanagerweatherdata.cpp +++ b/src/blackcore/pluginmanagerweatherdata.cpp @@ -7,6 +7,7 @@ * contained in the LICENSE file. */ +#include "blackcore/application.h" #include "blackcore/pluginmanagerweatherdata.h" #include "blackcore/weatherdata.h" @@ -66,7 +67,7 @@ namespace BlackCore QString CPluginManagerWeatherData::pluginDirectory() const { - return qApp->applicationDirPath() % QStringLiteral("/plugins/weatherdata"); + return sApp->applicationDirPath() % QStringLiteral("/plugins/weatherdata"); } } diff --git a/src/blackmisc/buildconfig.cpp b/src/blackmisc/buildconfig.cpp index 64b444f9e..3c553d521 100644 --- a/src/blackmisc/buildconfig.cpp +++ b/src/blackmisc/buildconfig.cpp @@ -68,6 +68,15 @@ namespace BlackMisc #endif } + bool CBuildConfig::isRunningOnMacOSXPlatform() + { +#ifdef Q_OS_OSX + return true; +#else + return false; +#endif + } + bool CBuildConfig::isDebugBuild() { #ifdef QT_DEBUG @@ -119,10 +128,27 @@ namespace BlackMisc return s; } + bool isAppBundle() + { + QDir bundleDir(CBuildConfig::getApplicationDir()); + bundleDir.cd("../.."); + static const bool isBundled = QFileInfo(bundleDir.absolutePath()).isBundle(); + return isBundled; + } + QString getSwiftResourceDirImpl() { QDir dir(CBuildConfig::getApplicationDir()); - if (dir.cdUp() && dir.cd("data")) + bool success = true; + + static const bool appBundle = isAppBundle(); + if (CBuildConfig::isRunningOnMacOSXPlatform() && appBundle) + { + success = dir.cd("../../../../data"); + } + else { success = dir.cd("../data"); } + + if (success) { Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir"); return dir.absolutePath(); diff --git a/src/blackmisc/buildconfig.h b/src/blackmisc/buildconfig.h index 6905f6a71..665003b0d 100644 --- a/src/blackmisc/buildconfig.h +++ b/src/blackmisc/buildconfig.h @@ -74,6 +74,9 @@ namespace BlackMisc //! Running on Windows NT platform? static bool isRunningOnWindowsNtPlatform(); + //! Running on Mac OS X platform? + static bool isRunningOnMacOSXPlatform(); + //! Application directory where current application is located //! \todo Move to to CApplication static const QString &getApplicationDir(); diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp index 74adc75fb..12db10c12 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp @@ -8,6 +8,7 @@ */ #include "simulatorxplaneconfigwindow.h" +#include "blackcore/application.h" #include "blackmisc/dbusserver.h" #include "blackmisc/fileutils.h" #include "blackmisc/simulation/xplane/xplaneutil.h" @@ -32,7 +33,7 @@ namespace { QString xBusOriginDir() { - return QCoreApplication::applicationDirPath() % QStringLiteral("/../xbus"); + return sApp->applicationDirPath() % QStringLiteral("/../xbus"); } } diff --git a/src/plugins/simulator/xplaneconfig/xplaneconfig.pro b/src/plugins/simulator/xplaneconfig/xplaneconfig.pro index cbcacfdf2..32ec9dc95 100644 --- a/src/plugins/simulator/xplaneconfig/xplaneconfig.pro +++ b/src/plugins/simulator/xplaneconfig/xplaneconfig.pro @@ -1,6 +1,6 @@ load(common_pre) -QT += core dbus widgets +QT += core dbus network widgets TARGET = simulatorxplaneconfig TEMPLATE = lib diff --git a/src/swiftcore/swiftcore.pro b/src/swiftcore/swiftcore.pro index 7ac66977f..cdbada86c 100644 --- a/src/swiftcore/swiftcore.pro +++ b/src/swiftcore/swiftcore.pro @@ -11,7 +11,6 @@ SOURCES += *.cpp HEADERS += *.h FORMS += *.ui CONFIG += blackmisc blacksound blackinput blackcore blackgui -CONFIG -= app_bundle DEPENDPATH += . $$SourceRoot/src/blackmisc \ $$SourceRoot/src/blacksound \ diff --git a/src/swiftdata/swiftdata.pro b/src/swiftdata/swiftdata.pro index 0a8e3ef28..9335d1635 100644 --- a/src/swiftdata/swiftdata.pro +++ b/src/swiftdata/swiftdata.pro @@ -11,8 +11,6 @@ SOURCES += *.cpp HEADERS += *.h FORMS += *.ui CONFIG += blackmisc blacksound blackinput blackcore blackgui -CONFIG -= app_bundle - DEPENDPATH += . $$SourceRoot/src/blackmisc \ $$SourceRoot/src/blacksound \ diff --git a/src/swiftguistandard/swiftguistandard.pro b/src/swiftguistandard/swiftguistandard.pro index 172294096..5c613a7d1 100644 --- a/src/swiftguistandard/swiftguistandard.pro +++ b/src/swiftguistandard/swiftguistandard.pro @@ -11,13 +11,6 @@ SOURCES += *.cpp HEADERS += *.h FORMS += *.ui CONFIG += blackmisc blacksound blackinput blackcore blackgui -CONFIG -= app_bundle - -macx { - deployment.files = ../blackgui/qss - deployment.path = Contents/MacOS - QMAKE_BUNDLE_DATA += deployment -} DEPENDPATH += . $$SourceRoot/src/blackmisc \ $$SourceRoot/src/blacksound \ diff --git a/src/swiftlauncher/swiftlauncher.pro b/src/swiftlauncher/swiftlauncher.pro index ca832bae7..2522d48b8 100644 --- a/src/swiftlauncher/swiftlauncher.pro +++ b/src/swiftlauncher/swiftlauncher.pro @@ -11,13 +11,6 @@ SOURCES += *.cpp HEADERS += *.h FORMS += *.ui CONFIG += blackmisc blacksound blackinput blackcore blackgui -CONFIG -= app_bundle - -macx { - deployment.files = ../blackgui/qss - deployment.path = Contents/MacOS - QMAKE_BUNDLE_DATA += deployment -} DEPENDPATH += . $$SourceRoot/src/blackmisc \ $$SourceRoot/src/blacksound \