diff options
author | Richard Weickelt <richard@weickelt.de> | 2020-04-15 22:37:21 +0200 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2020-04-15 22:37:51 +0200 |
commit | 99d009c0ae5558d86159206e7a27d4ed7e8ade28 (patch) | |
tree | 31a6917ba50c52c5987f4cec29be24dce2152565 /src | |
parent | 7d9c004b9692ee681f4778a1062e40ee1211f7e5 (diff) | |
parent | 846fc574f38395af24a9e60726372cb56075cff4 (diff) |
Merge branch '1.16' into master
Change-Id: Ie3f341fe18e2ffaf676721748279c6b027590727
Diffstat (limited to 'src')
-rw-r--r-- | src/app/qbs-setup-toolchains/gccprobe.cpp | 2 | ||||
-rw-r--r-- | src/app/qbs-setup-toolchains/sdccprobe.cpp | 27 | ||||
-rw-r--r-- | src/app/qbs/stdinreader.cpp | 30 | ||||
-rw-r--r-- | src/lib/corelib/language/artifactproperties.cpp | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/language.cpp | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/modulemerger.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/tools/hostosinfo.h | 7 | ||||
-rw-r--r-- | src/lib/corelib/tools/id.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/tools/jsonhelper.h | 6 |
9 files changed, 67 insertions, 17 deletions
diff --git a/src/app/qbs-setup-toolchains/gccprobe.cpp b/src/app/qbs-setup-toolchains/gccprobe.cpp index df3f92f62..6cbe246a5 100644 --- a/src/app/qbs-setup-toolchains/gccprobe.cpp +++ b/src/app/qbs-setup-toolchains/gccprobe.cpp @@ -111,7 +111,7 @@ class ToolchainDetails public: explicit ToolchainDetails(const QFileInfo &compiler) { - auto baseName = compiler.completeBaseName(); + auto baseName = HostOsInfo::stripExecutableSuffix(compiler.fileName()); // Extract the version sub-string if it exists. We assume that a version // sub-string located after the compiler prefix && suffix. E.g. this code // parses a version from the compiler names, like this: diff --git a/src/app/qbs-setup-toolchains/sdccprobe.cpp b/src/app/qbs-setup-toolchains/sdccprobe.cpp index 3eb37cfd3..977d834c4 100644 --- a/src/app/qbs-setup-toolchains/sdccprobe.cpp +++ b/src/app/qbs-setup-toolchains/sdccprobe.cpp @@ -151,6 +151,21 @@ static std::vector<Profile> createSdccProfileHelper( return profiles; } +static Version dumpOldSddcCompilerVersion(const QByteArray ¯oDump) +{ + const auto keyToken = QByteArrayLiteral("__SDCC "); + const int startIndex = macroDump.indexOf(keyToken); + if (startIndex == -1) + return Version{}; + const int endIndex = macroDump.indexOf('\n', startIndex); + if (endIndex == -1) + return Version{}; + const auto keyLength = keyToken.length(); + return Version::fromString(QString::fromLatin1( + macroDump.mid(startIndex + keyLength, + endIndex - startIndex - keyLength).replace('_', '.'))); +} + static Version dumpSdccCompilerVersion(const QFileInfo &compiler) { const QByteArray dump = dumpSdccMacros(compiler); @@ -161,10 +176,14 @@ static Version dumpSdccCompilerVersion(const QFileInfo &compiler) const int minor = extractVersion(dump, "__SDCC_VERSION_MINOR "); const int patch = extractVersion(dump, "__SDCC_VERSION_PATCH "); if (major < 0 || minor < 0 || patch < 0) { - qbsWarning() << Tr::tr("No '__SDCC_VERSION_xxx' token was found " - "in the compiler dump:\n%1") - .arg(QString::fromUtf8(dump)); - return Version{}; + const auto version = dumpOldSddcCompilerVersion(dump); + if (!version.isValid()) { + qbsWarning() << Tr::tr("No '__SDCC_VERSION_xxx' or '__SDCC' token was found " + "in the compiler dump:\n%1") + .arg(QString::fromUtf8(dump)); + return Version{}; + } + return version; } return Version{major, minor, patch}; diff --git a/src/app/qbs/stdinreader.cpp b/src/app/qbs/stdinreader.cpp index b90abf9d1..5f00d7de4 100644 --- a/src/app/qbs/stdinreader.cpp +++ b/src/app/qbs/stdinreader.cpp @@ -43,13 +43,13 @@ #include <QtCore/qfile.h> #include <QtCore/qsocketnotifier.h> +#include <QtCore/qtimer.h> #include <cerrno> #include <cstring> #ifdef Q_OS_WIN32 #include <qt_windows.h> -#include <QtCore/qtimer.h> #else #include <fcntl.h> #endif @@ -87,6 +87,18 @@ private: connect(&m_notifier, &QSocketNotifier::activated, this, [this] { emit dataAvailable(m_stdIn.readAll()); }); + + // Neither the aboutToClose() nor the readChannelFinished() signals + // are triggering, so we need a timer to check whether the controlling + // process disappeared. + const auto stdinClosedChecker = new QTimer(this); + connect(stdinClosedChecker, &QTimer::timeout, this, [this, stdinClosedChecker] { + if (m_stdIn.atEnd()) { + stdinClosedChecker->stop(); + emit errorOccurred(tr("Input channel closed unexpectedly.")); + } + }); + stdinClosedChecker->start(1000); } QFile m_stdIn; @@ -112,14 +124,22 @@ private: // (how would we abort that one?), but ideally we'd like // to have a signal-based approach like in the Unix variant. const auto timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [this] { + connect(timer, &QTimer::timeout, this, [this, timer] { char buf[1024]; DWORD bytesAvail; - PeekNamedPipe(m_stdinHandle, nullptr, 0, nullptr, &bytesAvail, nullptr); + if (!PeekNamedPipe(m_stdinHandle, nullptr, 0, nullptr, &bytesAvail, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } while (bytesAvail > 0) { DWORD bytesRead; - ReadFile(m_stdinHandle, buf, std::min<DWORD>(bytesAvail, sizeof buf), &bytesRead, - nullptr); + if (!ReadFile(m_stdinHandle, buf, std::min<DWORD>(bytesAvail, sizeof buf), + &bytesRead, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } emit dataAvailable(QByteArray(buf, bytesRead)); bytesAvail -= bytesRead; } diff --git a/src/lib/corelib/language/artifactproperties.cpp b/src/lib/corelib/language/artifactproperties.cpp index e5b11f4d7..011e58d88 100644 --- a/src/lib/corelib/language/artifactproperties.cpp +++ b/src/lib/corelib/language/artifactproperties.cpp @@ -64,6 +64,7 @@ bool operator==(const ArtifactProperties &ap1, const ArtifactProperties &ap2) { return ap1.fileTagsFilter() == ap2.fileTagsFilter() && ap1.extraFileTags() == ap2.extraFileTags() + && !ap1.propertyMap() == !ap2.propertyMap() && *ap1.propertyMap() == *ap2.propertyMap(); } diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index 7eec99947..3b3e7401e 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -857,6 +857,7 @@ bool operator==(const SourceArtifactInternal &sa1, const SourceArtifactInternal && sa1.fileTags == sa2.fileTags && sa1.overrideFileTags == sa2.overrideFileTags && sa1.targetOfModule == sa2.targetOfModule + && !sa1.properties == !sa2.properties && *sa1.properties == *sa2.properties; } diff --git a/src/lib/corelib/language/modulemerger.cpp b/src/lib/corelib/language/modulemerger.cpp index 5a5bd3ac0..c5deaae04 100644 --- a/src/lib/corelib/language/modulemerger.cpp +++ b/src/lib/corelib/language/modulemerger.cpp @@ -173,7 +173,9 @@ void ModuleMerger::mergeModule(Item::PropertyMap *dstProps, const Item::Module & if (dstVal) { if (srcDecl.isScalar()) { // Scalar properties get replaced. - if (dstVal->type() == Value::JSSourceValueType) { + if ((dstVal->type() == Value::JSSourceValueType) + && (srcVal->type() == Value::JSSourceValueType)) { + // Warn only about conflicting source code values const JSSourceValuePtr dstJsVal = std::static_pointer_cast<JSSourceValue>(dstVal); const JSSourceValuePtr srcJsVal = diff --git a/src/lib/corelib/tools/hostosinfo.h b/src/lib/corelib/tools/hostosinfo.h index 42ce3f8cf..0876d39ec 100644 --- a/src/lib/corelib/tools/hostosinfo.h +++ b/src/lib/corelib/tools/hostosinfo.h @@ -112,6 +112,13 @@ public: return finalName; } + static QString stripExecutableSuffix(const QString &executable) + { + constexpr QLatin1String suffix(QBS_HOST_EXE_SUFFIX, sizeof(QBS_HOST_EXE_SUFFIX) - 1); + return !suffix.isEmpty() && executable.endsWith(suffix) + ? executable.chopped(suffix.size()) : executable; + } + static QString dynamicLibraryName(const QString &libraryBaseName) { return QLatin1String(QBS_HOST_DYNAMICLIB_PREFIX) + libraryBaseName diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp index 6dd1147f2..33cfd60f7 100644 --- a/src/lib/corelib/tools/id.cpp +++ b/src/lib/corelib/tools/id.cpp @@ -269,9 +269,9 @@ Id Id::withPrefix(const char *prefix) const bool Id::operator==(const char *name) const { - const char *string = getStringFromId(m_id); - if (string && name) - return strcmp(string, name) == 0; + const auto string = getStringFromId(m_id); + if (!string.isNull() && name) + return strcmp(string.data(), name) == 0; else return false; } diff --git a/src/lib/corelib/tools/jsonhelper.h b/src/lib/corelib/tools/jsonhelper.h index d87802c0a..991d6bd6c 100644 --- a/src/lib/corelib/tools/jsonhelper.h +++ b/src/lib/corelib/tools/jsonhelper.h @@ -78,9 +78,9 @@ template<> inline QProcessEnvironment fromJson(const QJsonValue &v) template<typename T> inline void setValueFromJson(T &targetValue, const QJsonObject &data, const char *jsonProperty) { - const QJsonValue v = data.value(QLatin1String(jsonProperty)); - if (!v.isNull()) - targetValue = fromJson<T>(v); + const auto it = data.find(QLatin1String(jsonProperty)); + if (it != data.end()) + targetValue = fromJson<T>(*it); } } // namespace Internal |