diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 84905e8f174..9f77707a72b 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -145,6 +145,63 @@ static QStringList toolchainList(const ProjectExplorer::ToolChain *tc) return list; } +static QString architecture(const ProjectExplorer::Abi &targetAbi) +{ + if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) { + QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture()); + + // We have to be conservative tacking on suffixes to arch names because an arch that is + // already 64-bit may get an incorrect name as a result (i.e. Itanium) + if (targetAbi.wordWidth() == 64) { + switch (targetAbi.architecture()) { + case ProjectExplorer::Abi::X86Architecture: + architecture.append(QLatin1Char('_')); + // fall through + case ProjectExplorer::Abi::ArmArchitecture: + // ARM sub-architectures are currently not handled, which is kind of problematic + case ProjectExplorer::Abi::MipsArchitecture: + case ProjectExplorer::Abi::PowerPCArchitecture: + architecture.append(QString::number(targetAbi.wordWidth())); + break; + default: + break; + } + } + + return architecture; + } + + return QString(); +} + +static bool isMultiTargetingToolchain(const ProjectExplorer::ToolChain *tc) +{ + // Clang and QCC are multi-targeting compilers; others (GCC/MinGW, MSVC, ICC) are not + return tc->targetAbi().os() == ProjectExplorer::Abi::QnxOS + || tc->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID; +} + +static QStringList architectures(const ProjectExplorer::ToolChain *tc) +{ + // For platforms which can have builds for multiple architectures in a single configuration + // (Darwin, Android), regardless of whether the toolchain is multi-targeting or not (Clang + // always is, but Android GCC is not), let qbs automatically determine the list of architectures + // to build for by default. Similarly, if the underlying toolchain only targets a single + // architecture there's no reason to duplicate the detection logic here. + // Handles: GCC/MinGW, ICC, MSVC, Clang (Darwin, Android) + if (tc->targetAbi().os() == ProjectExplorer::Abi::DarwinOS + || tc->targetAbi().osFlavor() == ProjectExplorer::Abi::AndroidLinuxFlavor + || !isMultiTargetingToolchain(tc)) + return { }; + + // This attempts to use the preferred architecture for toolchains which are multi-targeting. + // Handles: Clang (Linux/UNIX), QCC + const auto arch = architecture(tc->targetAbi()); + if (!arch.isEmpty()) + return { arch }; + return { }; +} + QVariantMap DefaultPropertyProvider::properties(const ProjectExplorer::Kit *k, const QVariantMap &defaultData) const { @@ -191,32 +248,10 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor ProjectExplorer::ToolChain *mainTc = tcCxx ? tcCxx : tcC; ProjectExplorer::Abi targetAbi = mainTc->targetAbi(); - if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) { - QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture()); - - // We have to be conservative tacking on suffixes to arch names because an arch that is - // already 64-bit may get an incorrect name as a result (i.e. Itanium) - if (targetAbi.wordWidth() == 64) { - switch (targetAbi.architecture()) { - case ProjectExplorer::Abi::X86Architecture: - architecture.append(QLatin1Char('_')); - // fall through - case ProjectExplorer::Abi::ArmArchitecture: - case ProjectExplorer::Abi::MipsArchitecture: - case ProjectExplorer::Abi::PowerPCArchitecture: - architecture.append(QString::number(targetAbi.wordWidth())); - break; - default: - break; - } - } else if (targetAbi.architecture() == ProjectExplorer::Abi::ArmArchitecture && - targetAbi.os() == ProjectExplorer::Abi::DarwinOS) { - architecture.append(QLatin1String("v7")); - } - - data.insert(QLatin1String(QBS_ARCHITECTURE), qbs::canonicalArchitecture(architecture)); - } + auto archs = architectures(mainTc); + if (!archs.isEmpty()) + data.insert(QLatin1String(QBS_ARCHITECTURES), archs); data.insert(QLatin1String(QBS_TARGETOS), targetOSList(targetAbi, k)); QStringList toolchain = toolchainList(mainTc); diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h index 87831d436f6..e18767a2230 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h @@ -77,7 +77,7 @@ static const char QBS_PRODUCT_OVERLAY_ICON[] = ":/qbsprojectmanager/images/produ // Toolchain related settings: const char QBS_TARGETOS[] = "qbs.targetOS"; const char QBS_SYSROOT[] = "qbs.sysroot"; -const char QBS_ARCHITECTURE[] = "qbs.architecture"; +const char QBS_ARCHITECTURES[] = "qbs.architectures"; const char QBS_TOOLCHAIN[] = "qbs.toolchain"; const char CPP_TOOLCHAINPATH[] = "cpp.toolchainInstallPath"; const char CPP_TOOLCHAINPREFIX[] = "cpp.toolchainPrefix";