From 836ae4f70f5fa7468f7a57e6b7582fc3dc068632 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 24 Jul 2016 06:05:57 +0000 Subject: [PATCH] cleanup configuration directories handling Signed-off-by: Ivailo Monev --- CMakeLists.txt | 22 --- cmake/modules/KatieBuildMacros.cmake | 8 - src/core/global/qconfig.cpp.cmake | 46 ++--- src/core/global/qlibraryinfo.cpp | 273 +++------------------------ 4 files changed, 37 insertions(+), 312 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da67e629b..de145223c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,28 +135,6 @@ add_feature_info(corewlan WITH_COREWLAN "an closed source something") include(mkspecs/mkspecs.cmake) -katie_generate_string("${CMAKE_INSTALL_PATH}" "CMAKE_INSTALL_PATH_STR") -katie_generate_string("${LDCONF_INSTALL_PATH}" "LDCONF_INSTALL_PATH_STR") -katie_generate_string("${PROFILE_INSTALL_PATH}" "PROFILE_INSTALL_PATH_STR") -katie_generate_string("${MAN_INSTALL_PATH}" "MAN_INSTALL_PATH_STR") -katie_generate_string("${APPLICATIONS_INSTALL_PATH}" "APPLICATIONS_INSTALL_PATH_STR") -katie_generate_string("${PIXMAPS_INSTALL_PATH}" "PIXMAPS_INSTALL_PATH_STR") - -katie_generate_string("qt_lcnsuser=${QT_LICENSE}" "QT_LICENSE_STR") -katie_generate_string("qt_lcnsprod=${QT_PRODUCT}" "QT_PRODUCT_STR" "") -katie_generate_string("qt_prfxpath=${QT_PREFIX_PATH}" "QT_PREFIX_PATH_STR") -katie_generate_string("qt_hdrspath=${QT_HEADERS_PATH}" "QT_HEADERS_PATH_STR") -katie_generate_string("qt_libspath=${QT_LIBRARIES_PATH}" "QT_LIBRARIES_PATH_STR") -katie_generate_string("qt_binspath=${QT_BINARIES_PATH}" "QT_BINARIES_PATH_STR") -katie_generate_string("qt_plugpath=${QT_PLUGINS_PATH}" "QT_PLUGINS_PATH_STR") -katie_generate_string("qt_impspath=${QT_IMPORTS_PATH}" "QT_IMPORTS_PATH_STR") -katie_generate_string("qt_datapath=${QT_DATA_PATH}" "QT_DATA_PATH_STR") -katie_generate_string("qt_trnspath=${QT_TRANSLATIONS_PATH}" "QT_TRANSLATIONS_PATH_STR") -katie_generate_string("qt_stngpath=${QT_SETTINGS_PATH}" "QT_SETTINGS_PATH_STR") -katie_generate_string("qt_docspath=${QT_DOCUMENTATION_PATH}" "QT_DOCUMENTATION_PATH_STR") -katie_generate_string("${QT_EXAMPLES_PATH}" "QT_EXAMPLES_PATH_STR") -katie_generate_string("${QT_DEMOS_PATH}" "QT_DEMOS_PATH_STR") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ toolkit derived from the Qt 4.8 framework") set(CPACK_PACKAGE_VENDOR "Katie") set(CPACK_PACKAGE_CONTACT "${KATIE_BUGREPORT}") diff --git a/cmake/modules/KatieBuildMacros.cmake b/cmake/modules/KatieBuildMacros.cmake index 77be556d5..ffedd10f1 100644 --- a/cmake/modules/KatieBuildMacros.cmake +++ b/cmake/modules/KatieBuildMacros.cmake @@ -83,14 +83,6 @@ macro(KATIE_GENERATE_PACKAGE FORTARGET REQUIRES) endif() endmacro() -function(KATIE_GENERATE_STRING INSTR OUTSTR) - if("${INSTR}" GREATER "536") - message(FATAL_ERROR "${OUTSTR} is greater than 536") - endif() - # qt used to do some magic, adding trailing \0 in a weird way via padstring script - set(${OUTSTR} "${INSTR}\\0" PARENT_SCOPE) -endfunction() - # the purpose of this function is to ensure that (1) the output string is not # null so that when it is passed to another function/macro it does not complain # about inproper number of arguments and (2) it joins the input which if quoted diff --git a/src/core/global/qconfig.cpp.cmake b/src/core/global/qconfig.cpp.cmake index 9d9806a95..54cee7c9a 100644 --- a/src/core/global/qconfig.cpp.cmake +++ b/src/core/global/qconfig.cpp.cmake @@ -40,37 +40,21 @@ ****************************************************************************/ /* Installation date */ -static const char qt_configure_installation [12+11] = "${KATIE_DATE}"; +static const char* qt_configure_installation = "${KATIE_DATE}"; /* License Info */ -static const char qt_configure_licensee_str [256 + 12] = "${QT_LICENSE_STR}"; -static const char qt_configure_licensed_products_str [256 + 12] = "${QT_PRODUCT_STR}"; +static const char* qt_configure_licensee_str = "${QT_LICENSE}\\0"; +static const char* qt_configure_licensed_products_str = "${QT_PRODUCT}\\0"; -static const char qt_configure_prefix_path_str [256 + 12] = "${QT_PREFIX_PATH_STR}"; -static const char qt_configure_headers_path_str [256 + 12] = "${QT_HEADERS_PATH_STR}"; -static const char qt_configure_libraries_path_str [256 + 12] = "${QT_LIBRARIES_PATH_STR}"; -static const char qt_configure_binaries_path_str [256 + 12] = "${QT_BINARIES_PATH_STR}"; -static const char qt_configure_plugins_path_str [256 + 12] = "${QT_PLUGINS_PATH_STR}"; -static const char qt_configure_imports_path_str [256 + 12] = "${QT_IMPORTS_PATH_STR}"; -static const char qt_configure_data_path_str [256 + 12] = "${QT_DATA_PATH_STR}"; -static const char qt_configure_translations_path_str [256 + 12] = "${QT_TRANSLATIONS_PATH_STR}"; -static const char qt_configure_settings_path_str [256 + 12] = "${QT_SETTINGS_PATH_STR}"; -static const char qt_configure_documentation_path_str[256 + 12] = "${QT_DOCUMENTATION_PATH_STR}"; -static const char qt_configure_examples_path_str [256 + 12] = "${QT_EXAMPLES_PATH_STR}"; -static const char qt_configure_demos_path_str [256 + 12] = "${QT_DEMOS_PATH_STR}"; - -/* strlen( "qt_lcnsxxxx" ) == 12 */ -#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12; -#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12; -#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12; -#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12; -#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12; -#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12; -#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12; -#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12; -#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12; -#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12; -#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12; -#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12; -#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12; -#define QT_CONFIGURE_DEMOS_PATH qt_configure_demos_path_str + 12; +static const char* qt_configure_prefix_path_str = "${QT_PREFIX_PATH}\\0"; +static const char* qt_configure_headers_path_str = "${QT_HEADERS_PATH}\\0"; +static const char* qt_configure_libraries_path_str = "${QT_LIBRARIES_PATH}\\0"; +static const char* qt_configure_binaries_path_str = "${QT_BINARIES_PATH}\\0"; +static const char* qt_configure_plugins_path_str = "${QT_PLUGINS_PATH}\\0"; +static const char* qt_configure_imports_path_str = "${QT_IMPORTS_PATH}\\0"; +static const char* qt_configure_data_path_str = "${QT_DATA_PATH}\\0"; +static const char* qt_configure_translations_path_str = "${QT_TRANSLATIONS_PATH}\\0"; +static const char* qt_configure_settings_path_str = "${QT_SETTINGS_PATH}\\0"; +static const char* qt_configure_documentation_path_str = "${QT_DOCUMENTATION_PATH}\\0"; +static const char* qt_configure_examples_path_str = "${QT_EXAMPLES_PATH}\\0"; +static const char* qt_configure_demos_path_str = "${QT_DEMOS_PATH}\\0"; diff --git a/src/core/global/qlibraryinfo.cpp b/src/core/global/qlibraryinfo.cpp index 54047a779..b1396b172 100644 --- a/src/core/global/qlibraryinfo.cpp +++ b/src/core/global/qlibraryinfo.cpp @@ -66,71 +66,6 @@ extern void qDumpCPUFeatures(); // in qsimd.cpp #ifndef QT_NO_SETTINGS -struct QLibrarySettings -{ - QLibrarySettings(); - QScopedPointer settings; -}; -Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings) - -class QLibraryInfoPrivate -{ -public: - static QSettings *findConfiguration(); - static void cleanup() - { - QLibrarySettings *ls = qt_library_settings(); - if (ls) - ls->settings.reset(0); - } - static QSettings *configuration() - { - QLibrarySettings *ls = qt_library_settings(); - return ls ? ls->settings.data() : 0; - } -}; - -QLibrarySettings::QLibrarySettings() - : settings(QLibraryInfoPrivate::findConfiguration()) -{ -#ifndef QT_BOOTSTRAPPED - qAddPostRoutine(QLibraryInfoPrivate::cleanup); -#endif -} - -QSettings *QLibraryInfoPrivate::findConfiguration() -{ - QString qtconfig = QLatin1String(":/qt/etc/qt.conf"); -#ifdef QT_BOOTSTRAPPED - if(!QFile::exists(qtconfig)) - qtconfig = qmake_libraryInfoFile(); -#else - if (!QFile::exists(qtconfig) && QCoreApplication::instance()) { -#ifdef Q_OS_MAC - CFBundleRef bundleRef = CFBundleGetMainBundle(); - if (bundleRef) { - QCFType urlRef = CFBundleCopyResourceURL(bundleRef, - QCFString(QLatin1String("qt.conf")), - 0, - 0); - if (urlRef) { - QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); - qtconfig = QDir::cleanPath(path); - } - } - if (qtconfig.isEmpty()) -#endif - { - QDir pwd(QCoreApplication::applicationDirPath()); - qtconfig = pwd.filePath(QLatin1String("qt.conf")); - } - } -#endif - if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); - return 0; //no luck -} - /*! \class QLibraryInfo \brief The QLibraryInfo class provides information about the Qt library. @@ -177,8 +112,7 @@ QLibraryInfo::QLibraryInfo() QString QLibraryInfo::licensee() { - const char *str = QT_CONFIGURE_LICENSEE; - return QString::fromLocal8Bit(str); + return QString::fromLocal8Bit(qt_configure_licensee_str); } /*! @@ -190,8 +124,7 @@ QLibraryInfo::licensee() QString QLibraryInfo::licensedProducts() { - const char *str = QT_CONFIGURE_LICENSED_PRODUCTS; - return QString::fromLatin1(str); + return QString::fromLatin1(qt_configure_licensed_products_str); } /*! @@ -218,7 +151,7 @@ QLibraryInfo::buildKey() QDate QLibraryInfo::buildDate() { - return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); + return QDate::fromString(QString::fromLatin1(qt_configure_installation), Qt::ISODate); } #endif //QT_NO_DATESTRING @@ -231,207 +164,45 @@ QString QLibraryInfo::location(LibraryLocation loc) { QString ret; - if(!QLibraryInfoPrivate::configuration()) { - const char *path = 0; - switch (loc) { -#ifdef QT_CONFIGURE_PREFIX_PATH + switch (loc) { case PrefixPath: - path = QT_CONFIGURE_PREFIX_PATH; - break; -#endif -#ifdef QT_CONFIGURE_DOCUMENTATION_PATH - case DocumentationPath: - path = QT_CONFIGURE_DOCUMENTATION_PATH; - break; -#endif -#ifdef QT_CONFIGURE_HEADERS_PATH - case HeadersPath: - path = QT_CONFIGURE_HEADERS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_LIBRARIES_PATH - case LibrariesPath: - path = QT_CONFIGURE_LIBRARIES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_BINARIES_PATH - case BinariesPath: - path = QT_CONFIGURE_BINARIES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_PLUGINS_PATH - case PluginsPath: - path = QT_CONFIGURE_PLUGINS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_IMPORTS_PATH - case ImportsPath: - path = QT_CONFIGURE_IMPORTS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_DATA_PATH - case DataPath: - path = QT_CONFIGURE_DATA_PATH; - break; -#endif -#ifdef QT_CONFIGURE_TRANSLATIONS_PATH - case TranslationsPath: - path = QT_CONFIGURE_TRANSLATIONS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_SETTINGS_PATH - case SettingsPath: - path = QT_CONFIGURE_SETTINGS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_EXAMPLES_PATH - case ExamplesPath: - path = QT_CONFIGURE_EXAMPLES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_DEMOS_PATH - case DemosPath: - path = QT_CONFIGURE_DEMOS_PATH; - break; -#endif - default: - break; - } - - if (path) - ret = QString::fromLocal8Bit(path); - } else { - QString key; - QString defaultValue; - switch(loc) { - case PrefixPath: - key = QLatin1String("Prefix"); - break; - case DocumentationPath: - key = QLatin1String("Documentation"); - defaultValue = QLatin1String("doc"); + ret = QString::fromLocal8Bit(qt_configure_prefix_path_str); break; case HeadersPath: - key = QLatin1String("Headers"); - defaultValue = QLatin1String("include"); + ret = QString::fromLocal8Bit(qt_configure_headers_path_str); break; case LibrariesPath: - key = QLatin1String("Libraries"); - defaultValue = QLatin1String("lib"); + ret = QString::fromLocal8Bit(qt_configure_libraries_path_str); break; case BinariesPath: - key = QLatin1String("Binaries"); - defaultValue = QLatin1String("bin"); + ret = QString::fromLocal8Bit(qt_configure_binaries_path_str); break; case PluginsPath: - key = QLatin1String("Plugins"); - defaultValue = QLatin1String("plugins"); + ret = QString::fromLocal8Bit(qt_configure_plugins_path_str); break; case ImportsPath: - key = QLatin1String("Imports"); - defaultValue = QLatin1String("imports"); + ret = QString::fromLocal8Bit(qt_configure_imports_path_str); break; case DataPath: - key = QLatin1String("Data"); + ret = QString::fromLocal8Bit(qt_configure_data_path_str); break; case TranslationsPath: - key = QLatin1String("Translations"); - defaultValue = QLatin1String("translations"); + ret = QString::fromLocal8Bit(qt_configure_translations_path_str); break; case SettingsPath: - key = QLatin1String("Settings"); + ret = QString::fromLocal8Bit(qt_configure_settings_path_str); + break; + case DocumentationPath: + ret = QString::fromLocal8Bit(qt_configure_documentation_path_str); break; case ExamplesPath: - key = QLatin1String("Examples"); + ret = QString::fromLocal8Bit(qt_configure_examples_path_str); break; case DemosPath: - key = QLatin1String("Demos"); + ret = QString::fromLocal8Bit(qt_configure_demos_path_str); break; default: break; - } - - if(!key.isNull()) { - QSettings *config = QLibraryInfoPrivate::configuration(); - config->beginGroup(QLatin1String("Paths")); - - QString subKey; - { - /* - find the child group whose version number is closest - to the library version. for example and we have the - following groups: - - Paths - Paths/4.0 - Paths/4.1.2 - Paths/4.2.5 - Paths/5 - - if QT_VERSION is 4.0.1, then we use 'Paths/4.0' - if QT_VERSION is 4.1.5, then we use 'Paths/4.1.2' - if QT_VERSION is 4.6.3, then we use 'Paths/4.2.5' - if QT_VERSION is 6.0.2, then we use 'Paths/5' - - note: any of the trailing version numbers may be - omitted (in which case, they default to zero), - i.e. 4 == 4.0.0, 4.1 == 4.1.0, and so on - */ - enum { - QT_MAJOR = ((QT_VERSION >> 16) & 0xFF), - QT_MINOR = ((QT_VERSION >> 8) & 0xFF), - QT_PATCH = (QT_VERSION & 0xFF) - }; - int maj = 0, min = 0, pat = 0; - QStringList children = config->childGroups(); - for(int child = 0; child < children.size(); ++child) { - QString cver = children.at(child); - QStringList cver_list = cver.split(QLatin1Char('.')); - if(cver_list.size() > 0 && cver_list.size() < 4) { - bool ok; - int cmaj = -1, cmin = -1, cpat = -1; - cmaj = cver_list[0].toInt(&ok); - if(!ok || cmaj < 0) - continue; - if(cver_list.size() >= 2) { - cmin = cver_list[1].toInt(&ok); - if(!ok) - continue; - if(cmin < 0) - cmin = -1; - } - if(cver_list.size() >= 3) { - cpat = cver_list[2].toInt(&ok); - if(!ok) - continue; - if(cpat < 0) - cpat = -1; - } - if((cmaj >= maj && cmaj <= QT_MAJOR) && - (cmin == -1 || (cmin >= min && cmin <= QT_MINOR)) && - (cpat == -1 || (cpat >= pat && cpat <= QT_PATCH)) && - config->contains(cver + QLatin1Char('/') + key)) { - subKey = cver + QLatin1Char('/'); - maj = cmaj; - min = cmin; - pat = cpat; - } - } - } - } - ret = config->value(subKey + key, defaultValue).toString(); - // expand environment variables in the form $(ENVVAR) - int rep; - QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); - reg_var.setMinimal(true); - while((rep = reg_var.indexIn(ret)) != -1) { - ret.replace(rep, reg_var.matchedLength(), - QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2, - reg_var.matchedLength() - 3).toLatin1().constData()).constData())); - } - - config->endGroup(); - } } if (QDir::isRelativePath(ret)) { @@ -514,10 +285,10 @@ void qt_core_boilerplate() "Installation prefix: %s\n" "Library path: %s\n" "Include path: %s\n", - qt_configure_installation + 12, - qt_configure_prefix_path_str + 12, - qt_configure_libraries_path_str + 12, - qt_configure_headers_path_str + 12); + qt_configure_installation, + qt_configure_prefix_path_str, + qt_configure_libraries_path_str, + qt_configure_headers_path_str); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)();