diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-12-13 13:51:25 +0300 |
---|---|---|
committer | Ivan Komissarov <abbapoh@gmail.com> | 2021-12-13 13:51:25 +0300 |
commit | 119d6195adcd1bceb6eabb59062d54b639ca22a7 (patch) | |
tree | 40db0335c122bd41205d0399a3a87091e56d8ccd /src | |
parent | 8538cb992043eb680c1b7acaf133e4147e1db86a (diff) | |
parent | 137e1f968935a583a18c6a9c567ad043aff91360 (diff) | |
download | qbs-119d6195adcd1bceb6eabb59062d54b639ca22a7.tar.gz |
Merge branch '1.21' into master
Change-Id: Ia540ffdfbcb1e51146dba53337defd09ded66f1a
Diffstat (limited to 'src')
26 files changed, 104 insertions, 32 deletions
diff --git a/src/lib/corelib/CMakeLists.txt b/src/lib/corelib/CMakeLists.txt index d4b2d8d38..3a658db98 100644 --- a/src/lib/corelib/CMakeLists.txt +++ b/src/lib/corelib/CMakeLists.txt @@ -334,6 +334,7 @@ set(TOOLS_SOURCES pathutils.h persistence.cpp persistence.h + porting.h preferences.cpp processresult.cpp processresult_p.h diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h index 380806f3a..7ea7645a7 100644 --- a/src/lib/corelib/api/project.h +++ b/src/lib/corelib/api/project.h @@ -43,6 +43,7 @@ #include "transformerdata.h" #include "../language/forward_decls.h" #include "../tools/error.h" +#include "../tools/porting.h" #include "../tools/qbs_export.h" #include <QtCore/qshareddata.h> @@ -83,7 +84,7 @@ class ProjectPrivate; class QBS_EXPORT Project { friend class SetupProjectJob; - friend uint qHash(const Project &p); + friend QHashValueType qHash(const Project &p); public: SetupProjectJob *setupProject(const SetupProjectParameters ¶meters, ILogSink *logSink, QObject *jobOwner); @@ -173,7 +174,7 @@ private: }; inline bool operator!=(const Project &p1, const Project &p2) { return !(p1 == p2); } -inline uint qHash(const Project &p) { return QT_PREPEND_NAMESPACE(qHash)(p.d.data()); } +inline QHashValueType qHash(const Project &p) { return QT_PREPEND_NAMESPACE(qHash)(p.d.data()); } } // namespace qbs diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs index 6656d638b..b50b1e18b 100644 --- a/src/lib/corelib/corelib.qbs +++ b/src/lib/corelib/corelib.qbs @@ -438,6 +438,7 @@ QbsLibrary { "pathutils.h", "persistence.cpp", "persistence.h", + "porting.h", "preferences.cpp", "processresult.cpp", "processresult_p.h", diff --git a/src/lib/corelib/generators/generatorversioninfo.h b/src/lib/corelib/generators/generatorversioninfo.h index 38616eb98..5c867326f 100644 --- a/src/lib/corelib/generators/generatorversioninfo.h +++ b/src/lib/corelib/generators/generatorversioninfo.h @@ -74,7 +74,7 @@ private: utils::ArchitectureFlags m_archs; }; -inline quint32 qHash(const VersionInfo &info) +inline auto qHash(const VersionInfo &info) { return qHash(info.version().toString()); } diff --git a/src/lib/corelib/language/forward_decls.h b/src/lib/corelib/language/forward_decls.h index 6697ac8c9..6ee22a5a6 100644 --- a/src/lib/corelib/language/forward_decls.h +++ b/src/lib/corelib/language/forward_decls.h @@ -142,12 +142,14 @@ class PersistentPool; } // namespace qbs #ifdef QT_CORE_LIB +#include "../tools/porting.h" + #include <QtCore/qhash.h> namespace qbs { namespace Internal { -template <typename T> inline static uint qHash(const std::shared_ptr<T> &p, uint seed = 0) +template <typename T> inline static QHashValueType qHash(const std::shared_ptr<T> &p, QHashValueType seed = 0) { return ::qHash(p.get(), seed); } diff --git a/src/lib/corelib/language/itemtype.h b/src/lib/corelib/language/itemtype.h index 724666cb4..465396f45 100644 --- a/src/lib/corelib/language/itemtype.h +++ b/src/lib/corelib/language/itemtype.h @@ -82,7 +82,7 @@ enum class ItemType { Unknown }; -inline uint qHash(ItemType t) { return QT_PREPEND_NAMESPACE(qHash)(uint(t)); } +inline auto qHash(ItemType t) { return QT_PREPEND_NAMESPACE(qHash)(uint(t)); } } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/language/jsimports.h b/src/lib/corelib/language/jsimports.h index a892e0ec0..a4a045f2b 100644 --- a/src/lib/corelib/language/jsimports.h +++ b/src/lib/corelib/language/jsimports.h @@ -71,7 +71,7 @@ public: pool.serializationOp<opType>(scopeName, filePaths, location); } }; -inline uint qHash(const JsImport &jsi) { return qHash(jsi.scopeName); } +inline auto qHash(const JsImport &jsi) { return qHash(jsi.scopeName); } inline bool operator<(const JsImport &lhs, const JsImport &rhs) { diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index c7b2095fa..3db41b8c8 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -904,7 +904,7 @@ bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2 return b1.code == b2.code && b1.name == b2.name; } -uint qHash(const RuleArtifact::Binding &b) +QHashValueType qHash(const RuleArtifact::Binding &b) { return qHash(std::make_pair(b.code, b.name.join(QLatin1Char(',')))); } diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h index e50691560..146f00f89 100644 --- a/src/lib/corelib/language/language.h +++ b/src/lib/corelib/language/language.h @@ -52,6 +52,7 @@ #include <tools/filetime.h> #include <tools/joblimits.h> #include <tools/persistence.h> +#include <tools/porting.h> #include <tools/set.h> #include <tools/weakpointer.h> @@ -212,7 +213,7 @@ private: : alwaysUpdated(true) {} }; -uint qHash(const RuleArtifact::Binding &b); +QHashValueType qHash(const RuleArtifact::Binding &b); bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2); inline bool operator!=(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2) { return !(b1 == b2); diff --git a/src/lib/corelib/language/property.h b/src/lib/corelib/language/property.h index 78061bf6f..302973d19 100644 --- a/src/lib/corelib/language/property.h +++ b/src/lib/corelib/language/property.h @@ -94,7 +94,7 @@ inline bool operator==(const Property &p1, const Property &p2) } bool operator<(const Property &p1, const Property &p2); -inline uint qHash(const Property &p) +inline auto qHash(const Property &p) { return QT_PREPEND_NAMESPACE(qHash)(p.productName + p.moduleName + p.propertyName); } diff --git a/src/lib/corelib/language/qualifiedid.h b/src/lib/corelib/language/qualifiedid.h index 2b4c9d286..7e8b388d3 100644 --- a/src/lib/corelib/language/qualifiedid.h +++ b/src/lib/corelib/language/qualifiedid.h @@ -60,7 +60,7 @@ public: QString toString() const; }; -inline uint qHash(const QualifiedId &qid) { return qHash(qid.toString()); } +inline auto qHash(const QualifiedId &qid) { return qHash(qid.toString()); } using QualifiedIdSet = Set<QualifiedId>; diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp index 1533bd210..8d2c6a2c5 100644 --- a/src/lib/corelib/language/scriptengine.cpp +++ b/src/lib/corelib/language/scriptengine.cpp @@ -85,13 +85,15 @@ bool operator==(const ScriptEngine::PropertyCacheKey &lhs, && lhs.m_propertyName == rhs.m_propertyName; } -static inline uint combineHash(uint h1, uint h2, uint seed) + + +static inline QHashValueType combineHash(QHashValueType h1, QHashValueType h2, QHashValueType seed) { // stolen from qHash(QPair) return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed; } -uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed = 0) +QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed = 0) { return combineHash(qHash(k.m_moduleName), combineHash(qHash(k.m_propertyName), qHash(k.m_propertyMap), seed), seed); diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h index 2c8aca241..68e346b68 100644 --- a/src/lib/corelib/language/scriptengine.h +++ b/src/lib/corelib/language/scriptengine.h @@ -47,6 +47,7 @@ #include <logging/logger.h> #include <tools/codelocation.h> #include <tools/filetime.h> +#include <tools/porting.h> #include <tools/set.h> #include <QtCore/qdir.h> @@ -313,11 +314,11 @@ private: const PropertyMapConstPtr m_propertyMap; friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs); - friend uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed); + friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed); }; friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs); - friend uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed); + friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed); static std::mutex m_creationDestructionMutex; ScriptImporter *m_scriptImporter; diff --git a/src/lib/corelib/tools/codelocation.h b/src/lib/corelib/tools/codelocation.h index 3e84ce2d1..158b90766 100644 --- a/src/lib/corelib/tools/codelocation.h +++ b/src/lib/corelib/tools/codelocation.h @@ -85,7 +85,7 @@ QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2); QBS_EXPORT bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2); QBS_EXPORT bool operator<(const CodeLocation &cl1, const CodeLocation &cl2); -inline uint qHash(const CodeLocation &cl) { return qHash(cl.toString()); } +inline auto qHash(const CodeLocation &cl) { return qHash(cl.toString()); } QDebug operator<<(QDebug debug, const CodeLocation &location); diff --git a/src/lib/corelib/tools/error.h b/src/lib/corelib/tools/error.h index ea8ddb5ec..4c6370b1e 100644 --- a/src/lib/corelib/tools/error.h +++ b/src/lib/corelib/tools/error.h @@ -126,7 +126,7 @@ void appendError(ErrorInfo &dst, const ErrorInfo &src); void handlePropertyError( const ErrorInfo &error, const SetupProjectParameters ¶ms, Internal::Logger &logger); -inline uint qHash(const ErrorInfo &e) { return qHash(e.toString()); } +inline auto qHash(const ErrorInfo &e) { return qHash(e.toString()); } inline bool operator==(const ErrorInfo &e1, const ErrorInfo &e2) { return e1.toString() == e2.toString(); } diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp index b4c791f75..cca755512 100644 --- a/src/lib/corelib/tools/id.cpp +++ b/src/lib/corelib/tools/id.cpp @@ -75,7 +75,7 @@ public: : n(length), str(s) { if (!n) - length = n = qstrlen(s); + length = n = int(qstrlen(s)); h = 0; while (length--) { h = (h << 4) + *s++; @@ -95,7 +95,7 @@ static bool operator==(const StringHolder &sh1, const StringHolder &sh2) } -static uint qHash(const StringHolder &sh) +QHashValueType qHash(const StringHolder &sh) { return sh.h; } diff --git a/src/lib/corelib/tools/id.h b/src/lib/corelib/tools/id.h index aa327833f..845ed60df 100644 --- a/src/lib/corelib/tools/id.h +++ b/src/lib/corelib/tools/id.h @@ -41,6 +41,7 @@ #define QBS_TOOLS_ID_H #include "qbs_export.h" +#include <tools/porting.h> #include <QtCore/qmetatype.h> #include <QtCore/qstring.h> @@ -84,7 +85,7 @@ private: int m_id; }; -inline uint qHash(const Id &id) { return id.uniqueIdentifier(); } +inline QHashValueType qHash(const Id &id) { return id.uniqueIdentifier(); } } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/tools/porting.h b/src/lib/corelib/tools/porting.h new file mode 100644 index 000000000..37582e8d3 --- /dev/null +++ b/src/lib/corelib/tools/porting.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TOOLS_PORTING_H +#define QBS_TOOLS_PORTING_H + +#include <QtCore/qglobal.h> + +namespace qbs { + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +using QHashValueType = uint; +#else +using QHashValueType = size_t; +#endif + +} + +#endif diff --git a/src/lib/corelib/tools/qttools.cpp b/src/lib/corelib/tools/qttools.cpp index c2ef91f16..40e0d0778 100644 --- a/src/lib/corelib/tools/qttools.cpp +++ b/src/lib/corelib/tools/qttools.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qttools.h" +#include "porting.h" #include <QtCore/qprocess.h> @@ -64,15 +65,15 @@ size_t hash<QVariant>::operator()(const QVariant &v) const noexcept QT_BEGIN_NAMESPACE -uint qHash(const QStringList &list) +qbs::QHashValueType qHash(const QStringList &list) { - uint s = 0; + qbs::QHashValueType s = 0; for (const QString &n : list) s ^= qHash(n) + 0x9e3779b9 + (s << 6) + (s >> 2); return s; } -uint qHash(const QProcessEnvironment &env) +qbs::QHashValueType qHash(const QProcessEnvironment &env) { return qHash(env.toStringList()); } diff --git a/src/lib/corelib/tools/qttools.h b/src/lib/corelib/tools/qttools.h index 86e81936b..bc1210d53 100644 --- a/src/lib/corelib/tools/qttools.h +++ b/src/lib/corelib/tools/qttools.h @@ -41,6 +41,7 @@ #define QBSQTTOOLS_H #include <tools/qbsassert.h> +#include <tools/porting.h> #include <tools/stlutils.h> #include <QtCore/qhash.h> @@ -136,26 +137,26 @@ template<> struct hash<QVariantHash> QT_BEGIN_NAMESPACE -uint qHash(const QStringList &list); -uint qHash(const QProcessEnvironment &env); +qbs::QHashValueType qHash(const QStringList &list); +qbs::QHashValueType qHash(const QProcessEnvironment &env); template<typename... Args> -uint qHash(const std::tuple<Args...> &tuple) +qbs::QHashValueType qHash(const std::tuple<Args...> &tuple) { return std::hash<std::tuple<Args...>>()(tuple) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariant &v) +inline qbs::QHashValueType qHash(const QVariant &v) { return std::hash<QVariant>()(v) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariantMap &v) +inline qbs::QHashValueType qHash(const QVariantMap &v) { return std::hash<QVariantMap>()(v) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariantHash &v) +inline qbs::QHashValueType qHash(const QVariantHash &v) { return std::hash<QVariantHash>()(v) % std::numeric_limits<uint>::max(); } diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri index 00d87ecc7..1fdacc016 100644 --- a/src/lib/corelib/tools/tools.pri +++ b/src/lib/corelib/tools/tools.pri @@ -30,6 +30,7 @@ HEADERS += \ $$PWD/launchersocket.h \ $$PWD/msvcinfo.h \ $$PWD/persistence.h \ + $$PWD/porting.h \ $$PWD/scannerpluginmanager.h \ $$PWD/scripttools.h \ $$PWD/set.h \ diff --git a/src/lib/corelib/tools/visualstudioversioninfo.cpp b/src/lib/corelib/tools/visualstudioversioninfo.cpp index b5ee3e719..1c51cc4b9 100644 --- a/src/lib/corelib/tools/visualstudioversioninfo.cpp +++ b/src/lib/corelib/tools/visualstudioversioninfo.cpp @@ -181,7 +181,7 @@ QString VisualStudioVersionInfo::platformToolsetVersion() const return QStringLiteral("v%1").arg(m_version.majorVersion() * 10); } -quint32 qHash(const VisualStudioVersionInfo &info) +QHashValueType qHash(const VisualStudioVersionInfo &info) { return qHash(info.version().toString()); } diff --git a/src/lib/corelib/tools/visualstudioversioninfo.h b/src/lib/corelib/tools/visualstudioversioninfo.h index d4b226623..92eecb388 100644 --- a/src/lib/corelib/tools/visualstudioversioninfo.h +++ b/src/lib/corelib/tools/visualstudioversioninfo.h @@ -43,6 +43,7 @@ #include "qbs_export.h" +#include <tools/porting.h> #include <tools/version.h> #include <QtCore/qstring.h> @@ -78,7 +79,7 @@ private: Version m_version; }; -quint32 qHash(const VisualStudioVersionInfo &info); +QHashValueType qHash(const VisualStudioVersionInfo &info); } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/use_corelib.pri b/src/lib/corelib/use_corelib.pri index a0bb90e8b..e1d74ca0d 100644 --- a/src/lib/corelib/use_corelib.pri +++ b/src/lib/corelib/use_corelib.pri @@ -1,5 +1,6 @@ include(../../../qbs_version.pri) include(../../library_dirname.pri) +include(../scriptengine/use_scriptengine.pri) isEmpty(QBSLIBDIR) { QBSLIBDIR = $$OUT_PWD/../../../$${QBS_LIBRARY_DIRNAME} diff --git a/src/lib/pkgconfig/use_pkgconfig.pri b/src/lib/pkgconfig/use_pkgconfig.pri index ad64cea6d..4620aec7f 100644 --- a/src/lib/pkgconfig/use_pkgconfig.pri +++ b/src/lib/pkgconfig/use_pkgconfig.pri @@ -29,7 +29,7 @@ win32 { LIBS += $${QBSPKGCONFIG_LIB} } -gcc { +gcc:!clang { isEmpty(COMPILER_VERSION) { COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion") COMPILER_MAJOR_VERSION = $$str_member($$COMPILER_VERSION) diff --git a/src/lib/scriptengine/use_scriptengine.pri b/src/lib/scriptengine/use_scriptengine.pri index ff1bb1343..9981b442a 100644 --- a/src/lib/scriptengine/use_scriptengine.pri +++ b/src/lib/scriptengine/use_scriptengine.pri @@ -1,4 +1,6 @@ -!qbs_do_not_link_bundled_qtscript { +include(../bundledlibs.pri) + +qbs_use_bundled_qtscript:!qbs_do_not_link_bundled_qtscript { include(../../library_dirname.pri) isEmpty(QBSLIBDIR) { QBSLIBDIR = $$shadowed($$PWD/../../../$${QBS_LIBRARY_DIRNAME}) |