summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-10-08 11:04:03 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-10-09 08:14:16 +0000
commit2a40c215e91ab739ed6e237f60424faa85e2cfd0 (patch)
treea0cc88a51ccc7c8ed8a731e91cbf1d4ccab85ec7 /src/plugins/cpptools
parent3c5dc450b8ec797ba625c1a208c458fee5bd8d2f (diff)
downloadqt-creator-2a40c215e91ab739ed6e237f60424faa85e2cfd0.tar.gz
CppTools: Inline ToolChainEvaluator
Change-Id: Ie5579820e4683a5e4d7d73034441d662e017b6a3 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppprojectinfogenerator.cpp126
1 files changed, 40 insertions, 86 deletions
diff --git a/src/plugins/cpptools/cppprojectinfogenerator.cpp b/src/plugins/cpptools/cppprojectinfogenerator.cpp
index 9eec00ed54..0eb1af9c6e 100644
--- a/src/plugins/cpptools/cppprojectinfogenerator.cpp
+++ b/src/plugins/cpptools/cppprojectinfogenerator.cpp
@@ -35,86 +35,6 @@
namespace CppTools {
namespace Internal {
-namespace {
-
-class ToolChainEvaluator
-{
-public:
- ToolChainEvaluator(ProjectPart &projectPart,
- Language language,
- const RawProjectPartFlags &flags,
- const ToolChainInfo &tcInfo)
- : m_projectPart(projectPart)
- , m_language(language)
- , m_flags(flags)
- , m_tcInfo(tcInfo)
- {
- }
-
- void evaluate()
- {
- m_projectPart.toolchainType = m_tcInfo.type;
- m_projectPart.isMsvc2015Toolchain = m_tcInfo.isMsvc2015ToolChain;
- m_projectPart.toolChainWordWidth = mapWordWith(m_tcInfo.wordWidth);
- m_projectPart.toolChainTargetTriple = m_tcInfo.targetTriple;
- m_projectPart.extraCodeModelFlags = m_tcInfo.extraCodeModelFlags;
-
- m_projectPart.warningFlags = m_flags.warningFlags;
-
- // For compilation database pass the command line flags directly.
- if (m_projectPart.toolchainType == ProjectExplorer::Constants::COMPILATION_DATABASE_TOOLCHAIN_TYPEID)
- m_projectPart.extraCodeModelFlags = m_flags.commandLineFlags;
-
- if (m_tcInfo.macroInspectionRunner) {
- auto macroInspectionReport = m_tcInfo.macroInspectionRunner(m_flags.commandLineFlags);
- m_projectPart.toolChainMacros = macroInspectionReport.macros;
- m_projectPart.languageVersion = macroInspectionReport.languageVersion;
- } else { // No compiler set in kit.
- if (m_language == Language::C)
- m_projectPart.languageVersion = ProjectExplorer::LanguageVersion::LatestC;
- else if (m_language == Language::Cxx)
- m_projectPart.languageVersion = ProjectExplorer::LanguageVersion::LatestCxx;
- }
-
- m_projectPart.languageExtensions = m_flags.languageExtensions;
-
- addHeaderPaths();
- }
-
-private:
- static ProjectPart::ToolChainWordWidth mapWordWith(unsigned wordWidth)
- {
- return wordWidth == 64
- ? ProjectPart::WordWidth64Bit
- : ProjectPart::WordWidth32Bit;
- }
-
- void addHeaderPaths()
- {
- if (!m_tcInfo.headerPathsRunner)
- return; // No compiler set in kit.
-
- const ProjectExplorer::HeaderPaths builtInHeaderPaths
- = m_tcInfo.headerPathsRunner(m_flags.commandLineFlags,
- m_tcInfo.sysRootPath);
-
- ProjectExplorer::HeaderPaths &headerPaths = m_projectPart.headerPaths;
- for (const ProjectExplorer::HeaderPath &header : builtInHeaderPaths) {
- const ProjectExplorer::HeaderPath headerPath{header.path, header.type};
- if (!headerPaths.contains(headerPath))
- headerPaths.push_back(headerPath);
- }
- }
-
-private:
- ProjectPart &m_projectPart;
- const Language m_language;
- const RawProjectPartFlags &m_flags;
- const ToolChainInfo &m_tcInfo;
-};
-
-} // anonymous namespace
-
ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<void> &futureInterface,
const ProjectUpdateInfo &projectUpdateInfo)
: m_futureInterface(futureInterface)
@@ -220,10 +140,6 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
Language language,
ProjectExplorer::LanguageExtensions languageExtensions)
{
- ProjectPart::Ptr part(templateProjectPart->copy());
- part->displayName = partName;
- part->files = projectFiles;
-
RawProjectPartFlags flags;
ToolChainInfo tcInfo;
if (language == Language::C) {
@@ -236,8 +152,46 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
tcInfo = m_projectUpdateInfo.cxxToolChainInfo;
}
// TODO: If no toolchain is set, show a warning
- ToolChainEvaluator evaluator(*part.data(), language, flags, tcInfo);
- evaluator.evaluate();
+
+ ProjectPart::Ptr part(templateProjectPart->copy());
+ part->displayName = partName;
+ part->files = projectFiles;
+ part->toolchainType = tcInfo.type;
+ part->isMsvc2015Toolchain = tcInfo.isMsvc2015ToolChain;
+ part->toolChainWordWidth = tcInfo.wordWidth == 64 ? ProjectPart::WordWidth64Bit
+ : ProjectPart::WordWidth32Bit;
+ part->toolChainTargetTriple = tcInfo.targetTriple;
+ part->extraCodeModelFlags = tcInfo.extraCodeModelFlags;
+ part->warningFlags = flags.warningFlags;
+ part->languageExtensions = flags.languageExtensions;
+
+ if (part->toolchainType == ProjectExplorer::Constants::COMPILATION_DATABASE_TOOLCHAIN_TYPEID)
+ part->extraCodeModelFlags = flags.commandLineFlags;
+
+ // Toolchain macros and language version
+ if (tcInfo.macroInspectionRunner) {
+ auto macroInspectionReport = tcInfo.macroInspectionRunner(flags.commandLineFlags);
+ part->toolChainMacros = macroInspectionReport.macros;
+ part->languageVersion = macroInspectionReport.languageVersion;
+ // No compiler set in kit.
+ } else if (language == Language::C) {
+ part->languageVersion = ProjectExplorer::LanguageVersion::LatestC;
+ } else {
+ part->languageVersion = ProjectExplorer::LanguageVersion::LatestCxx;
+ }
+
+ // Header paths
+ if (tcInfo.headerPathsRunner) {
+ const ProjectExplorer::HeaderPaths builtInHeaderPaths
+ = tcInfo.headerPathsRunner(flags.commandLineFlags, tcInfo.sysRootPath);
+
+ ProjectExplorer::HeaderPaths &headerPaths = part->headerPaths;
+ for (const ProjectExplorer::HeaderPath &header : builtInHeaderPaths) {
+ const ProjectExplorer::HeaderPath headerPath{header.path, header.type};
+ if (!headerPaths.contains(headerPath))
+ headerPaths.push_back(headerPath);
+ }
+ }
part->languageExtensions |= languageExtensions;
part->updateLanguageFeatures();