| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qlibraryinfo.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | - | |
| 2 | - | |
| 3 | - | |
| 4 | - | |
| 5 | - | |
| 6 | - | |
| 7 | - | |
| 8 | - | |
| 9 | - | |
| 10 | - | |
| 11 | - | |
| 12 | - | |
| 13 | - | |
| 14 | - | |
| 15 | - | |
| 16 | extern void qDumpCPUFeatures(); | - |
| 17 | - | |
| 18 | - | |
| 19 | - | |
| 20 | struct QLibrarySettings | - |
| 21 | { | - |
| 22 | QLibrarySettings(); | - |
| 23 | void load(); | - |
| 24 | - | |
| 25 | QScopedPointer<QSettings> settings; | - |
| 26 | - | |
| 27 | - | |
| 28 | - | |
| 29 | - | |
| 30 | - | |
| 31 | - | |
| 32 | bool reloadOnQAppAvailable; | - |
| 33 | - | |
| 34 | }; | - |
| 35 | namespace { namespace Q_QGS_qt_library_settings { typedef QLibrarySettings Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QLibrarySettings, Q_QGS_qt_library_settings::innerFunction, Q_QGS_qt_library_settings::guard> qt_library_settings; | - |
| 36 | - | |
| 37 | class QLibraryInfoPrivate | - |
| 38 | { | - |
| 39 | public: | - |
| 40 | static QSettings *findConfiguration(); | - |
| 41 | static QSettings *configuration() | - |
| 42 | { | - |
| 43 | QLibrarySettings *ls = qt_library_settings(); | - |
| 44 | if (ls) { | - |
| 45 | - | |
| 46 | if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != 0) | - |
| 47 | ls->load(); | - |
| 48 | - | |
| 49 | return ls->settings.data(); | - |
| 50 | } else { | - |
| 51 | return 0; | - |
| 52 | } | - |
| 53 | } | - |
| 54 | }; | - |
| 55 | - | |
| 56 | static const char platformsSection[] = "Platforms"; | - |
| 57 | - | |
| 58 | QLibrarySettings::QLibrarySettings() | - |
| 59 | { | - |
| 60 | load(); | - |
| 61 | } | - |
| 62 | - | |
| 63 | void QLibrarySettings::load() | - |
| 64 | { | - |
| 65 | - | |
| 66 | settings.reset(QLibraryInfoPrivate::findConfiguration()); | - |
| 67 | - | |
| 68 | reloadOnQAppAvailable = (settings.data() == 0 && QCoreApplication::instance() == 0); | - |
| 69 | bool haveDevicePaths; | - |
| 70 | bool haveEffectivePaths; | - |
| 71 | bool havePaths; | - |
| 72 | - | |
| 73 | if (settings) { | - |
| 74 | - | |
| 75 | - | |
| 76 | QStringList children = settings->childGroups(); | - |
| 77 | haveDevicePaths = children.contains(QLatin1String("DevicePaths")); | - |
| 78 | - | |
| 79 | - | |
| 80 | - | |
| 81 | - | |
| 82 | bool haveEffectiveSourcePaths = false; | - |
| 83 | - | |
| 84 | haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); | - |
| 85 | - | |
| 86 | havePaths = (!haveDevicePaths && !haveEffectivePaths | - |
| 87 | && !children.contains(QLatin1String(platformsSection))) | - |
| 88 | || children.contains(QLatin1String("Paths")); | - |
| 89 | - | |
| 90 | if (!havePaths) | - |
| 91 | settings.reset(0); | - |
| 92 | - | |
| 93 | - | |
| 94 | - | |
| 95 | - | |
| 96 | - | |
| 97 | - | |
| 98 | - | |
| 99 | } | - |
| 100 | } | - |
| 101 | - | |
| 102 | QSettings *QLibraryInfoPrivate::findConfiguration() | - |
| 103 | { | - |
| 104 | QString qtconfig = ([]() -> QString { enum { Size = sizeof(u"" ":/qt/etc/qt.conf")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt/etc/qt.conf" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - |
| 105 | if (QFile::exists(qtconfig)) | - |
| 106 | return new QSettings(qtconfig, QSettings::IniFormat); | - |
| 107 | if (QCoreApplication::instance()) { | - |
| 108 | QDir pwd(QCoreApplication::applicationDirPath()); | - |
| 109 | qtconfig = pwd.filePath(QLatin1String("qt.conf")); | - |
| 110 | if (QFile::exists(qtconfig)) | - |
| 111 | return new QSettings(qtconfig, QSettings::IniFormat); | - |
| 112 | } | - |
| 113 | - | |
| 114 | return 0; | - |
| 115 | } | - |
| 116 | QLibraryInfo::QLibraryInfo() | - |
| 117 | { } | - |
| 118 | - | |
| 119 | - | |
| 120 | - | |
| 121 | - | |
| 122 | - | |
| 123 | - | |
| 124 | - | |
| 125 | QString | - |
| 126 | QLibraryInfo::licensee() | - |
| 127 | { | - |
| 128 | const char * volatile str = qt_configure_licensee_str + 12; | - |
| 129 | return QString::fromLocal8Bit(str); | - |
| 130 | } | - |
| 131 | - | |
| 132 | - | |
| 133 | - | |
| 134 | - | |
| 135 | - | |
| 136 | - | |
| 137 | - | |
| 138 | QString | - |
| 139 | QLibraryInfo::licensedProducts() | - |
| 140 | { | - |
| 141 | const char * volatile str = qt_configure_licensed_products_str + 12; | - |
| 142 | return QString::fromLatin1(str); | - |
| 143 | } | - |
| 144 | QDate | - |
| 145 | QLibraryInfo::buildDate() | - |
| 146 | { | - |
| 147 | return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate); | - |
| 148 | } | - |
| 149 | const char *QLibraryInfo::build() noexcept | - |
| 150 | { | - |
| 151 | return executed 1436 times by 506 tests: "Qt " "5.67.4"1" " (" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" " shared (dynamic)" " debug" " build; by " "GCC " "4.9.2" ")";return "Qt " "5.7.1" " (" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" " shared (dynamic)" " debug" " build; by " "GCC " "4.9.2" ")";Executed by:
executed 1436 times by 506 tests: return "Qt " "5.7.1" " (" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" " shared (dynamic)" " debug" " build; by " "GCC " "4.9.2" ")";Executed by:
| 1436 |
| 152 | } | - |
| 153 | - | |
| 154 | - | |
| 155 | - | |
| 156 | - | |
| 157 | - | |
| 158 | - | |
| 159 | bool | - |
| 160 | QLibraryInfo::isDebugBuild() | - |
| 161 | { | - |
| 162 | - | |
| 163 | return true; | - |
| 164 | - | |
| 165 | - | |
| 166 | - | |
| 167 | } | - |
| 168 | static const struct { | - |
| 169 | char key[19], value[13]; | - |
| 170 | } qtConfEntries[] = { | - |
| 171 | { "Prefix", "." }, | - |
| 172 | { "Documentation", "doc" }, | - |
| 173 | { "Headers", "include" }, | - |
| 174 | { "Libraries", "lib" }, | - |
| 175 | - | |
| 176 | - | |
| 177 | - | |
| 178 | { "LibraryExecutables", "libexec" }, | - |
| 179 | - | |
| 180 | { "Binaries", "bin" }, | - |
| 181 | { "Plugins", "plugins" }, | - |
| 182 | { "Imports", "imports" }, | - |
| 183 | { "Qml2Imports", "qml" }, | - |
| 184 | { "ArchData", "." }, | - |
| 185 | { "Data", "." }, | - |
| 186 | { "Translations", "translations" }, | - |
| 187 | { "Examples", "examples" }, | - |
| 188 | { "Tests", "tests" }, | - |
| 189 | }; | - |
| 190 | - | |
| 191 | - | |
| 192 | - | |
| 193 | - | |
| 194 | QString | - |
| 195 | QLibraryInfo::location(LibraryLocation loc) | - |
| 196 | { | - |
| 197 | QString ret; | - |
| 198 | if (!QLibraryInfoPrivate::configuration()) | - |
| 199 | - | |
| 200 | { | - |
| 201 | const char * volatile path = 0; | - |
| 202 | if (loc == PrefixPath) { | - |
| 203 | path = | - |
| 204 | - | |
| 205 | - | |
| 206 | - | |
| 207 | - | |
| 208 | qt_configure_prefix_path_str + 12; | - |
| 209 | } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { | - |
| 210 | path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; | - |
| 211 | - | |
| 212 | } else if (loc == SettingsPath) { | - |
| 213 | path = "etc/xdg"; | - |
| 214 | - | |
| 215 | - | |
| 216 | - | |
| 217 | - | |
| 218 | - | |
| 219 | } | - |
| 220 | - | |
| 221 | if (path) | - |
| 222 | ret = QString::fromLocal8Bit(path); | - |
| 223 | - | |
| 224 | } else { | - |
| 225 | QString key; | - |
| 226 | QString defaultValue; | - |
| 227 | if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { | - |
| 228 | key = QLatin1String(qtConfEntries[loc].key); | - |
| 229 | defaultValue = QLatin1String(qtConfEntries[loc].value); | - |
| 230 | } | - |
| 231 | - | |
| 232 | else if (loc == SettingsPath) { | - |
| 233 | key = QLatin1String("Settings"); | - |
| 234 | defaultValue = QLatin1String("."); | - |
| 235 | } | - |
| 236 | - | |
| 237 | - | |
| 238 | if(!key.isNull()) { | - |
| 239 | QSettings *config = QLibraryInfoPrivate::configuration(); | - |
| 240 | config->beginGroup(QLatin1String( | - |
| 241 | - | |
| 242 | - | |
| 243 | - | |
| 244 | - | |
| 245 | - | |
| 246 | "Paths")); | - |
| 247 | - | |
| 248 | ret = config->value(key, defaultValue).toString(); | - |
| 249 | int rep; | - |
| 250 | QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); | - |
| 251 | reg_var.setMinimal(true); | - |
| 252 | while((rep = reg_var.indexIn(ret)) != -1) { | - |
| 253 | ret.replace(rep, reg_var.matchedLength(), | - |
| 254 | QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2, | - |
| 255 | reg_var.matchedLength() - 3).toLatin1().constData()).constData())); | - |
| 256 | } | - |
| 257 | - | |
| 258 | config->endGroup(); | - |
| 259 | - | |
| 260 | ret = QDir::fromNativeSeparators(ret); | - |
| 261 | } | - |
| 262 | - | |
| 263 | } | - |
| 264 | - | |
| 265 | - | |
| 266 | - | |
| 267 | - | |
| 268 | - | |
| 269 | - | |
| 270 | - | |
| 271 | if (!ret.isEmpty() && QDir::isRelativePath(ret)) { | - |
| 272 | QString baseDir; | - |
| 273 | if (loc == PrefixPath) { | - |
| 274 | if (QCoreApplication::instance()) { | - |
| 275 | baseDir = QCoreApplication::applicationDirPath(); | - |
| 276 | } else { | - |
| 277 | baseDir = QDir::currentPath(); | - |
| 278 | } | - |
| 279 | } else { | - |
| 280 | - | |
| 281 | baseDir = location(PrefixPath); | - |
| 282 | } | - |
| 283 | - | |
| 284 | ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); | - |
| 285 | } | - |
| 286 | return ret; | - |
| 287 | } | - |
| 288 | QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) | - |
| 289 | { | - |
| 290 | - | |
| 291 | QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration()); | - |
| 292 | if (!settings.isNull()) { | - |
| 293 | QString key = QLatin1String(platformsSection); | - |
| 294 | key += QLatin1Char('/'); | - |
| 295 | key += platformName; | - |
| 296 | key += QLatin1String("Arguments"); | - |
| 297 | return settings->value(key).toStringList(); | - |
| 298 | } | - |
| 299 | - | |
| 300 | return QStringList(); | - |
| 301 | } | - |
| 302 | - | |
| 303 | - | |
| 304 | - | |
| 305 | - | |
| 306 | - | |
| 307 | - | |
| 308 | - | |
| 309 | extern const char qt_core_interpreter[] __attribute__((section(".interp"))) | - |
| 310 | = "/lib64/ld-linux-x86-64.so.2"; | - |
| 311 | - | |
| 312 | extern "C" void qt_core_boilerplate(); | - |
| 313 | void qt_core_boilerplate() | - |
| 314 | { | - |
| 315 | printf("This is the QtCore library version " "Qt " "5.67.4"1" " (" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" " shared (dynamic)" " debug" " build; by " "GCC " "4.9.2" ")" "\n" | - |
| 316 | "Copyright (C) 2016 The Qt Company Ltd.\n" | - |
| 317 | "Contact: http://www.qt.io/licensing/\n" | - |
| 318 | "\n" | - |
| 319 | "Installation prefix: %s\n" | - |
| 320 | "Library path: %s\n" | - |
| 321 | "Include path: %s\n", | - |
| 322 | qt_configure_prefix_path_str + 12, | - |
| 323 | qt_configure_strs + qt_configure_str_offsets[::QLibraryInfo::LibrariesPath - 1], | - |
| 324 | qt_configure_strs + qt_configure_str_offsets[::QLibraryInfo::HeadersPath - 1]); | - |
| 325 | - | |
| 326 | ::qDumpCPUFeatures(); | - |
| 327 | - | |
| 328 | - | |
| 329 | - | |
| 330 | - | |
| 331 | - | |
| 332 | - | |
| 333 | exit(0); | - |
| 334 | } | - |
| Switch to Source code | Preprocessed file |