diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/global.pri | 12 | ||||
-rw-r--r-- | src/corelib/global/qconfig-bootstrapped.h | 4 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 116 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 23 |
5 files changed, 124 insertions, 33 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index f74662b464..36655ca1dd 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -47,19 +47,11 @@ if(linux*|hurd*):!cross_compile:!static:!*-armcc* { DEFINES += ELF_INTERPRETER=\\\"$$system(LC_ALL=C readelf -l /bin/ls | perl -n -e \'$$prog\')\\\" } -slog2 { +qtConfig(slog2): \ LIBS_PRIVATE += -lslog2 - DEFINES += QT_USE_SLOG2 -} -journald { +qtConfig(journald): \ QMAKE_USE_PRIVATE += journald - DEFINES += QT_USE_JOURNALD -} - -syslog { - DEFINES += QT_USE_SYSLOG -} gcc:ltcg { versiontagging_compiler.commands = $$QMAKE_CXX -c $(CXXFLAGS) $(INCPATH) diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 4629a57485..d0e45478cc 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -69,10 +69,14 @@ #define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 #define QT_NO_DATASTREAM #define QT_FEATURE_iconv -1 +#define QT_FEATURE_icu -1 +#define QT_FEATURE_journald -1 #define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT #define QT_NO_SYSTEMLOCALE +#define QT_FEATURE_slog2 -1 +#define QT_FEATURE_syslog -1 #define QT_NO_THREAD #define QT_FEATURE_timezone -1 #define QT_FEATURE_topleveldomain -1 diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 27fe10a79e..87ee75fa45 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -41,15 +41,18 @@ #include "qdir.h" #include "qstringlist.h" #include "qfile.h" +#include "qtemporaryfile.h" #include "qsettings.h" #include "qlibraryinfo.h" #include "qscopedpointer.h" #ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE +extern QString qmake_absoluteLocation(); extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE #else +# include "qconfig.cpp" # include "qcoreapplication.h" #endif @@ -57,7 +60,6 @@ QT_END_NAMESPACE # include "private/qcore_mac_p.h" #endif -#include "qconfig.cpp" #include "archdetect.cpp" QT_BEGIN_NAMESPACE @@ -70,9 +72,16 @@ struct QLibrarySettings { QLibrarySettings(); void load(); +#ifdef QT_BUILD_QMAKE + void loadBuiltinValues(QSettings *config); +#endif QScopedPointer<QSettings> settings; #ifdef QT_BUILD_QMAKE + QString builtinValues[QLibraryInfo::LastHostPath + 1]; +# ifndef Q_OS_WIN + QString builtinSettingsPath; +# endif bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; @@ -88,6 +97,11 @@ class QLibraryInfoPrivate public: static QSettings *findConfiguration(); #ifdef QT_BUILD_QMAKE + static void reload() + { + if (qt_library_settings.exists()) + qt_library_settings->load(); + } static bool haveGroup(QLibraryInfo::PathGroup group) { QLibrarySettings *ls = qt_library_settings(); @@ -99,6 +113,25 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } + static bool sysrootify() + { + // This is actually bogus, as it does not consider post-configure settings. + QLibrarySettings *ls = qt_library_settings(); + return ls ? (!ls->builtinValues[QLibraryInfo::SysrootPath].isEmpty() + && ls->builtinValues[QLibraryInfo::ExtPrefixPath].isEmpty()) : false; + } + static QString builtinValue(int loc) + { + QLibrarySettings *ls = qt_library_settings(); + return ls ? ls->builtinValues[loc] : QString(); + } +# ifndef Q_OS_WIN + static QString builtinSettingsPath() + { + QLibrarySettings *ls = qt_library_settings(); + return ls ? ls->builtinSettingsPath : QString(); + } +# endif #endif static QSettings *configuration() { @@ -122,6 +155,20 @@ QLibrarySettings::QLibrarySettings() load(); } +#ifdef QT_BUILD_QMAKE +static QByteArray qtconfSeparator() +{ +# ifdef Q_OS_WIN + QByteArray header = QByteArrayLiteral("\r\n===========================================================\r\n"); +# else + QByteArray header = QByteArrayLiteral("\n===========================================================\n"); +# endif + QByteArray content = QByteArrayLiteral("==================== qt.conf beginning ===================="); + // Assemble from pieces to avoid that the string appears in a raw executable + return header + content + header; +} +#endif + void QLibrarySettings::load() { // If we get any settings here, those won't change when the application shows up. @@ -159,6 +206,27 @@ void QLibrarySettings::load() havePaths = false; #endif } + +#ifdef QT_BUILD_QMAKE + // Try to use an embedded qt.conf appended to the QMake executable. + QFile qmakeFile(qmake_absoluteLocation()); + if (!qmakeFile.open(QIODevice::ReadOnly)) + return; + qmakeFile.seek(qmakeFile.size() - 10000); + QByteArray tail = qmakeFile.read(10000); + QByteArray separator = qtconfSeparator(); + int qtconfOffset = tail.lastIndexOf(separator); + if (qtconfOffset < 0) + return; + tail.remove(0, qtconfOffset + separator.size()); + // If QSettings had a c'tor taking a QIODevice, we'd pass a QBuffer ... + QTemporaryFile tmpFile; + tmpFile.open(); + tmpFile.write(tail); + tmpFile.close(); + QSettings builtinSettings(tmpFile.fileName(), QSettings::IniFormat); + loadBuiltinValues(&builtinSettings); +#endif } QSettings *QLibraryInfoPrivate::findConfiguration() @@ -420,10 +488,30 @@ static const struct { { "HostData", "." }, { "TargetSpec", "" }, { "HostSpec", "" }, + { "ExtPrefix", "" }, { "HostPrefix", "" }, #endif }; +#ifdef QT_BUILD_QMAKE +void QLibrarySettings::loadBuiltinValues(QSettings *config) +{ + config->beginGroup(QLatin1String("Paths")); + for (int i = 0; i <= QLibraryInfo::LastHostPath; i++) + builtinValues[i] = config->value(QLatin1String(qtConfEntries[i].key), + QLatin1String(qtConfEntries[i].value)).toString(); +# ifndef Q_OS_WIN + builtinSettingsPath = config->value(QLatin1String("Settings")).toString(); +# endif + config->endGroup(); +} + +void QLibraryInfo::reload() +{ + QLibraryInfoPrivate::reload(); +} +#endif + /*! Returns the location specified by \a loc. */ @@ -434,7 +522,7 @@ QLibraryInfo::location(LibraryLocation loc) QString ret = rawLocation(loc, FinalPaths); // Automatically prepend the sysroot to target paths - if ((loc < SysrootPath || loc > LastHostPath) && QT_CONFIGURE_SYSROOTIFY_PREFIX) { + if ((loc < SysrootPath || loc > LastHostPath) && QLibraryInfoPrivate::sysrootify()) { QString sysroot = rawLocation(SysrootPath, FinalPaths); if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) @@ -528,28 +616,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) #endif // QT_NO_SETTINGS if (!fromConf) { +#ifdef QT_BUILD_QMAKE + if ((unsigned)loc <= (unsigned)LastHostPath) { + if (loc == PrefixPath && group != DevicePaths) + ret = QLibraryInfoPrivate::builtinValue(ExtPrefixPath); + else + ret = QLibraryInfoPrivate::builtinValue(loc); +# ifndef Q_OS_WIN // On Windows we use the registry + } else if (loc == SettingsPath) { + ret = QLibraryInfoPrivate::builtinSettingsPath(); +# endif + } +#else // QT_BUILD_QMAKE const char * volatile path = 0; if (loc == PrefixPath) { - path = -#ifdef QT_BUILD_QMAKE - (group != DevicePaths) ? - QT_CONFIGURE_EXT_PREFIX_PATH : -#endif - QT_CONFIGURE_PREFIX_PATH; + path = QT_CONFIGURE_PREFIX_PATH; } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; #ifndef Q_OS_WIN // On Windows we use the registry } else if (loc == SettingsPath) { path = QT_CONFIGURE_SETTINGS_PATH; #endif -#ifdef QT_BUILD_QMAKE - } else if (loc == HostPrefixPath) { - path = QT_CONFIGURE_HOST_PREFIX_PATH; -#endif } if (path) ret = QString::fromLocal8Bit(path); +#endif } #ifdef QT_BUILD_QMAKE diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 55be706382..9d794ce1da 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -96,6 +96,7 @@ public: HostDataPath, TargetSpecPath, HostSpecPath, + ExtPrefixPath, HostPrefixPath, LastHostPath = HostPrefixPath, #endif @@ -105,6 +106,7 @@ public: #ifdef QT_BUILD_QMAKE enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths }; static QString rawLocation(LibraryLocation, PathGroup); + static void reload(); #endif static QStringList platformPluginArguments(const QString &platformName); diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 6984097b70..6b90a47388 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qglobal_p.h" #include "qlogging.h" #include "qlist.h" #include "qbytearray.h" @@ -59,7 +60,7 @@ #ifdef Q_OS_WIN #include <qt_windows.h> #endif -#ifdef QT_USE_SLOG2 +#if QT_CONFIG(slog2) #include <slog2.h> #endif @@ -67,12 +68,12 @@ #include <android/log.h> #endif -#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) +#if QT_CONFIG(journald) # define SD_JOURNAL_SUPPRESS_LOCATION # include <systemd/sd-journal.h> # include <syslog.h> #endif -#if defined(QT_USE_SYSLOG) && !defined(QT_BOOTSTRAPPED) +#if QT_CONFIG(syslog) # include <syslog.h> #endif #ifdef Q_OS_UNIX @@ -93,7 +94,7 @@ # endif #endif -#if defined(QT_USE_SLOG2) +#if QT_CONFIG(slog2) extern char *__progname; #endif @@ -1285,7 +1286,7 @@ static QString formatBacktraceForLogMessage(const QMessagePattern::BacktracePara } #endif // QLOGGING_HAVE_BACKTRACE && !QT_BOOTSTRAPPED -#if defined(QT_USE_SLOG2) +#if QT_CONFIG(slog2) #ifndef QT_LOG_CODE #define QT_LOG_CODE 9000 #endif @@ -1334,7 +1335,7 @@ static void slog2_default_handler(QtMsgType msgType, const char *message) //writes to the slog2 buffer slog2c(NULL, QT_LOG_CODE, severity, message); } -#endif // QT_USE_SLOG2 +#endif // slog2 Q_GLOBAL_STATIC(QMessagePattern, qMessagePattern) @@ -1483,7 +1484,7 @@ static QBasicAtomicPointer<void (QtMsgType, const char*)> msgHandler = Q_BASIC_A // pointer to QtMessageHandler debug handler (with context) static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = Q_BASIC_ATOMIC_INITIALIZER(qDefaultMessageHandler); -#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) +#if QT_CONFIG(journald) static void systemd_default_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &message) @@ -1517,7 +1518,7 @@ static void systemd_default_message_handler(QtMsgType type, } #endif -#ifdef QT_USE_SYSLOG +#if QT_CONFIG(syslog) static void syslog_default_message_handler(QtMsgType type, const char *message) { int priority = LOG_INFO; // Informational @@ -1581,14 +1582,14 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con logMessage.append(QLatin1Char('\n')); OutputDebugString(reinterpret_cast<const wchar_t *>(logMessage.utf16())); return; -#elif defined(QT_USE_SLOG2) +#elif QT_CONFIG(slog2) logMessage.append(QLatin1Char('\n')); slog2_default_handler(type, logMessage.toLocal8Bit().constData()); return; -#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) +#elif QT_CONFIG(journald) systemd_default_message_handler(type, context, logMessage); return; -#elif defined(QT_USE_SYSLOG) && !defined(QT_BOOTSTRAPPED) +#elif QT_CONFIG(syslog) syslog_default_message_handler(type, logMessage.toUtf8().constData()); return; #elif defined(Q_OS_ANDROID) |