aboutsummaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2014-03-02 04:34:58 -0500
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-03-12 15:46:06 +0100
commitd996dc6b08232c8e7e137f9259c447302737c581 (patch)
treeb4a391f817ef5c3e9639a4b10d79eb61987b6eb7 /src/app
parent8ee37bfaed662dcae521c4c901ea91aec3258547 (diff)
Combine createGccProfile and createMingwProfile.
They were substantially similar. Change-Id: I2ec29d7eb1691b3c2d8de7075843b88773c7cb63 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/qbs-setup-toolchains/probe.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/app/qbs-setup-toolchains/probe.cpp b/src/app/qbs-setup-toolchains/probe.cpp
index ac598b393..63793dc63 100644
--- a/src/app/qbs-setup-toolchains/probe.cpp
+++ b/src/app/qbs-setup-toolchains/probe.cpp
@@ -150,37 +150,29 @@ static void setCommonProperties(Profile &profile, const QString &compilerFilePat
HostOsInfo::defaultEndianness(architecture));
}
-static Profile createMingwProfile(const QString &_compilerFilePath, Settings *settings,
- const QString &profileName = QString())
+static Profile createGccProfile(const QString &_compilerFilePath, Settings *settings,
+ const QStringList &toolchainTypes,
+ const QString &profileName = QString())
{
const QString compilerFilePath = actualCompilerFilePath(_compilerFilePath);
const QString machineName = gccMachineName(compilerFilePath);
const QStringList compilerTriplet = machineName.split(QLatin1Char('-'));
- if (!validMinGWMachines().contains(machineName)) {
+ const bool isMingw = toolchainTypes.contains(QLatin1String("mingw"));
+
+ if (isMingw && !validMinGWMachines().contains(machineName)) {
throw qbs::ErrorInfo(Tr::tr("Detected gcc platform '%1' is not supported.")
.arg(machineName));
+ } else if (compilerTriplet.count() < 2) {
+ throw qbs::ErrorInfo(Tr::tr("Architecture '%1' of compiler at '%1' not understood.")
+ .arg(compilerFilePath, machineName));
}
+
Profile profile(!profileName.isEmpty() ? profileName : machineName, settings);
profile.removeProfile();
- profile.setValue(QLatin1String("qbs.targetOS"), QStringList(QLatin1String("windows")));
- setCommonProperties(profile, compilerFilePath, completeToolchainList(QLatin1String("mingw")),
- compilerTriplet.first());
- qStdout << Tr::tr("Profile '%1' created for '%2'.").arg(profile.name(), compilerFilePath)
- << endl;
- return profile;
-}
-
-static Profile createGccProfile(const QString &_compilerFilePath, Settings *settings,
- const QStringList &toolchainTypes, const QString &profileName)
-{
- const QString compilerFilePath = actualCompilerFilePath(_compilerFilePath);
- const QString machineName = gccMachineName(compilerFilePath);
- const QStringList compilerTriplet = machineName.split(QLatin1Char('-'));
- if (compilerTriplet.count() < 2) {
- throw qbs::ErrorInfo(Tr::tr("Architecture '%1' of compiler at '%1' not understood.")
- .arg(compilerFilePath, machineName));
+ if (isMingw) {
+ profile.setValue(QLatin1String("qbs.targetOS"), QStringList(QLatin1String("windows")));
}
- Profile profile(profileName, settings);
+
setCommonProperties(profile, compilerFilePath, toolchainTypes, compilerTriplet.first());
const QString compilerName = QFileInfo(compilerFilePath).fileName();
if (compilerName.contains(QLatin1Char('-'))) {
@@ -225,7 +217,8 @@ static void mingwProbe(Settings *settings, QList<Profile> &profiles)
const QString gccPath
= findExecutable(HostOsInfo::appendExecutableSuffix(compilerName));
if (!gccPath.isEmpty())
- profiles << createMingwProfile(gccPath, settings);
+ profiles << createGccProfile(gccPath, settings,
+ completeToolchainList(QLatin1String("mingw")));
}
}
@@ -268,9 +261,7 @@ void createProfile(const QString &profileName, const QString &toolchainType,
"via the auto-detection mechanism."));
}
- if (toolchainTypes.contains(QLatin1String("mingw")))
- createMingwProfile(compilerFilePath, settings, profileName);
- else if (toolchainTypes.contains(QLatin1String("gcc")))
+ if (toolchainTypes.contains(QLatin1String("gcc")))
createGccProfile(compilerFilePath, settings, toolchainTypes, profileName);
else
throw qbs::ErrorInfo(Tr::tr("Cannot create profile: Unknown toolchain type."));