diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-07-07 12:21:41 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-07-07 18:47:09 +0200 |
commit | fc3e6c4872e9dd677a2d186440abcc7f1beb9e00 (patch) | |
tree | f02668ec63465e1ebdaaf147a8890bea03f2f2d3 /src/app/qbs-setup-toolchains | |
parent | 98f4637d3f7bea8c24c01ce085042b686b54cb57 (diff) |
setup-toolchains: detect location of ar and nm
Gcc's executables might be split among several directories. This is the
case when using e.g. an installed icecc. The toolchain's install path is
/usr/lib/icecc/bin but the archiver is in /usr/bin.
Task-number: QBS-528
Change-Id: I8f448b482bb00854a3144643e886634199d37012
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/app/qbs-setup-toolchains')
-rw-r--r-- | src/app/qbs-setup-toolchains/probe.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/app/qbs-setup-toolchains/probe.cpp b/src/app/qbs-setup-toolchains/probe.cpp index 618c4793b..ce491dd0e 100644 --- a/src/app/qbs-setup-toolchains/probe.cpp +++ b/src/app/qbs-setup-toolchains/probe.cpp @@ -139,6 +139,34 @@ static void setCommonProperties(Profile &profile, const QString &compilerFilePat HostOsInfo::defaultEndianness(architecture)); } +class ToolPathSetup +{ +public: + ToolPathSetup(Profile *profile, const QString &path, const QString &toolchainPrefix) + : m_profile(profile), m_compilerDirPath(path), m_toolchainPrefix(toolchainPrefix) + { + } + + void apply(const QString &toolName, const QString &propertyName) const + { + QString toolFileName = m_toolchainPrefix + HostOsInfo::appendExecutableSuffix(toolName); + if (QFile::exists(m_compilerDirPath + QLatin1Char('/') + toolFileName)) + return; + const QString toolFilePath = findExecutable(toolFileName); + if (toolFilePath.isEmpty()) { + qWarning("%s", qPrintable( + QString(QLatin1String("'%1' exists neither in '%2' nor in PATH.")) + .arg(toolFileName, m_compilerDirPath))); + } + m_profile->setValue(propertyName, toolFilePath); + } + +private: + Profile * const m_profile; + const QString &m_compilerDirPath; + const QString &m_toolchainPrefix; +}; + static Profile createGccProfile(const QString &_compilerFilePath, Settings *settings, const QStringList &toolchainTypes, const QString &profileName = QString()) @@ -164,12 +192,21 @@ static Profile createGccProfile(const QString &_compilerFilePath, Settings *sett setCommonProperties(profile, compilerFilePath, toolchainTypes, compilerTriplet.first()); const QString compilerName = QFileInfo(compilerFilePath).fileName(); + QString toolchainPrefix; if (compilerName.contains(QLatin1Char('-'))) { QStringList nameParts = compilerName.split(QLatin1Char('-')); profile.setValue(QLatin1String("cpp.compilerName"), nameParts.takeLast()); - profile.setValue(QLatin1String("cpp.toolchainPrefix"), - nameParts.join(QLatin1String("-")) + QLatin1Char('-')); + toolchainPrefix = nameParts.join(QLatin1String("-")) + QLatin1Char('-'); + profile.setValue(QLatin1String("cpp.toolchainPrefix"), toolchainPrefix); } + + // Check whether auxiliary tools reside within the toolchain's install path. + // This might not be the case when using icecc or another compiler wrapper. + const QString compilerDirPath = QFileInfo(compilerFilePath).absolutePath(); + const ToolPathSetup toolPathSetup(&profile, compilerDirPath, toolchainPrefix); + toolPathSetup.apply(QLatin1String("ar"), QLatin1String("cpp.archiverPath")); + toolPathSetup.apply(QLatin1String("nm"), QLatin1String("cpp.nmPath")); + qStdout << Tr::tr("Profile '%1' created for '%2'.").arg(profile.name(), compilerFilePath) << endl; return profile; |