diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2021-12-26 18:57:11 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2022-01-07 17:30:07 +0000 |
commit | b1d1e10d23862d1d38b34bfec0620cea0891e59c (patch) | |
tree | fac0592fef3fc5d709c56eb6d632000551c34c6b /src | |
parent | b8af6bee81f621c936030e914b600f454cde360e (diff) |
Fix detection of MSVC environment for cross-compilers
The MSVC profile has no mention of the host architecture, since it
contains only the target architecture.
Therefore, in the probe for the MSVC cross-compilers such as HostX64\x86,
HostX86\x64, only the target architecture is passed to determine their
build environment, which is incorrect.
We need to pass the combined cross-architecture as x86_x64, x64_x86 by
analogy as it is done in the qbs-setup-toolchains.
Fixes: QBS-1681
Change-Id: I549d8673cd6d4b0e46bf714355206b9efb2f5b1f
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/corelib/jsextensions/utilitiesextension.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp index 2dc87e980..53596bd1b 100644 --- a/src/lib/corelib/jsextensions/utilitiesextension.cpp +++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp @@ -465,6 +465,22 @@ QScriptValue UtilitiesExtension::js_signingIdentities(QScriptContext *context, } #ifdef Q_OS_WIN +// Try to detect the cross-architecture from the compiler path; prepend the host architecture +// if it is differ than the target architecture (e.g. something like x64_x86 and so forth). +static QString detectArchitecture(const QString &compilerFilePath, const QString &targetArch) +{ + const auto startIndex = compilerFilePath.lastIndexOf(QLatin1String("Host")); + if (startIndex == -1) + return targetArch; + const auto endIndex = compilerFilePath.indexOf(QLatin1Char('/'), startIndex); + if (endIndex == -1) + return targetArch; + const auto hostArch = compilerFilePath.mid(startIndex + 4, endIndex - startIndex - 4).toLower(); + if (hostArch.isEmpty() || (hostArch == targetArch)) + return targetArch; + return hostArch + QLatin1Char('_') + targetArch; +} + static std::pair<QVariantMap /*result*/, QString /*error*/> msvcCompilerInfoHelper( const QString &compilerFilePath, MSVC::CompilerLanguage language, @@ -472,7 +488,8 @@ static std::pair<QVariantMap /*result*/, QString /*error*/> msvcCompilerInfoHelp const QString &arch, const QString &sdkVersion) { - MSVC msvc(compilerFilePath, arch, sdkVersion); + QString detailedArch = detectArchitecture(compilerFilePath, arch); + MSVC msvc(compilerFilePath, std::move(detailedArch), sdkVersion); VsEnvironmentDetector envdetector(vcvarsallPath); if (!envdetector.start(&msvc)) return { {}, QStringLiteral("Detecting the MSVC build environment failed: ") |