forked from qt-creator/qt-creator
GCC: Actually use sysroot for header path detection
Function signature was prepared for that on
4c6b794774
but it wasn't really used
Change-Id: I1ee7059a00f0441d42a117b8f8d2c8c776d93815
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
77b3de44e2
commit
948abf10ae
@@ -418,9 +418,10 @@ void AutotoolsProject::updateCppCodeModel()
|
||||
QByteArray macros;
|
||||
|
||||
if (activeTarget()) {
|
||||
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(activeTarget()->kit());
|
||||
ProjectExplorer::Kit *k = activeTarget()->kit();
|
||||
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
|
||||
if (tc) {
|
||||
const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths();
|
||||
const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k));
|
||||
foreach (const HeaderPath &headerPath, allHeaderPaths) {
|
||||
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
|
||||
allFrameworkPaths.append(headerPath.path());
|
||||
|
@@ -286,7 +286,8 @@ bool CMakeProject::parseCMakeLists()
|
||||
|
||||
createUiCodeModelSupport();
|
||||
|
||||
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(activeTarget()->kit());
|
||||
Kit *k = activeTarget()->kit();
|
||||
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
|
||||
if (!tc) {
|
||||
emit buildTargetsChanged();
|
||||
emit fileListChanged();
|
||||
@@ -304,7 +305,7 @@ bool CMakeProject::parseCMakeLists()
|
||||
|
||||
QStringList allFrameworkPaths;
|
||||
QList<ProjectExplorer::HeaderPath> allHeaderPaths;
|
||||
allHeaderPaths = tc->systemHeaderPaths();
|
||||
allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k));
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) {
|
||||
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
||||
allFrameworkPaths.append(headerPath.path());
|
||||
|
@@ -249,13 +249,13 @@ void GenericProject::refresh(RefreshOptions options)
|
||||
CPlusPlus::CppModelManagerInterface::ProjectPart::Ptr part(
|
||||
new CPlusPlus::CppModelManagerInterface::ProjectPart);
|
||||
|
||||
ToolChain *tc = activeTarget() ?
|
||||
ToolChainKitInformation::toolChain(activeTarget()->kit()) : 0;
|
||||
Kit *k = activeTarget() ? activeTarget()->kit() : KitManager::instance()->defaultKit();
|
||||
ToolChain *tc = k ? ToolChainKitInformation::toolChain(k) : 0;
|
||||
if (tc) {
|
||||
part->defines = tc->predefinedMacros(QStringList());
|
||||
part->defines += '\n';
|
||||
|
||||
foreach (const HeaderPath &headerPath, tc->systemHeaderPaths()) {
|
||||
foreach (const HeaderPath &headerPath, tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k))) {
|
||||
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
|
||||
part->frameworkPaths.append(headerPath.path());
|
||||
else
|
||||
|
@@ -108,8 +108,9 @@ ToolChain::CompilerFlags AbstractMsvcToolChain::compilerFlags(const QStringList
|
||||
}
|
||||
}
|
||||
|
||||
QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths() const
|
||||
QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const
|
||||
{
|
||||
Q_UNUSED(sysRoot);
|
||||
if (m_headerPaths.isEmpty()) {
|
||||
Utils::Environment env(m_lastEnvironment);
|
||||
addToEnvironment(env);
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
QByteArray predefinedMacros(const QStringList &cxxflags) const;
|
||||
CompilerFlags compilerFlags(const QStringList &cxxflags) const;
|
||||
QList<HeaderPath> systemHeaderPaths() const;
|
||||
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
|
||||
void addToEnvironment(Utils::Environment &env) const;
|
||||
|
||||
QString makeCommand() const;
|
||||
|
@@ -148,12 +148,12 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar
|
||||
return predefinedMacros;
|
||||
}
|
||||
|
||||
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &env, const QString &sysrootPath)
|
||||
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &env, const FileName &sysrootPath)
|
||||
{
|
||||
QList<HeaderPath> systemHeaderPaths;
|
||||
QStringList arguments;
|
||||
if (!sysrootPath.isEmpty())
|
||||
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath));
|
||||
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString()));
|
||||
arguments << QLatin1String("-xc++")
|
||||
<< QLatin1String("-E")
|
||||
<< QLatin1String("-v")
|
||||
@@ -393,13 +393,13 @@ ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStringList &cxxflags
|
||||
return NO_FLAGS;
|
||||
}
|
||||
|
||||
QList<HeaderPath> GccToolChain::systemHeaderPaths() const
|
||||
QList<HeaderPath> GccToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const
|
||||
{
|
||||
if (m_headerPaths.isEmpty()) {
|
||||
// Using a clean environment breaks ccache/distcc/etc.
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList());
|
||||
m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList(), sysRoot);
|
||||
}
|
||||
return m_headerPaths;
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
QByteArray predefinedMacros(const QStringList &cxxflags) const;
|
||||
CompilerFlags compilerFlags(const QStringList &cxxflags) const;
|
||||
|
||||
QList<HeaderPath> systemHeaderPaths() const;
|
||||
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
|
||||
void addToEnvironment(Utils::Environment &env) const;
|
||||
QString makeCommand() const;
|
||||
QList<Utils::FileName> suggestedMkspecList() const;
|
||||
@@ -91,7 +91,7 @@ protected:
|
||||
virtual QList<Abi> detectSupportedAbis() const;
|
||||
virtual QString detectVersion() const;
|
||||
|
||||
static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath = QString());
|
||||
static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const Utils::FileName &sysrootPath);
|
||||
|
||||
mutable QByteArray m_predefinedMacros;
|
||||
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
STD_CXX11 = 1
|
||||
};
|
||||
virtual CompilerFlags compilerFlags(const QStringList &cxxflags) const = 0;
|
||||
virtual QList<HeaderPath> systemHeaderPaths() const = 0;
|
||||
virtual QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const = 0;
|
||||
virtual void addToEnvironment(Utils::Environment &env) const = 0;
|
||||
virtual QString makeCommand() const = 0;
|
||||
|
||||
|
@@ -527,7 +527,7 @@ void Qt4Project::updateCppCodeModel()
|
||||
|
||||
QList<HeaderPath> headers;
|
||||
if (tc)
|
||||
headers = tc->systemHeaderPaths(); // todo pass cxxflags?
|
||||
headers = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k)); // todo pass cxxflags?
|
||||
if (qtVersion) {
|
||||
headers.append(qtVersion->systemHeaderPathes(k));
|
||||
}
|
||||
|
Reference in New Issue
Block a user