Commit 49ae9766 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QbsProjectManager: Make DefaultPropertyProvider a bit more readable.



- Decrease indentation by exiting early.
- Use switch instead of "else if".

Change-Id: I74e73e087f64c16f01497854c67f581ef79aff3c
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent 869445b7
...@@ -67,113 +67,120 @@ QVariantMap DefaultPropertyProvider::properties(const ProjectExplorer::Kit *k, c ...@@ -67,113 +67,120 @@ QVariantMap DefaultPropertyProvider::properties(const ProjectExplorer::Kit *k, c
data.insert(QLatin1String(QBS_SYSROOT), sysroot); data.insert(QLatin1String(QBS_SYSROOT), sysroot);
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (tc) { if (!tc)
// FIXME/CLARIFY: How to pass the sysroot? return data;
ProjectExplorer::Abi targetAbi = tc->targetAbi();
if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) { // FIXME/CLARIFY: How to pass the sysroot?
QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture()); ProjectExplorer::Abi targetAbi = tc->targetAbi();
if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) {
// We have to be conservative tacking on suffixes to arch names because an arch that is QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture());
// already 64-bit may get an incorrect name as a result (i.e. Itanium)
if (targetAbi.wordWidth() == 64) { // We have to be conservative tacking on suffixes to arch names because an arch that is
switch (targetAbi.architecture()) { // already 64-bit may get an incorrect name as a result (i.e. Itanium)
case ProjectExplorer::Abi::X86Architecture: if (targetAbi.wordWidth() == 64) {
architecture.append(QLatin1String("_")); switch (targetAbi.architecture()) {
// fall through case ProjectExplorer::Abi::X86Architecture:
case ProjectExplorer::Abi::ArmArchitecture: architecture.append(QLatin1String("_"));
case ProjectExplorer::Abi::MipsArchitecture: // fall through
case ProjectExplorer::Abi::PowerPCArchitecture: case ProjectExplorer::Abi::ArmArchitecture:
architecture.append(QString::number(targetAbi.wordWidth())); case ProjectExplorer::Abi::MipsArchitecture:
break; case ProjectExplorer::Abi::PowerPCArchitecture:
default: architecture.append(QString::number(targetAbi.wordWidth()));
break; break;
} default:
break;
} }
}
data.insert(QLatin1String(QBS_ARCHITECTURE),
qbs::Internal::HostOsInfo::canonicalArchitecture(architecture));
}
data.insert(QLatin1String(QBS_ARCHITECTURE), switch (targetAbi.os()) {
qbs::Internal::HostOsInfo::canonicalArchitecture(architecture)); case ProjectExplorer::Abi::WindowsOS:
data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("windows"));
data.insert(QLatin1String(QBS_TOOLCHAIN),
targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor
? QStringList() << QLatin1String("mingw") << QLatin1String("gcc")
: QStringList() << QLatin1String("msvc"));
break;
case ProjectExplorer::Abi::MacOS: {
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // from Ios::Constants (include header?)
const char IOS_SIMULATOR_TYPE[] = "Ios.Simulator.Type";
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitInformation::qtVersion(k);
QStringList targetOS;
targetOS << QLatin1String("darwin") << QLatin1String("bsd4")
<< QLatin1String("bsd") << QLatin1String("unix");
if (qt && qt->type() == QLatin1String(IOSQT)) {
targetOS.insert(0, QLatin1String("ios"));
if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k) == IOS_SIMULATOR_TYPE)
targetOS.insert(0, QLatin1String("ios-simulator"));
} else {
targetOS.insert(0, QLatin1String("osx"));
} }
data.insert(QLatin1String(QBS_TARGETOS), targetOS);
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("windows")); data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN), data.insert(QLatin1String(QBS_TOOLCHAIN),
targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor QStringList() << QLatin1String("clang")
? QStringList() << QLatin1String("mingw") << QLatin1String("gcc") << QLatin1String("llvm")
: QStringList() << QLatin1String("msvc")); << QLatin1String("gcc"));
} else if (targetAbi.os() == ProjectExplorer::Abi::MacOS) { }
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // from Ios::Constants (include header?)
const char IOS_SIMULATOR_TYPE[] = "Ios.Simulator.Type";
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitInformation::qtVersion(k);
QStringList targetOS;
targetOS << QLatin1String("darwin") << QLatin1String("bsd4")
<< QLatin1String("bsd") << QLatin1String("unix");
if (qt && qt->type() == QLatin1String(IOSQT)) {
targetOS.insert(0, QLatin1String("ios"));
if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k) == IOS_SIMULATOR_TYPE)
targetOS.insert(0, QLatin1String("ios-simulator"));
} else {
targetOS.insert(0, QLatin1String("osx"));
}
data.insert(QLatin1String(QBS_TARGETOS), targetOS);
if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN),
QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
}
// Set Xcode SDK name and version - required by Qbs if a sysroot is present // Set Xcode SDK name and version - required by Qbs if a sysroot is present
// Ideally this would be done in a better way... // Ideally this would be done in a better way...
QRegExp re(QLatin1String("(MacOSX|iPhoneOS|iPhoneSimulator)([0-9]+\\.[0-9]+)\\.sdk")); QRegExp re(QLatin1String("(MacOSX|iPhoneOS|iPhoneSimulator)([0-9]+\\.[0-9]+)\\.sdk"));
if (re.exactMatch(QDir(sysroot).dirName())) { if (re.exactMatch(QDir(sysroot).dirName())) {
data.insert(QLatin1String(CPP_XCODESDKNAME), QString(re.cap(1).toLower() + re.cap(2))); data.insert(QLatin1String(CPP_XCODESDKNAME), QString(re.cap(1).toLower() + re.cap(2)));
data.insert(QLatin1String(CPP_XCODESDKVERSION), re.cap(2)); data.insert(QLatin1String(CPP_XCODESDKVERSION), re.cap(2));
}
} else if (targetAbi.os() == ProjectExplorer::Abi::LinuxOS) {
data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("linux")
<< QLatin1String("unix"));
if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN),
QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
}
} else {
// TODO: Factor out toolchain type setting.
data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("unix"));
if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN),
QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
}
} }
Utils::FileName cxx = tc->compilerCommand(); break;
const QFileInfo cxxFileInfo = cxx.toFileInfo(); }
QString compilerName = cxxFileInfo.fileName(); case ProjectExplorer::Abi::LinuxOS:
const QString toolchainPrefix = extractToolchainPrefix(&compilerName); data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("linux")
if (!toolchainPrefix.isEmpty()) << QLatin1String("unix"));
data.insert(QLatin1String(CPP_TOOLCHAINPREFIX), toolchainPrefix); if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(CPP_COMPILERNAME), compilerName); data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
if (targetAbi.os() != ProjectExplorer::Abi::WindowsOS } else {
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { data.insert(QLatin1String(QBS_TOOLCHAIN),
data.insert(QLatin1String(CPP_LINKERNAME), compilerName); QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
} }
data.insert(QLatin1String(CPP_TOOLCHAINPATH), cxxFileInfo.absolutePath()); break;
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2013Flavor) { default:
const QLatin1String flags("/FS"); // TODO: Factor out toolchain type setting.
data.insert(QLatin1String(CPP_PLATFORMCFLAGS), flags); data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("unix"));
data.insert(QLatin1String(CPP_PLATFORMCXXFLAGS), flags); if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN),
QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
} }
} }
Utils::FileName cxx = tc->compilerCommand();
const QFileInfo cxxFileInfo = cxx.toFileInfo();
QString compilerName = cxxFileInfo.fileName();
const QString toolchainPrefix = extractToolchainPrefix(&compilerName);
if (!toolchainPrefix.isEmpty())
data.insert(QLatin1String(CPP_TOOLCHAINPREFIX), toolchainPrefix);
data.insert(QLatin1String(CPP_COMPILERNAME), compilerName);
if (targetAbi.os() != ProjectExplorer::Abi::WindowsOS
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
data.insert(QLatin1String(CPP_LINKERNAME), compilerName);
}
data.insert(QLatin1String(CPP_TOOLCHAINPATH), cxxFileInfo.absolutePath());
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2013Flavor) {
const QLatin1String flags("/FS");
data.insert(QLatin1String(CPP_PLATFORMCFLAGS), flags);
data.insert(QLatin1String(CPP_PLATFORMCXXFLAGS), flags);
}
return data; return data;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment