Commit 4c6b7947 authored by Marco Bubke's avatar Marco Bubke
Browse files

Add sysroot to the gcc tool chain system header detection



If no sysroot is applied the sysroot/usr/include path is not detected. Is
fixing a typo too.

Change-Id: I6a4e750b8b24b9f702ff4874810a91f020fca410
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent 998e4ae1
...@@ -146,10 +146,12 @@ static QByteArray gccPredefinedMacros(const Utils::FileName &gcc, const QStringL ...@@ -146,10 +146,12 @@ static QByteArray gccPredefinedMacros(const Utils::FileName &gcc, const QStringL
return predefinedMacros; return predefinedMacros;
} }
static QList<HeaderPath> gccHeaderPathes(const Utils::FileName &gcc, const QStringList &env) QList<HeaderPath> GccToolChain::gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath)
{ {
QList<HeaderPath> systemHeaderPaths; QList<HeaderPath> systemHeaderPaths;
QStringList arguments; QStringList arguments;
if (!sysrootPath.isEmpty())
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath));
arguments << QLatin1String("-xc++") arguments << QLatin1String("-xc++")
<< QLatin1String("-E") << QLatin1String("-E")
<< QLatin1String("-v") << QLatin1String("-v")
...@@ -326,7 +328,7 @@ GccToolChain::GccToolChain(const GccToolChain &tc) : ...@@ -326,7 +328,7 @@ GccToolChain::GccToolChain(const GccToolChain &tc) :
m_debuggerCommand(tc.debuggerCommand()), m_debuggerCommand(tc.debuggerCommand()),
m_targetAbi(tc.m_targetAbi), m_targetAbi(tc.m_targetAbi),
m_supportedAbis(tc.m_supportedAbis), m_supportedAbis(tc.m_supportedAbis),
m_headerPathes(tc.m_headerPathes), m_headerPaths(tc.m_headerPaths),
m_version(tc.m_version) m_version(tc.m_version)
{ } { }
...@@ -409,13 +411,13 @@ ProjectExplorer::ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStr ...@@ -409,13 +411,13 @@ ProjectExplorer::ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStr
QList<HeaderPath> GccToolChain::systemHeaderPaths() const QList<HeaderPath> GccToolChain::systemHeaderPaths() const
{ {
if (m_headerPathes.isEmpty()) { if (m_headerPaths.isEmpty()) {
// Using a clean environment breaks ccache/distcc/etc. // Using a clean environment breaks ccache/distcc/etc.
Utils::Environment env = Utils::Environment::systemEnvironment(); Utils::Environment env = Utils::Environment::systemEnvironment();
addToEnvironment(env); addToEnvironment(env);
m_headerPathes = gccHeaderPathes(m_compilerCommand, env.toStringList()); m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList());
} }
return m_headerPathes; return m_headerPaths;
} }
void GccToolChain::addToEnvironment(Utils::Environment &env) const void GccToolChain::addToEnvironment(Utils::Environment &env) const
......
...@@ -97,6 +97,8 @@ protected: ...@@ -97,6 +97,8 @@ protected:
virtual QList<Abi> detectSupportedAbis() const; virtual QList<Abi> detectSupportedAbis() const;
virtual QString detectVersion() const; virtual QString detectVersion() const;
static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath = QString());
mutable QByteArray m_predefinedMacros; mutable QByteArray m_predefinedMacros;
private: private:
...@@ -109,7 +111,7 @@ private: ...@@ -109,7 +111,7 @@ private:
Abi m_targetAbi; Abi m_targetAbi;
mutable QList<Abi> m_supportedAbis; mutable QList<Abi> m_supportedAbis;
mutable QList<HeaderPath> m_headerPathes; mutable QList<HeaderPath> m_headerPaths;
mutable QString m_version; mutable QString m_version;
friend class Internal::GccToolChainFactory; friend class Internal::GccToolChainFactory;
......
Supports Markdown
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