forked from qt-creator/qt-creator
ProjectExplorer: Consolidate *ToolChain::compilerCommand() implementations
All ToolChains had an compiler command member one way or the other, so have one in the base class and drop all others. ClangClToolChain is quirky insofar as it diverts the compilerCommand() to the additional m_clangPath member. This is left for a later patch. Change-Id: Ic8b5da17a4b7050966d0c37573edb0706fac2ecf Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -58,7 +58,6 @@ namespace Internal {
|
||||
|
||||
// Helpers:
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
@@ -294,6 +293,7 @@ IarToolChain::IarToolChain() :
|
||||
{
|
||||
setTypeDisplayName(Internal::IarToolChain::tr("IAREW"));
|
||||
setTargetAbiKey("TargetAbi");
|
||||
setCompilerCommandKey("CompilerPath");
|
||||
}
|
||||
|
||||
bool IarToolChain::isValid() const
|
||||
@@ -306,16 +306,16 @@ ToolChain::MacroInspectionRunner IarToolChain::createMacroInspectionRunner() con
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Utils::Id languageId = language();
|
||||
const FilePath compiler = compilerCommand();
|
||||
const Id languageId = language();
|
||||
const QStringList extraArgs = m_extraCodeModelFlags;
|
||||
MacrosCache macrosCache = predefinedMacrosCache();
|
||||
|
||||
return [env, compilerCommand, extraArgs, macrosCache, languageId]
|
||||
return [env, compiler, extraArgs, macrosCache, languageId]
|
||||
(const QStringList &flags) {
|
||||
Q_UNUSED(flags)
|
||||
|
||||
Macros macros = dumpPredefinedMacros(compilerCommand, extraArgs, languageId, env.toStringList());
|
||||
Macros macros = dumpPredefinedMacros(compiler, extraArgs, languageId, env.toStringList());
|
||||
macros.append({"__intrinsic", "", MacroType::Define});
|
||||
macros.append({"__nounwind", "", MacroType::Define});
|
||||
macros.append({"__noreturn", "", MacroType::Define});
|
||||
@@ -353,18 +353,18 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Utils::Id languageId = language();
|
||||
const FilePath compiler = compilerCommand();
|
||||
const Id languageId = language();
|
||||
|
||||
HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
return [env, compilerCommand, headerPaths, languageId](const QStringList &flags,
|
||||
return [env, compiler, headerPaths, languageId](const QStringList &flags,
|
||||
const QString &fileName,
|
||||
const QString &) {
|
||||
Q_UNUSED(flags)
|
||||
Q_UNUSED(fileName)
|
||||
|
||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, languageId, env.toStringList());
|
||||
const HeaderPaths paths = dumpHeaderPaths(compiler, languageId, env.toStringList());
|
||||
headerPaths->insert({}, paths);
|
||||
|
||||
return paths;
|
||||
@@ -380,8 +380,8 @@ HeaderPaths IarToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||
|
||||
void IarToolChain::addToEnvironment(Environment &env) const
|
||||
{
|
||||
if (!m_compilerCommand.isEmpty()) {
|
||||
const FilePath path = m_compilerCommand.parentDir();
|
||||
if (!compilerCommand().isEmpty()) {
|
||||
const FilePath path = compilerCommand().parentDir();
|
||||
env.prependOrSetPath(path.toString());
|
||||
}
|
||||
}
|
||||
@@ -394,7 +394,6 @@ QList<Utils::OutputLineParser *> IarToolChain::createOutputParsers() const
|
||||
QVariantMap IarToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_extraCodeModelFlags);
|
||||
return data;
|
||||
}
|
||||
@@ -403,7 +402,6 @@ bool IarToolChain::fromMap(const QVariantMap &data)
|
||||
{
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_extraCodeModelFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
return true;
|
||||
}
|
||||
@@ -419,23 +417,10 @@ bool IarToolChain::operator==(const ToolChain &other) const
|
||||
return false;
|
||||
|
||||
const auto customTc = static_cast<const IarToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
return compilerCommand() == customTc->compilerCommand()
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags;
|
||||
}
|
||||
|
||||
void IarToolChain::setCompilerCommand(const FilePath &file)
|
||||
{
|
||||
if (file == m_compilerCommand)
|
||||
return;
|
||||
m_compilerCommand = file;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
FilePath IarToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void IarToolChain::setExtraCodeModelFlags(const QStringList &flags)
|
||||
{
|
||||
if (flags == m_extraCodeModelFlags)
|
||||
|
@@ -75,9 +75,6 @@ public:
|
||||
|
||||
bool operator ==(const ToolChain &other) const final;
|
||||
|
||||
void setCompilerCommand(const Utils::FilePath &file);
|
||||
Utils::FilePath compilerCommand() const final;
|
||||
|
||||
void setExtraCodeModelFlags(const QStringList &flags);
|
||||
QStringList extraCodeModelFlags() const final;
|
||||
|
||||
@@ -86,7 +83,6 @@ public:
|
||||
private:
|
||||
IarToolChain();
|
||||
|
||||
Utils::FilePath m_compilerCommand;
|
||||
QStringList m_extraCodeModelFlags;
|
||||
|
||||
friend class IarToolChainFactory;
|
||||
|
@@ -60,7 +60,6 @@ namespace Internal {
|
||||
|
||||
// Helpers:
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
@@ -433,6 +432,7 @@ KeilToolChain::KeilToolChain() :
|
||||
{
|
||||
setTypeDisplayName(tr("KEIL"));
|
||||
setTargetAbiKey("TargetAbi");
|
||||
setCompilerCommandKey("CompilerPath");
|
||||
}
|
||||
|
||||
bool KeilToolChain::isValid() const
|
||||
@@ -445,17 +445,16 @@ ToolChain::MacroInspectionRunner KeilToolChain::createMacroInspectionRunner() co
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Utils::Id lang = language();
|
||||
const FilePath compiler = compilerCommand();
|
||||
const Id lang = language();
|
||||
|
||||
MacrosCache macroCache = predefinedMacrosCache();
|
||||
const QStringList extraArgs = m_extraCodeModelFlags;
|
||||
|
||||
return [env, compilerCommand, extraArgs, macroCache, lang]
|
||||
(const QStringList &flags) {
|
||||
return [env, compiler, extraArgs, macroCache, lang](const QStringList &flags) {
|
||||
Q_UNUSED(flags)
|
||||
|
||||
const Macros macros = dumpPredefinedMacros(compilerCommand, extraArgs, env.toStringList());
|
||||
const Macros macros = dumpPredefinedMacros(compiler, extraArgs, env.toStringList());
|
||||
const auto report = MacroInspectionReport{macros, languageVersion(lang, macros)};
|
||||
macroCache->insert({}, report);
|
||||
|
||||
@@ -482,16 +481,15 @@ WarningFlags KeilToolChain::warningFlags(const QStringList &cxxflags) const
|
||||
ToolChain::BuiltInHeaderPathsRunner KeilToolChain::createBuiltInHeaderPathsRunner(
|
||||
const Environment &) const
|
||||
{
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const FilePath compiler = compilerCommand();
|
||||
const HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
return [compilerCommand,
|
||||
return [compiler,
|
||||
headerPaths](const QStringList &flags, const QString &fileName, const QString &) {
|
||||
Q_UNUSED(flags)
|
||||
Q_UNUSED(fileName)
|
||||
|
||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand);
|
||||
const HeaderPaths paths = dumpHeaderPaths(compiler);
|
||||
headerPaths->insert({}, paths);
|
||||
|
||||
return paths;
|
||||
@@ -507,8 +505,8 @@ HeaderPaths KeilToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||
|
||||
void KeilToolChain::addToEnvironment(Environment &env) const
|
||||
{
|
||||
if (!m_compilerCommand.isEmpty()) {
|
||||
const FilePath path = m_compilerCommand.parentDir();
|
||||
if (!compilerCommand().isEmpty()) {
|
||||
const FilePath path = compilerCommand().parentDir();
|
||||
env.prependOrSetPath(path.toString());
|
||||
}
|
||||
}
|
||||
@@ -521,7 +519,6 @@ QList<OutputLineParser *> KeilToolChain::createOutputParsers() const
|
||||
QVariantMap KeilToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_extraCodeModelFlags);
|
||||
return data;
|
||||
}
|
||||
@@ -530,7 +527,6 @@ bool KeilToolChain::fromMap(const QVariantMap &data)
|
||||
{
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_extraCodeModelFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
return true;
|
||||
}
|
||||
@@ -546,24 +542,11 @@ bool KeilToolChain::operator ==(const ToolChain &other) const
|
||||
return false;
|
||||
|
||||
const auto customTc = static_cast<const KeilToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
return compilerCommand() == customTc->compilerCommand()
|
||||
&& targetAbi() == customTc->targetAbi()
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags;
|
||||
}
|
||||
|
||||
void KeilToolChain::setCompilerCommand(const FilePath &file)
|
||||
{
|
||||
if (file == m_compilerCommand)
|
||||
return;
|
||||
m_compilerCommand = file;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
FilePath KeilToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void KeilToolChain::setExtraCodeModelFlags(const QStringList &flags)
|
||||
{
|
||||
if (flags == m_extraCodeModelFlags)
|
||||
|
@@ -76,9 +76,6 @@ public:
|
||||
|
||||
bool operator ==(const ToolChain &other) const final;
|
||||
|
||||
void setCompilerCommand(const Utils::FilePath &file);
|
||||
Utils::FilePath compilerCommand() const final;
|
||||
|
||||
void setExtraCodeModelFlags(const QStringList &flags);
|
||||
QStringList extraCodeModelFlags() const final;
|
||||
|
||||
@@ -87,7 +84,6 @@ public:
|
||||
private:
|
||||
KeilToolChain();
|
||||
|
||||
Utils::FilePath m_compilerCommand;
|
||||
QStringList m_extraCodeModelFlags;
|
||||
|
||||
friend class KeilToolChainFactory;
|
||||
|
@@ -58,8 +58,6 @@ namespace Internal {
|
||||
|
||||
// Helpers:
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
{
|
||||
const QFileInfo fi = compilerPath.toFileInfo();
|
||||
@@ -218,6 +216,7 @@ SdccToolChain::SdccToolChain() :
|
||||
{
|
||||
setTypeDisplayName(Internal::SdccToolChain::tr("SDCC"));
|
||||
setTargetAbiKey("TargetAbi");
|
||||
setCompilerCommandKey("CompilerPath");
|
||||
}
|
||||
|
||||
bool SdccToolChain::isValid() const
|
||||
@@ -230,17 +229,17 @@ ToolChain::MacroInspectionRunner SdccToolChain::createMacroInspectionRunner() co
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Utils::Id lang = language();
|
||||
const FilePath compiler = compilerCommand();
|
||||
const Id lang = language();
|
||||
const Abi abi = targetAbi();
|
||||
|
||||
MacrosCache macrosCache = predefinedMacrosCache();
|
||||
|
||||
return [env, compilerCommand, macrosCache, lang, abi]
|
||||
return [env, compiler, macrosCache, lang, abi]
|
||||
(const QStringList &flags) {
|
||||
Q_UNUSED(flags)
|
||||
|
||||
const Macros macros = dumpPredefinedMacros(compilerCommand, env.toStringList(),
|
||||
const Macros macros = dumpPredefinedMacros(compiler, env.toStringList(),
|
||||
abi);
|
||||
const auto report = MacroInspectionReport{macros, languageVersion(lang, macros)};
|
||||
macrosCache->insert({}, report);
|
||||
@@ -271,11 +270,11 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const FilePath compiler = compilerCommand();
|
||||
const Abi abi = targetAbi();
|
||||
|
||||
return [env, compilerCommand, abi](const QStringList &, const QString &, const QString &) {
|
||||
return dumpHeaderPaths(compilerCommand, env.toStringList(), abi);
|
||||
return [env, compiler, abi](const QStringList &, const QString &, const QString &) {
|
||||
return dumpHeaderPaths(compiler, env.toStringList(), abi);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -288,8 +287,8 @@ HeaderPaths SdccToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||
|
||||
void SdccToolChain::addToEnvironment(Environment &env) const
|
||||
{
|
||||
if (!m_compilerCommand.isEmpty()) {
|
||||
const FilePath path = m_compilerCommand.parentDir();
|
||||
if (!compilerCommand().isEmpty()) {
|
||||
const FilePath path = compilerCommand().parentDir();
|
||||
env.prependOrSetPath(path.toString());
|
||||
}
|
||||
}
|
||||
@@ -299,21 +298,6 @@ QList<Utils::OutputLineParser *> SdccToolChain::createOutputParsers() const
|
||||
return {new SdccParser};
|
||||
}
|
||||
|
||||
QVariantMap SdccToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
return data;
|
||||
}
|
||||
|
||||
bool SdccToolChain::fromMap(const QVariantMap &data)
|
||||
{
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<ToolChainConfigWidget> SdccToolChain::createConfigurationWidget()
|
||||
{
|
||||
return std::make_unique<SdccToolChainConfigWidget>(this);
|
||||
@@ -325,23 +309,10 @@ bool SdccToolChain::operator==(const ToolChain &other) const
|
||||
return false;
|
||||
|
||||
const auto customTc = static_cast<const SdccToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
return compilerCommand() == customTc->compilerCommand()
|
||||
&& targetAbi() == customTc->targetAbi();
|
||||
}
|
||||
|
||||
void SdccToolChain::setCompilerCommand(const FilePath &file)
|
||||
{
|
||||
if (file == m_compilerCommand)
|
||||
return;
|
||||
m_compilerCommand = file;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
FilePath SdccToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
FilePath SdccToolChain::makeCommand(const Environment &env) const
|
||||
{
|
||||
Q_UNUSED(env)
|
||||
|
@@ -68,23 +68,15 @@ public:
|
||||
void addToEnvironment(Utils::Environment &env) const final;
|
||||
QList<Utils::OutputLineParser *> createOutputParsers() const final;
|
||||
|
||||
QVariantMap toMap() const final;
|
||||
bool fromMap(const QVariantMap &data) final;
|
||||
|
||||
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
|
||||
|
||||
bool operator ==(const ToolChain &other) const final;
|
||||
|
||||
void setCompilerCommand(const Utils::FilePath &file);
|
||||
Utils::FilePath compilerCommand() const final;
|
||||
|
||||
Utils::FilePath makeCommand(const Utils::Environment &env) const final;
|
||||
|
||||
private:
|
||||
SdccToolChain();
|
||||
|
||||
Utils::FilePath m_compilerCommand;
|
||||
|
||||
friend class SdccToolChainFactory;
|
||||
friend class SdccToolChainConfigWidget;
|
||||
};
|
||||
|
@@ -37,7 +37,6 @@ const char C_NIMEDITOR_ID[] = "Nim.NimEditor";
|
||||
|
||||
// NimToolChain
|
||||
const char C_NIMTOOLCHAIN_TYPEID[] = "Nim.NimToolChain";
|
||||
const char C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY[] = "Nim.NimToolChain.CompilerCommand";
|
||||
|
||||
// NimProject
|
||||
const char C_NIMPROJECT_EXCLUDEDFILES[] = "Nim.NimProjectExcludedFiles";
|
||||
|
@@ -45,17 +45,17 @@ NimToolChain::NimToolChain()
|
||||
|
||||
NimToolChain::NimToolChain(Utils::Id typeId)
|
||||
: ToolChain(typeId)
|
||||
, m_compilerCommand(FilePath())
|
||||
, m_version(std::make_tuple(-1,-1,-1))
|
||||
{
|
||||
setLanguage(Constants::C_NIMLANGUAGE_ID);
|
||||
setTypeDisplayName(tr("Nim"));
|
||||
setTargetAbiNoSignal(Abi::hostAbi());
|
||||
setCompilerCommandKey("Nim.NimToolChain.CompilerCommand");
|
||||
}
|
||||
|
||||
bool NimToolChain::isValid() const
|
||||
{
|
||||
if (m_compilerCommand.isEmpty())
|
||||
if (compilerCommand().isEmpty())
|
||||
return false;
|
||||
QFileInfo fi = compilerCommand().toFileInfo();
|
||||
return fi.isExecutable();
|
||||
@@ -105,17 +105,6 @@ FilePath NimToolChain::makeCommand(const Environment &env) const
|
||||
return tmp.isEmpty() ? FilePath::fromString("make") : tmp;
|
||||
}
|
||||
|
||||
FilePath NimToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void NimToolChain::setCompilerCommand(const FilePath &compilerCommand)
|
||||
{
|
||||
m_compilerCommand = compilerCommand;
|
||||
parseVersion(compilerCommand, m_version);
|
||||
}
|
||||
|
||||
QList<Utils::OutputLineParser *> NimToolChain::createOutputParsers() const
|
||||
{
|
||||
return {};
|
||||
@@ -126,16 +115,9 @@ std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> NimToolChain::createConf
|
||||
return std::make_unique<NimToolChainConfigWidget>(this);
|
||||
}
|
||||
|
||||
QVariantMap NimToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data[Constants::C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY] = m_compilerCommand.toString();
|
||||
return data;
|
||||
}
|
||||
|
||||
QString NimToolChain::compilerVersion() const
|
||||
{
|
||||
return m_compilerCommand.isEmpty() || m_version == std::make_tuple(-1,-1,-1)
|
||||
return compilerCommand().isEmpty() || m_version == std::make_tuple(-1,-1,-1)
|
||||
? QString()
|
||||
: QString::asprintf("%d.%d.%d",
|
||||
std::get<0>(m_version),
|
||||
@@ -147,7 +129,7 @@ bool NimToolChain::fromMap(const QVariantMap &data)
|
||||
{
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
setCompilerCommand(FilePath::fromString(data.value(Constants::C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY).toString()));
|
||||
parseVersion(compilerCommand(), m_version);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,4 +153,4 @@ bool NimToolChain::parseVersion(const FilePath &path, std::tuple<int, int, int>
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // Nim
|
||||
|
@@ -52,20 +52,16 @@ public:
|
||||
const Utils::Environment &) const final;
|
||||
void addToEnvironment(Utils::Environment &env) const final;
|
||||
Utils::FilePath makeCommand(const Utils::Environment &env) const final;
|
||||
Utils::FilePath compilerCommand() const final;
|
||||
QString compilerVersion() const;
|
||||
void setCompilerCommand(const Utils::FilePath &compilerCommand);
|
||||
QList<Utils::OutputLineParser *> createOutputParsers() const final;
|
||||
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
|
||||
|
||||
QVariantMap toMap() const final;
|
||||
bool fromMap(const QVariantMap &data) final;
|
||||
|
||||
static bool parseVersion(const Utils::FilePath &path, std::tuple<int, int, int> &version);
|
||||
|
||||
private:
|
||||
Utils::FilePath m_compilerCommand;
|
||||
std::tuple<int, int, int> m_version;
|
||||
};
|
||||
|
||||
}
|
||||
} // Nim
|
||||
|
@@ -57,7 +57,6 @@ namespace ProjectExplorer {
|
||||
// Helpers:
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
static const char compilerCommandKeyC[] = "ProjectExplorer.CustomToolChain.CompilerPath";
|
||||
static const char makeCommandKeyC[] = "ProjectExplorer.CustomToolChain.MakePath";
|
||||
static const char predefinedMacrosKeyC[] = "ProjectExplorer.CustomToolChain.PredefinedMacros";
|
||||
static const char headerPathsKeyC[] = "ProjectExplorer.CustomToolChain.HeaderPaths";
|
||||
@@ -75,6 +74,7 @@ CustomToolChain::CustomToolChain() :
|
||||
{
|
||||
setTypeDisplayName(tr("Custom"));
|
||||
setTargetAbiKey("ProjectExplorer.CustomToolChain.TargetAbi");
|
||||
setCompilerCommandKey("ProjectExplorer.CustomToolChain.CompilerPath");
|
||||
}
|
||||
|
||||
CustomParserSettings CustomToolChain::customParserSettings() const
|
||||
@@ -210,19 +210,6 @@ void CustomToolChain::setHeaderPaths(const QStringList &list)
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
void CustomToolChain::setCompilerCommand(const FilePath &path)
|
||||
{
|
||||
if (path == m_compilerCommand)
|
||||
return;
|
||||
m_compilerCommand = path;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
FilePath CustomToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void CustomToolChain::setMakeCommand(const FilePath &path)
|
||||
{
|
||||
if (path == m_makeCommand)
|
||||
@@ -266,7 +253,6 @@ QString CustomToolChain::mkspecs() const
|
||||
QVariantMap CustomToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(QLatin1String(compilerCommandKeyC), m_compilerCommand.toString());
|
||||
data.insert(QLatin1String(makeCommandKeyC), m_makeCommand.toString());
|
||||
QStringList macros = Utils::transform<QList>(m_predefinedMacros, [](const Macro &m) { return QString::fromUtf8(m.toByteArray()); });
|
||||
data.insert(QLatin1String(predefinedMacrosKeyC), macros);
|
||||
@@ -283,7 +269,6 @@ bool CustomToolChain::fromMap(const QVariantMap &data)
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
|
||||
m_compilerCommand = FilePath::fromString(data.value(QLatin1String(compilerCommandKeyC)).toString());
|
||||
m_makeCommand = FilePath::fromString(data.value(QLatin1String(makeCommandKeyC)).toString());
|
||||
const QStringList macros = data.value(QLatin1String(predefinedMacrosKeyC)).toStringList();
|
||||
m_predefinedMacros = Macro::toMacros(macros.join('\n').toUtf8());
|
||||
|
@@ -91,8 +91,6 @@ public:
|
||||
|
||||
bool operator ==(const ToolChain &) const override;
|
||||
|
||||
void setCompilerCommand(const Utils::FilePath &);
|
||||
Utils::FilePath compilerCommand() const override;
|
||||
void setMakeCommand(const Utils::FilePath &);
|
||||
Utils::FilePath makeCommand(const Utils::Environment &environment) const override;
|
||||
|
||||
|
@@ -70,7 +70,6 @@ using namespace Internal;
|
||||
// Helpers:
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
static const char compilerCommandKeyC[] = "ProjectExplorer.GccToolChain.Path";
|
||||
static const char compilerPlatformCodeGenFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformCodeGenFlags";
|
||||
static const char compilerPlatformLinkerFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformLinkerFlags";
|
||||
static const char targetAbiKeyC[] = "ProjectExplorer.GccToolChain.TargetAbi";
|
||||
@@ -267,15 +266,7 @@ GccToolChain::GccToolChain(Utils::Id typeId) :
|
||||
{
|
||||
setTypeDisplayName(tr("GCC"));
|
||||
setTargetAbiKey(targetAbiKeyC);
|
||||
}
|
||||
|
||||
void GccToolChain::setCompilerCommand(const FilePath &path)
|
||||
{
|
||||
if (path == m_compilerCommand)
|
||||
return;
|
||||
|
||||
m_compilerCommand = path;
|
||||
toolChainUpdated();
|
||||
setCompilerCommandKey("ProjectExplorer.GccToolChain.Path");
|
||||
}
|
||||
|
||||
void GccToolChain::setSupportedAbis(const Abis &abis)
|
||||
@@ -309,7 +300,7 @@ QString GccToolChain::defaultDisplayName() const
|
||||
{
|
||||
QString type = typeDisplayName();
|
||||
const QRegularExpression regexp(binaryRegexp);
|
||||
const QRegularExpressionMatch match = regexp.match(m_compilerCommand.fileName());
|
||||
const QRegularExpressionMatch match = regexp.match(compilerCommand().fileName());
|
||||
if (match.lastCapturedIndex() >= 1)
|
||||
type += ' ' + match.captured(1);
|
||||
const Abi abi = targetAbi();
|
||||
@@ -355,7 +346,7 @@ Abis GccToolChain::supportedAbis() const
|
||||
|
||||
bool GccToolChain::isValid() const
|
||||
{
|
||||
if (m_compilerCommand.isEmpty())
|
||||
if (compilerCommand().isEmpty())
|
||||
return false;
|
||||
|
||||
QFileInfo fi = compilerCommand().toFileInfo();
|
||||
@@ -430,7 +421,6 @@ ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() con
|
||||
// Using a clean environment breaks ccache/distcc/etc.
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
|
||||
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
|
||||
QTC_CHECK(reinterpretOptions);
|
||||
@@ -438,7 +428,8 @@ ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() con
|
||||
Utils::Id lang = language();
|
||||
|
||||
// This runner must be thread-safe!
|
||||
return [env, compilerCommand, platformCodeGenFlags, reinterpretOptions, macroCache, lang]
|
||||
return [env, compilerCommand = compilerCommand(),
|
||||
platformCodeGenFlags, reinterpretOptions, macroCache, lang]
|
||||
(const QStringList &flags) {
|
||||
QStringList allFlags = platformCodeGenFlags + flags; // add only cxxflags is empty?
|
||||
QStringList arguments = gccPredefinedMacrosOptions(lang) + filteredFlags(allFlags, true);
|
||||
@@ -633,7 +624,7 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
|
||||
// This runner must be thread-safe!
|
||||
return [this,
|
||||
fullEnv,
|
||||
compilerCommand = m_compilerCommand,
|
||||
compilerCommand = compilerCommand(),
|
||||
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||
reinterpretOptions = m_optionsReinterpreter,
|
||||
headerCache = headerPathsCache(),
|
||||
@@ -676,7 +667,7 @@ void GccToolChain::addToEnvironment(Environment &env) const
|
||||
// On Windows gcc invokes cc1plus which is in libexec directory.
|
||||
// cc1plus depends on libwinpthread-1.dll which is in bin, so bin must be in the PATH.
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
addCommandPathToEnvironment(m_compilerCommand, env);
|
||||
addCommandPathToEnvironment(compilerCommand(), env);
|
||||
}
|
||||
|
||||
QStringList GccToolChain::suggestedMkspecList() const
|
||||
@@ -693,9 +684,9 @@ QStringList GccToolChain::suggestedMkspecList() const
|
||||
if (abi.os() == Abi::DarwinOS) {
|
||||
QString v = version();
|
||||
// prefer versioned g++ on macOS. This is required to enable building for older macOS versions
|
||||
if (v.startsWith("4.0") && m_compilerCommand.endsWith("-4.0"))
|
||||
if (v.startsWith("4.0") && compilerCommand().endsWith("-4.0"))
|
||||
return {"macx-g++40"};
|
||||
if (v.startsWith("4.2") && m_compilerCommand.endsWith("-4.2"))
|
||||
if (v.startsWith("4.2") && compilerCommand().endsWith("-4.2"))
|
||||
return {"macx-g++42"};
|
||||
return {"macx-g++"};
|
||||
}
|
||||
@@ -751,11 +742,6 @@ void GccToolChain::resetToolChain(const FilePath &path)
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
FilePath GccToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void GccToolChain::setPlatformCodeGenFlags(const QStringList &flags)
|
||||
{
|
||||
if (flags != m_platformCodeGenFlags) {
|
||||
@@ -798,7 +784,6 @@ QStringList GccToolChain::platformLinkerFlags() const
|
||||
QVariantMap GccToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_platformCodeGenFlags);
|
||||
data.insert(compilerPlatformLinkerFlagsKeyC, m_platformLinkerFlags);
|
||||
data.insert(originalTargetTripleKeyC, m_originalTargetTriple);
|
||||
@@ -811,7 +796,6 @@ bool GccToolChain::fromMap(const QVariantMap &data)
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_platformCodeGenFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
m_platformLinkerFlags = data.value(compilerPlatformLinkerFlagsKeyC).toStringList();
|
||||
m_originalTargetTriple = data.value(originalTargetTripleKeyC).toString();
|
||||
@@ -822,7 +806,7 @@ bool GccToolChain::fromMap(const QVariantMap &data)
|
||||
|
||||
const QString targetAbiString = data.value(targetAbiKeyC).toString();
|
||||
if (targetAbiString.isEmpty())
|
||||
resetToolChain(m_compilerCommand);
|
||||
resetToolChain(compilerCommand());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -833,7 +817,7 @@ bool GccToolChain::operator ==(const ToolChain &other) const
|
||||
return false;
|
||||
|
||||
auto gccTc = static_cast<const GccToolChain *>(&other);
|
||||
return m_compilerCommand == gccTc->m_compilerCommand && targetAbi() == gccTc->targetAbi()
|
||||
return compilerCommand() == gccTc->compilerCommand() && targetAbi() == gccTc->targetAbi()
|
||||
&& m_platformCodeGenFlags == gccTc->m_platformCodeGenFlags
|
||||
&& m_platformLinkerFlags == gccTc->m_platformLinkerFlags;
|
||||
}
|
||||
@@ -862,7 +846,7 @@ GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
ProjectExplorer::Macros macros = predefinedMacros(QStringList());
|
||||
return guessGccAbi(findLocalCompiler(m_compilerCommand, env),
|
||||
return guessGccAbi(findLocalCompiler(compilerCommand(), env),
|
||||
env.toStringList(),
|
||||
macros,
|
||||
platformCodeGenFlags());
|
||||
@@ -872,7 +856,7 @@ QString GccToolChain::detectVersion() const
|
||||
{
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
return gccVersion(findLocalCompiler(m_compilerCommand, env), env.toStringList(),
|
||||
return gccVersion(findLocalCompiler(compilerCommand(), env), env.toStringList(),
|
||||
filteredFlags(platformCodeGenFlags(), true));
|
||||
}
|
||||
|
||||
@@ -880,7 +864,7 @@ Utils::FilePath GccToolChain::detectInstallDir() const
|
||||
{
|
||||
Environment env = Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
return gccInstallDir(findLocalCompiler(m_compilerCommand, env), env.toStringList(),
|
||||
return gccInstallDir(findLocalCompiler(compilerCommand(), env), env.toStringList(),
|
||||
filteredFlags(platformCodeGenFlags(), true));
|
||||
}
|
||||
|
||||
@@ -1569,7 +1553,7 @@ ToolChain::BuiltInHeaderPathsRunner ClangToolChain::createBuiltInHeaderPathsRunn
|
||||
// This runner must be thread-safe!
|
||||
return [this,
|
||||
fullEnv,
|
||||
compilerCommand = m_compilerCommand,
|
||||
compilerCommand = compilerCommand(),
|
||||
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||
reinterpretOptions = m_optionsReinterpreter,
|
||||
headerCache = headerPathsCache(),
|
||||
|
@@ -103,7 +103,6 @@ public:
|
||||
bool operator ==(const ToolChain &) const override;
|
||||
|
||||
void resetToolChain(const Utils::FilePath &);
|
||||
Utils::FilePath compilerCommand() const override;
|
||||
void setPlatformCodeGenFlags(const QStringList &);
|
||||
QStringList extraCodeModelFlags() const override;
|
||||
QStringList platformCodeGenFlags() const;
|
||||
@@ -128,7 +127,6 @@ protected:
|
||||
using CacheItem = QPair<QStringList, Macros>;
|
||||
using GccCache = QVector<CacheItem>;
|
||||
|
||||
void setCompilerCommand(const Utils::FilePath &path);
|
||||
void setSupportedAbis(const Abis &abis);
|
||||
void setOriginalTargetTriple(const QString &targetTriple);
|
||||
void setInstallDir(const Utils::FilePath &installDir);
|
||||
@@ -187,7 +185,6 @@ private:
|
||||
OptionsReinterpreter reinterpretOptions);
|
||||
|
||||
protected:
|
||||
Utils::FilePath m_compilerCommand;
|
||||
QStringList m_platformCodeGenFlags;
|
||||
QStringList m_platformLinkerFlags;
|
||||
|
||||
|
@@ -1144,11 +1144,6 @@ FilePath MsvcToolChain::makeCommand(const Environment &environment) const
|
||||
return command;
|
||||
}
|
||||
|
||||
Utils::FilePath MsvcToolChain::compilerCommand() const
|
||||
{
|
||||
return m_compilerCommand;
|
||||
}
|
||||
|
||||
void MsvcToolChain::rescanForCompiler()
|
||||
{
|
||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||
|
@@ -87,7 +87,6 @@ public:
|
||||
void addToEnvironment(Utils::Environment &env) const override;
|
||||
|
||||
Utils::FilePath makeCommand(const Utils::Environment &environment) const override;
|
||||
Utils::FilePath compilerCommand() const override;
|
||||
QList<Utils::OutputLineParser *> createOutputParsers() const override;
|
||||
|
||||
QString varsBatArg() const { return m_varsBatArg; }
|
||||
@@ -170,7 +169,7 @@ public:
|
||||
bool isValid() const override;
|
||||
QStringList suggestedMkspecList() const override;
|
||||
void addToEnvironment(Utils::Environment &env) const override;
|
||||
Utils::FilePath compilerCommand() const override;
|
||||
Utils::FilePath compilerCommand() const override; // FIXME: Remove.
|
||||
QList<Utils::OutputLineParser *> createOutputParsers() const override;
|
||||
QVariantMap toMap() const override;
|
||||
bool fromMap(const QVariantMap &data) override;
|
||||
|
@@ -39,6 +39,8 @@
|
||||
#include <QFileInfo>
|
||||
#include <QUuid>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
static const char ID_KEY[] = "ProjectExplorer.ToolChain.Id";
|
||||
static const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ToolChain.DisplayName";
|
||||
static const char AUTODETECT_KEY[] = "ProjectExplorer.ToolChain.Autodetect";
|
||||
@@ -69,6 +71,8 @@ public:
|
||||
}
|
||||
|
||||
QByteArray m_id;
|
||||
FilePath m_compilerCommand;
|
||||
QString m_compilerCommandKey;
|
||||
Abi m_targetAbi;
|
||||
QString m_targetAbiKey;
|
||||
QSet<Utils::Id> m_supportedLanguages;
|
||||
@@ -210,6 +214,8 @@ QVariantMap ToolChain::toMap() const
|
||||
result.insert(QLatin1String(LANGUAGE_KEY_V2), language().toSetting());
|
||||
if (!d->m_targetAbiKey.isEmpty())
|
||||
result.insert(d->m_targetAbiKey, d->m_targetAbi.toString());
|
||||
if (!d->m_compilerCommandKey.isEmpty())
|
||||
result.insert(d->m_compilerCommandKey, d->m_compilerCommand.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -262,6 +268,24 @@ void ToolChain::setTargetAbiKey(const QString &abiKey)
|
||||
d->m_targetAbiKey = abiKey;
|
||||
}
|
||||
|
||||
FilePath ToolChain::compilerCommand() const
|
||||
{
|
||||
return d->m_compilerCommand;
|
||||
}
|
||||
|
||||
void ToolChain::setCompilerCommand(const FilePath &command)
|
||||
{
|
||||
if (command == d->m_compilerCommand)
|
||||
return;
|
||||
d->m_compilerCommand = command;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
void ToolChain::setCompilerCommandKey(const QString &commandKey)
|
||||
{
|
||||
d->m_compilerCommandKey = commandKey;
|
||||
}
|
||||
|
||||
void ToolChain::setTypeDisplayName(const QString &typeName)
|
||||
{
|
||||
d->m_typeDisplayName = typeName;
|
||||
@@ -304,6 +328,8 @@ bool ToolChain::fromMap(const QVariantMap &data)
|
||||
if (!d->m_targetAbiKey.isEmpty())
|
||||
d->m_targetAbi = Abi::fromString(data.value(d->m_targetAbiKey).toString());
|
||||
|
||||
d->m_compilerCommand = FilePath::fromString(data.value(d->m_compilerCommandKey).toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -137,7 +137,9 @@ public:
|
||||
|
||||
Utils::Id language() const;
|
||||
|
||||
virtual Utils::FilePath compilerCommand() const = 0;
|
||||
virtual Utils::FilePath compilerCommand() const; // FIXME: De-virtualize.
|
||||
void setCompilerCommand(const Utils::FilePath &command);
|
||||
|
||||
virtual QList<Utils::OutputLineParser *> createOutputParsers() const = 0;
|
||||
|
||||
virtual bool operator ==(const ToolChain &) const;
|
||||
@@ -166,6 +168,8 @@ protected:
|
||||
void setTargetAbiNoSignal(const Abi &abi);
|
||||
void setTargetAbiKey(const QString &abiKey);
|
||||
|
||||
void setCompilerCommandKey(const QString &commandKey);
|
||||
|
||||
const MacrosCache &predefinedMacrosCache() const;
|
||||
const HeaderPathsCache &headerPathsCache() const;
|
||||
|
||||
|
@@ -308,6 +308,7 @@ public:
|
||||
setLanguage(Constants::CXX_LANGUAGE_ID);
|
||||
setTypeDisplayName("Test Tool Chain");
|
||||
setTargetAbiNoSignal(Abi::hostAbi());
|
||||
setCompilerCommand(FilePath::fromString("/tmp/test/gcc"));
|
||||
}
|
||||
|
||||
static QList<TTC *> toolChains() { return m_toolChains; }
|
||||
@@ -323,7 +324,6 @@ public:
|
||||
{ Q_UNUSED(cxxflags) Q_UNUSED(sysRoot) return {}; }
|
||||
void addToEnvironment(Environment &env) const override { Q_UNUSED(env) }
|
||||
FilePath makeCommand(const Environment &) const override { return FilePath::fromString("make"); }
|
||||
FilePath compilerCommand() const override { return Utils::FilePath::fromString("/tmp/test/gcc"); }
|
||||
QList<OutputLineParser *> createOutputParsers() const override { return {}; }
|
||||
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override { return nullptr; }
|
||||
bool operator ==(const ToolChain &other) const override {
|
||||
|
Reference in New Issue
Block a user