forked from qt-creator/qt-creator
ProjectExplorer: Use FilePath for sysroots
... and reduce to the relevant part when passing to cmake. Task-number: QTCREATORBUG-27229 Change-Id: I7cde2ff04530caf439d6707c2c6d15a8e734ae0b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -347,10 +347,10 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
|||||||
HeaderPathsCache headerPaths = headerPathsCache();
|
HeaderPathsCache headerPaths = headerPathsCache();
|
||||||
|
|
||||||
return [env, compiler, headerPaths, languageId](const QStringList &flags,
|
return [env, compiler, headerPaths, languageId](const QStringList &flags,
|
||||||
const QString &fileName,
|
const FilePath &sysRoot,
|
||||||
const QString &) {
|
const QString &) {
|
||||||
Q_UNUSED(flags)
|
Q_UNUSED(flags)
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(sysRoot)
|
||||||
|
|
||||||
const HeaderPaths paths = dumpHeaderPaths(compiler, languageId, env);
|
const HeaderPaths paths = dumpHeaderPaths(compiler, languageId, env);
|
||||||
headerPaths->insert({}, paths);
|
headerPaths->insert({}, paths);
|
||||||
|
|||||||
@@ -473,9 +473,9 @@ ToolChain::BuiltInHeaderPathsRunner KeilToolChain::createBuiltInHeaderPathsRunne
|
|||||||
const HeaderPathsCache headerPaths = headerPathsCache();
|
const HeaderPathsCache headerPaths = headerPathsCache();
|
||||||
|
|
||||||
return [compiler,
|
return [compiler,
|
||||||
headerPaths](const QStringList &flags, const QString &fileName, const QString &) {
|
headerPaths](const QStringList &flags, const FilePath &sysRoot, const QString &) {
|
||||||
Q_UNUSED(flags)
|
Q_UNUSED(flags)
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(sysRoot)
|
||||||
|
|
||||||
const HeaderPaths paths = dumpHeaderPaths(compiler);
|
const HeaderPaths paths = dumpHeaderPaths(compiler);
|
||||||
headerPaths->insert({}, paths);
|
headerPaths->insert({}, paths);
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
|||||||
const FilePath compiler = compilerCommand();
|
const FilePath compiler = compilerCommand();
|
||||||
const Abi abi = targetAbi();
|
const Abi abi = targetAbi();
|
||||||
|
|
||||||
return [env, compiler, abi](const QStringList &, const QString &, const QString &) {
|
return [env, compiler, abi](const QStringList &, const FilePath &, const QString &) {
|
||||||
return dumpHeaderPaths(compiler, env, abi);
|
return dumpHeaderPaths(compiler, env, abi);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
using namespace CppEditor;
|
using namespace CppEditor;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CompilationDatabaseProjectManager {
|
namespace CompilationDatabaseProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -124,7 +125,7 @@ public:
|
|||||||
QStringList flags;
|
QStringList flags;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString workingDir;
|
QString workingDir;
|
||||||
QString sysRoot;
|
FilePath sysRoot;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +184,8 @@ void CompilationDatabaseTests::testFilterArguments()
|
|||||||
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
||||||
{"QT_CREATOR", "1"}}));
|
{"QT_CREATOR", "1"}}));
|
||||||
QCOMPARE(testData.fileKind, CppEditor::ProjectFile::Kind::CXXSource);
|
QCOMPARE(testData.fileKind, CppEditor::ProjectFile::Kind::CXXSource);
|
||||||
QCOMPARE(testData.sysRoot, HostOsInfo::isWindowsHost() ? QString("C:\\sysroot\\embedded")
|
QCOMPARE(testData.sysRoot.toString(), HostOsInfo::isWindowsHost() ? QString("C:\\sysroot\\embedded")
|
||||||
: QString("/opt/sysroot/embedded"));
|
: QString("/opt/sysroot/embedded"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString kCmakeCommand
|
static QString kCmakeCommand
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CompilationDatabaseProjectManager {
|
namespace CompilationDatabaseProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -102,7 +103,7 @@ void filteredFlags(const QString &fileName,
|
|||||||
HeaderPaths &headerPaths,
|
HeaderPaths &headerPaths,
|
||||||
Macros ¯os,
|
Macros ¯os,
|
||||||
CppEditor::ProjectFile::Kind &fileKind,
|
CppEditor::ProjectFile::Kind &fileKind,
|
||||||
QString &sysRoot)
|
Utils::FilePath &sysRoot)
|
||||||
{
|
{
|
||||||
if (flags.empty())
|
if (flags.empty())
|
||||||
return;
|
return;
|
||||||
@@ -192,7 +193,7 @@ void filteredFlags(const QString &fileName,
|
|||||||
|
|
||||||
if (flag.startsWith("--sysroot=")) {
|
if (flag.startsWith("--sysroot=")) {
|
||||||
if (sysRoot.isEmpty())
|
if (sysRoot.isEmpty())
|
||||||
sysRoot = updatedPathFlag(flag.mid(10), workingDir);
|
sysRoot = FilePath::fromString(updatedPathFlag(flag.mid(10), workingDir));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "compilationdatabaseconstants.h"
|
|
||||||
|
|
||||||
#include <cppeditor/cppprojectfile.h>
|
#include <cppeditor/cppprojectfile.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -65,7 +63,7 @@ void filteredFlags(const QString &fileName,
|
|||||||
QVector<ProjectExplorer::HeaderPath> &headerPaths,
|
QVector<ProjectExplorer::HeaderPath> &headerPaths,
|
||||||
QVector<ProjectExplorer::Macro> ¯os,
|
QVector<ProjectExplorer::Macro> ¯os,
|
||||||
CppEditor::ProjectFile::Kind &fileKind,
|
CppEditor::ProjectFile::Kind &fileKind,
|
||||||
QString &sysRoot);
|
Utils::FilePath &sysRoot);
|
||||||
|
|
||||||
QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache);
|
QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "compilationdbparser.h"
|
#include "compilationdbparser.h"
|
||||||
|
|
||||||
|
#include "compilationdatabaseconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <projectexplorer/task.h>
|
#include <projectexplorer/task.h>
|
||||||
#include <projectexplorer/treescanner.h>
|
#include <projectexplorer/treescanner.h>
|
||||||
|
|||||||
@@ -1533,7 +1533,7 @@ void CppModelManager::setupFallbackProjectPart()
|
|||||||
if (sysroot.isEmpty())
|
if (sysroot.isEmpty())
|
||||||
sysroot = Utils::FilePath::fromString(defaultTc->sysRoot());
|
sysroot = Utils::FilePath::fromString(defaultTc->sysRoot());
|
||||||
Utils::Environment env = defaultKit->buildEnvironment();
|
Utils::Environment env = defaultKit->buildEnvironment();
|
||||||
tcInfo = ToolChainInfo(defaultTc, sysroot.toString(), env);
|
tcInfo = ToolChainInfo(defaultTc, sysroot, env);
|
||||||
const auto macroInspectionWrapper = [runner = tcInfo.macroInspectionRunner](
|
const auto macroInspectionWrapper = [runner = tcInfo.macroInspectionRunner](
|
||||||
const QStringList &flags) {
|
const QStringList &flags) {
|
||||||
ToolChain::MacroInspectionReport report = runner(flags);
|
ToolChain::MacroInspectionReport report = runner(flags);
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
|
|||||||
const HeaderPaths builtInHeaderPaths = m_builtInHeaderPaths;
|
const HeaderPaths builtInHeaderPaths = m_builtInHeaderPaths;
|
||||||
|
|
||||||
// This runner must be thread-safe!
|
// This runner must be thread-safe!
|
||||||
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &, const QString &) {
|
return [builtInHeaderPaths](const QStringList &cxxFlags, const FilePath &sysRoot, const QString &) {
|
||||||
|
Q_UNUSED(sysRoot)
|
||||||
HeaderPaths flagHeaderPaths;
|
HeaderPaths flagHeaderPaths;
|
||||||
for (const QString &cxxFlag : cxxFlags) {
|
for (const QString &cxxFlag : cxxFlags) {
|
||||||
if (cxxFlag.startsWith(QLatin1String("-I")))
|
if (cxxFlag.startsWith(QLatin1String("-I")))
|
||||||
|
|||||||
@@ -596,15 +596,15 @@ QStringList GccToolChain::includedFiles(const QStringList &flags, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList GccToolChain::gccPrepareArguments(const QStringList &flags,
|
QStringList GccToolChain::gccPrepareArguments(const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const FilePath &sysRoot,
|
||||||
const QStringList &platformCodeGenFlags,
|
const QStringList &platformCodeGenFlags,
|
||||||
Utils::Id languageId,
|
Id languageId,
|
||||||
OptionsReinterpreter reinterpretOptions)
|
OptionsReinterpreter reinterpretOptions)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
const bool hasKitSysroot = !sysRoot.isEmpty();
|
const bool hasKitSysroot = !sysRoot.isEmpty();
|
||||||
if (hasKitSysroot)
|
if (hasKitSysroot)
|
||||||
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysRoot));
|
arguments.append(QString("--sysroot=%1").arg(sysRoot.nativePath()));
|
||||||
|
|
||||||
QStringList allFlags;
|
QStringList allFlags;
|
||||||
allFlags << platformCodeGenFlags << flags;
|
allFlags << platformCodeGenFlags << flags;
|
||||||
@@ -629,7 +629,7 @@ HeaderPaths GccToolChain::builtInHeaderPaths(const Utils::Environment &env,
|
|||||||
Utils::Id languageId,
|
Utils::Id languageId,
|
||||||
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||||
const QStringList &flags,
|
const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const Utils::FilePath &sysRoot,
|
||||||
const QString &originalTargetTriple)
|
const QString &originalTargetTriple)
|
||||||
{
|
{
|
||||||
QStringList arguments = gccPrepareArguments(flags,
|
QStringList arguments = gccPrepareArguments(flags,
|
||||||
@@ -677,7 +677,7 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
|
|||||||
headerCache = headerPathsCache(),
|
headerCache = headerPathsCache(),
|
||||||
languageId = language(),
|
languageId = language(),
|
||||||
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const FilePath &sysRoot,
|
||||||
const QString &) {
|
const QString &) {
|
||||||
return builtInHeaderPaths(fullEnv,
|
return builtInHeaderPaths(fullEnv,
|
||||||
compilerCommand,
|
compilerCommand,
|
||||||
@@ -1712,7 +1712,7 @@ ToolChain::BuiltInHeaderPathsRunner ClangToolChain::createBuiltInHeaderPathsRunn
|
|||||||
headerCache = headerPathsCache(),
|
headerCache = headerPathsCache(),
|
||||||
languageId = language(),
|
languageId = language(),
|
||||||
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const FilePath &sysRoot,
|
||||||
const QString &target) {
|
const QString &target) {
|
||||||
return builtInHeaderPaths(fullEnv,
|
return builtInHeaderPaths(fullEnv,
|
||||||
compilerCommand,
|
compilerCommand,
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ protected:
|
|||||||
Utils::Id languageId,
|
Utils::Id languageId,
|
||||||
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||||
const QStringList &flags,
|
const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const Utils::FilePath &sysRoot,
|
||||||
const QString &originalTargetTriple);
|
const QString &originalTargetTriple);
|
||||||
|
|
||||||
static HeaderPaths gccHeaderPaths(const Utils::FilePath &gcc,
|
static HeaderPaths gccHeaderPaths(const Utils::FilePath &gcc,
|
||||||
@@ -175,7 +175,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void updateSupportedAbis() const;
|
void updateSupportedAbis() const;
|
||||||
static QStringList gccPrepareArguments(const QStringList &flags,
|
static QStringList gccPrepareArguments(const QStringList &flags,
|
||||||
const QString &sysRoot,
|
const Utils::FilePath &sysRoot,
|
||||||
const QStringList &platformCodeGenFlags,
|
const QStringList &platformCodeGenFlags,
|
||||||
Utils::Id languageId,
|
Utils::Id languageId,
|
||||||
OptionsReinterpreter reinterpretOptions);
|
OptionsReinterpreter reinterpretOptions);
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
|
|||||||
Utils::Environment fullEnv = env;
|
Utils::Environment fullEnv = env;
|
||||||
addToEnvironment(fullEnv);
|
addToEnvironment(fullEnv);
|
||||||
|
|
||||||
return [this, fullEnv](const QStringList &, const QString &, const QString &) {
|
return [this, fullEnv](const QStringList &, const FilePath &, const QString &) {
|
||||||
QMutexLocker locker(&m_headerPathsMutex);
|
QMutexLocker locker(&m_headerPathsMutex);
|
||||||
const auto envList = fullEnv.toStringList();
|
const auto envList = fullEnv.toStringList();
|
||||||
const auto it = m_headerPathsPerEnv.constFind(envList);
|
const auto it = m_headerPathsPerEnv.constFind(envList);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
#include "kitinformation.h"
|
#include "kitinformation.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "projectexplorerconstants.h"
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -165,7 +164,7 @@ KitInfo::KitInfo(Kit *kit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sysroot
|
// Sysroot
|
||||||
sysRootPath = SysRootKitAspect::sysRoot(kit).toString();
|
sysRootPath = SysRootKitAspect::sysRoot(kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KitInfo::isValid() const
|
bool KitInfo::isValid() const
|
||||||
@@ -174,7 +173,7 @@ bool KitInfo::isValid() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
|
ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
|
||||||
const QString &sysRootPath,
|
const Utils::FilePath &sysRootPath,
|
||||||
const Utils::Environment &env)
|
const Utils::Environment &env)
|
||||||
{
|
{
|
||||||
if (toolChain) {
|
if (toolChain) {
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
|
|
||||||
Utils::QtMajorVersion projectPartQtVersion = Utils::QtMajorVersion::None;
|
Utils::QtMajorVersion projectPartQtVersion = Utils::QtMajorVersion::None;
|
||||||
|
|
||||||
QString sysRootPath;
|
Utils::FilePath sysRootPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT ToolChainInfo
|
class PROJECTEXPLORER_EXPORT ToolChainInfo
|
||||||
@@ -146,7 +146,7 @@ class PROJECTEXPLORER_EXPORT ToolChainInfo
|
|||||||
public:
|
public:
|
||||||
ToolChainInfo() = default;
|
ToolChainInfo() = default;
|
||||||
ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
|
ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
|
||||||
const QString &sysRootPath,
|
const Utils::FilePath &sysRootPath,
|
||||||
const Utils::Environment &env);
|
const Utils::Environment &env);
|
||||||
|
|
||||||
bool isValid() const { return type.isValid(); }
|
bool isValid() const { return type.isValid(); }
|
||||||
@@ -161,7 +161,7 @@ public:
|
|||||||
Utils::FilePath installDir;
|
Utils::FilePath installDir;
|
||||||
QStringList extraCodeModelFlags;
|
QStringList extraCodeModelFlags;
|
||||||
|
|
||||||
QString sysRootPath; // For headerPathsRunner.
|
Utils::FilePath sysRootPath; // For headerPathsRunner.
|
||||||
ProjectExplorer::ToolChain::BuiltInHeaderPathsRunner headerPathsRunner;
|
ProjectExplorer::ToolChain::BuiltInHeaderPathsRunner headerPathsRunner;
|
||||||
ProjectExplorer::ToolChain::MacroInspectionRunner macroInspectionRunner;
|
ProjectExplorer::ToolChain::MacroInspectionRunner macroInspectionRunner;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public:
|
|||||||
|
|
||||||
// A BuiltInHeaderPathsRunner is created in the ui thread and runs in another thread.
|
// A BuiltInHeaderPathsRunner is created in the ui thread and runs in another thread.
|
||||||
using BuiltInHeaderPathsRunner = std::function<HeaderPaths(
|
using BuiltInHeaderPathsRunner = std::function<HeaderPaths(
|
||||||
const QStringList &cxxflags, const QString &sysRoot, const QString &originalTargetTriple)>;
|
const QStringList &cxxflags, const Utils::FilePath &sysRoot, const QString &originalTargetTriple)>;
|
||||||
virtual BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner(const Utils::Environment &env) const = 0;
|
virtual BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner(const Utils::Environment &env) const = 0;
|
||||||
virtual void addToEnvironment(Utils::Environment &env) const = 0;
|
virtual void addToEnvironment(Utils::Environment &env) const = 0;
|
||||||
virtual Utils::FilePath makeCommand(const Utils::Environment &env) const = 0;
|
virtual Utils::FilePath makeCommand(const Utils::Environment &env) const = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user