forked from qt-creator/qt-creator
CppTools: De-duplicate code for CppProjectUpdater
Centralize gathering the kit, toolchains and qt version. Change-Id: I6bd586ac7925e2ee556fd119f1dab096cd500e41 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -256,37 +257,19 @@ static QStringList filterIncludes(const QString &absSrc, const QString &absBuild
|
|||||||
|
|
||||||
void AutotoolsProject::updateCppCodeModel()
|
void AutotoolsProject::updateCppCodeModel()
|
||||||
{
|
{
|
||||||
const Kit *k = nullptr;
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
if (Target *target = activeTarget())
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
k = target->kit();
|
|
||||||
else
|
|
||||||
k = KitManager::defaultKit();
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
|
|
||||||
ToolChain *cToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
||||||
ToolChain *cxxToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
||||||
|
|
||||||
CppTools::RawProjectPart rpp;
|
CppTools::RawProjectPart rpp;
|
||||||
rpp.setDisplayName(displayName());
|
rpp.setDisplayName(displayName());
|
||||||
rpp.setProjectFileLocation(projectFilePath().toString());
|
rpp.setProjectFileLocation(projectFilePath().toString());
|
||||||
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
|
|
||||||
if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k)) {
|
|
||||||
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt4;
|
|
||||||
else
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt5;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpp.setQtVersion(activeQtVersion);
|
|
||||||
const QStringList cflags = m_makefileParserThread->cflags();
|
const QStringList cflags = m_makefileParserThread->cflags();
|
||||||
QStringList cxxflags = m_makefileParserThread->cxxflags();
|
QStringList cxxflags = m_makefileParserThread->cxxflags();
|
||||||
if (cxxflags.isEmpty())
|
if (cxxflags.isEmpty())
|
||||||
cxxflags = cflags;
|
cxxflags = cflags;
|
||||||
rpp.setFlagsForC({cToolChain, cflags});
|
rpp.setFlagsForC({kitInfo.cToolChain, cflags});
|
||||||
rpp.setFlagsForCxx({cxxToolChain, cxxflags});
|
rpp.setFlagsForCxx({kitInfo.cxxToolChain, cxxflags});
|
||||||
|
|
||||||
const QString absSrc = projectDirectory().toString();
|
const QString absSrc = projectDirectory().toString();
|
||||||
const Target *target = activeTarget();
|
const Target *target = activeTarget();
|
||||||
@@ -297,5 +280,6 @@ void AutotoolsProject::updateCppCodeModel()
|
|||||||
rpp.setMacros(m_makefileParserThread->macros());
|
rpp.setMacros(m_makefileParserThread->macros());
|
||||||
rpp.setFiles(m_files);
|
rpp.setFiles(m_files);
|
||||||
|
|
||||||
m_cppCodeModelUpdater->update({this, cToolChain, cxxToolChain, k, {rpp}});
|
m_cppCodeModelUpdater->update(
|
||||||
|
{this, kitInfo.cToolChain, kitInfo.cxxToolChain, kitInfo.kit, {rpp}});
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
|
||||||
@@ -264,9 +265,6 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
QTC_ASSERT(bc == aBc, return);
|
QTC_ASSERT(bc == aBc, return);
|
||||||
QTC_ASSERT(m_treeScanner.isFinished() && !m_buildDirManager.isParsing(), return);
|
QTC_ASSERT(m_treeScanner.isFinished() && !m_buildDirManager.isParsing(), return);
|
||||||
|
|
||||||
Target *t = bc->target();
|
|
||||||
Kit *k = t->kit();
|
|
||||||
|
|
||||||
bc->setBuildTargets(m_buildDirManager.takeBuildTargets());
|
bc->setBuildTargets(m_buildDirManager.takeBuildTargets());
|
||||||
bc->setConfigurationFromCMake(m_buildDirManager.takeCMakeConfiguration());
|
bc->setConfigurationFromCMake(m_buildDirManager.takeCMakeConfiguration());
|
||||||
|
|
||||||
@@ -276,6 +274,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
setRootProjectNode(std::move(newRoot));
|
setRootProjectNode(std::move(newRoot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Target *t = bc->target();
|
||||||
t->setApplicationTargets(bc->appTargets());
|
t->setApplicationTargets(bc->appTargets());
|
||||||
t->setDeploymentData(bc->deploymentData());
|
t->setDeploymentData(bc->deploymentData());
|
||||||
|
|
||||||
@@ -283,30 +282,22 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
|
|
||||||
createGeneratedCodeModelSupport();
|
createGeneratedCodeModelSupport();
|
||||||
|
|
||||||
ToolChain *tcC = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
ToolChain *tcCxx = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
|
|
||||||
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
|
|
||||||
if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k)) {
|
|
||||||
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt4;
|
|
||||||
else
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt5;
|
|
||||||
}
|
|
||||||
|
|
||||||
CppTools::RawProjectParts rpps;
|
CppTools::RawProjectParts rpps;
|
||||||
m_buildDirManager.updateCodeModel(rpps);
|
m_buildDirManager.updateCodeModel(rpps);
|
||||||
|
|
||||||
for (CppTools::RawProjectPart &rpp : rpps) {
|
for (CppTools::RawProjectPart &rpp : rpps) {
|
||||||
// TODO: Set the Qt version only if target actually depends on Qt.
|
rpp.setQtVersion(kitInfo.projectPartQtVersion); // TODO: Check if project actually uses Qt.
|
||||||
rpp.setQtVersion(activeQtVersion);
|
if (kitInfo.cxxToolChain)
|
||||||
if (tcCxx)
|
rpp.setFlagsForCxx({kitInfo.cxxToolChain, rpp.flagsForCxx.commandLineFlags});
|
||||||
rpp.setFlagsForCxx({tcCxx, rpp.flagsForCxx.commandLineFlags});
|
if (kitInfo.cToolChain)
|
||||||
if (tcC)
|
rpp.setFlagsForC({kitInfo.cToolChain, rpp.flagsForC.commandLineFlags});
|
||||||
rpp.setFlagsForC({tcC, rpp.flagsForC.commandLineFlags});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cppCodeModelUpdater->update({this, tcC, tcCxx, k, rpps});
|
m_cppCodeModelUpdater->update(
|
||||||
|
{this, kitInfo.cToolChain, kitInfo.cxxToolChain, kitInfo.kit, rpps});
|
||||||
|
|
||||||
updateQmlJSCodeModel();
|
updateQmlJSCodeModel();
|
||||||
|
|
||||||
|
61
src/plugins/cpptools/cppkitinfo.cpp
Normal file
61
src/plugins/cpptools/cppkitinfo.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cppkitinfo.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/kitmanager.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
namespace CppTools {
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
|
KitInfo::KitInfo(Project *project)
|
||||||
|
{
|
||||||
|
// Kit
|
||||||
|
if (Target *target = project->activeTarget())
|
||||||
|
kit = target->kit();
|
||||||
|
else
|
||||||
|
kit = KitManager::defaultKit();
|
||||||
|
|
||||||
|
// Toolchains
|
||||||
|
if (kit) {
|
||||||
|
cToolChain = ToolChainKitInformation::toolChain(kit, Constants::C_LANGUAGE_ID);
|
||||||
|
cxxToolChain = ToolChainKitInformation::toolChain(kit, Constants::CXX_LANGUAGE_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KitInfo::isValid() const
|
||||||
|
{
|
||||||
|
return kit;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CppTools
|
54
src/plugins/cpptools/cppkitinfo.h
Normal file
54
src/plugins/cpptools/cppkitinfo.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "projectpart.h"
|
||||||
|
|
||||||
|
#include "cpptools_global.h"
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
class Project;
|
||||||
|
class ToolChain;
|
||||||
|
} // namespace ProjectExplorer
|
||||||
|
|
||||||
|
namespace CppTools {
|
||||||
|
|
||||||
|
class CPPTOOLS_EXPORT KitInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KitInfo(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
ProjectExplorer::Kit *kit = nullptr;
|
||||||
|
ProjectExplorer::ToolChain *cToolChain = nullptr;
|
||||||
|
ProjectExplorer::ToolChain *cxxToolChain = nullptr;
|
||||||
|
|
||||||
|
ProjectPart::QtVersion projectPartQtVersion = ProjectPart::NoQt;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CppTools
|
@@ -102,7 +102,8 @@ HEADERS += \
|
|||||||
cpptools_clangtidychecks.h \
|
cpptools_clangtidychecks.h \
|
||||||
cppmodelmanagerinterface.h \
|
cppmodelmanagerinterface.h \
|
||||||
cppbuiltinmodelmanagersupport.h \
|
cppbuiltinmodelmanagersupport.h \
|
||||||
headerpathfilter.h
|
headerpathfilter.h \
|
||||||
|
cppkitinfo.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
abstracteditorsupport.cpp \
|
abstracteditorsupport.cpp \
|
||||||
@@ -189,7 +190,8 @@ SOURCES += \
|
|||||||
cppprojectpartchooser.cpp \
|
cppprojectpartchooser.cpp \
|
||||||
wrappablelineedit.cpp \
|
wrappablelineedit.cpp \
|
||||||
cppbuiltinmodelmanagersupport.cpp \
|
cppbuiltinmodelmanagersupport.cpp \
|
||||||
headerpathfilter.cpp
|
headerpathfilter.cpp \
|
||||||
|
cppkitinfo.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
clangdiagnosticconfigswidget.ui \
|
clangdiagnosticconfigswidget.ui \
|
||||||
|
@@ -115,6 +115,8 @@ Project {
|
|||||||
"cppincludesfilter.h",
|
"cppincludesfilter.h",
|
||||||
"cppindexingsupport.cpp",
|
"cppindexingsupport.cpp",
|
||||||
"cppindexingsupport.h",
|
"cppindexingsupport.h",
|
||||||
|
"cppkitinfo.cpp",
|
||||||
|
"cppkitinfo.h",
|
||||||
"cpplocalsymbols.cpp",
|
"cpplocalsymbols.cpp",
|
||||||
"cpplocalsymbols.h",
|
"cpplocalsymbols.h",
|
||||||
"cpplocatordata.cpp",
|
"cpplocatordata.cpp",
|
||||||
|
@@ -51,6 +51,7 @@
|
|||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -426,37 +427,19 @@ QStringList GenericProject::processEntries(const QStringList &paths,
|
|||||||
|
|
||||||
void GenericProject::refreshCppCodeModel()
|
void GenericProject::refreshCppCodeModel()
|
||||||
{
|
{
|
||||||
const Kit *k = nullptr;
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
if (Target *target = activeTarget())
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
k = target->kit();
|
|
||||||
else
|
|
||||||
k = KitManager::defaultKit();
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
|
|
||||||
ToolChain *cToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
||||||
ToolChain *cxxToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
||||||
|
|
||||||
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
|
|
||||||
if (QtSupport::BaseQtVersion *qtVersion =
|
|
||||||
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit())) {
|
|
||||||
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt4;
|
|
||||||
else
|
|
||||||
activeQtVersion = CppTools::ProjectPart::Qt5;
|
|
||||||
}
|
|
||||||
|
|
||||||
CppTools::RawProjectPart rpp;
|
CppTools::RawProjectPart rpp;
|
||||||
rpp.setDisplayName(displayName());
|
rpp.setDisplayName(displayName());
|
||||||
rpp.setProjectFileLocation(projectFilePath().toString());
|
rpp.setProjectFileLocation(projectFilePath().toString());
|
||||||
rpp.setQtVersion(activeQtVersion);
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
rpp.setIncludePaths(m_projectIncludePaths);
|
rpp.setIncludePaths(m_projectIncludePaths);
|
||||||
rpp.setConfigFileName(m_configFileName);
|
rpp.setConfigFileName(m_configFileName);
|
||||||
rpp.setFiles(m_files);
|
rpp.setFiles(m_files);
|
||||||
|
|
||||||
const CppTools::ProjectUpdateInfo projectInfoUpdate(this, cToolChain, cxxToolChain, k, {rpp});
|
m_cppCodeModelUpdater->update(
|
||||||
m_cppCodeModelUpdater->update(projectInfoUpdate);
|
{this, kitInfo.cToolChain, kitInfo.cxxToolChain, kitInfo.kit, {rpp}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::updateDeploymentData()
|
void GenericProject::updateDeploymentData()
|
||||||
|
@@ -59,6 +59,7 @@
|
|||||||
#include <projectexplorer/taskhub.h>
|
#include <projectexplorer/taskhub.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/headerpath.h>
|
#include <projectexplorer/headerpath.h>
|
||||||
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <cpptools/generatedcodemodelsupport.h>
|
#include <cpptools/generatedcodemodelsupport.h>
|
||||||
#include <qmljstools/qmljsmodelmanager.h>
|
#include <qmljstools/qmljsmodelmanager.h>
|
||||||
@@ -894,29 +895,6 @@ void QbsProject::updateCppCodeModel()
|
|||||||
if (!m_projectData.isValid())
|
if (!m_projectData.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Kit *k = nullptr;
|
|
||||||
if (Target *target = activeTarget())
|
|
||||||
k = target->kit();
|
|
||||||
else
|
|
||||||
k = KitManager::defaultKit();
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
|
|
||||||
ToolChain *cToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
||||||
ToolChain *cxxToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *qtVersion =
|
|
||||||
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit());
|
|
||||||
|
|
||||||
CppTools::ProjectPart::QtVersion qtVersionFromKit = CppTools::ProjectPart::NoQt;
|
|
||||||
if (qtVersion) {
|
|
||||||
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
||||||
qtVersionFromKit = CppTools::ProjectPart::Qt4;
|
|
||||||
else
|
|
||||||
qtVersionFromKit = CppTools::ProjectPart::Qt5;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ProjectExplorer::ExtraCompilerFactory *> factories =
|
QList<ProjectExplorer::ExtraCompilerFactory *> factories =
|
||||||
ProjectExplorer::ExtraCompilerFactory::extraCompilerFactories();
|
ProjectExplorer::ExtraCompilerFactory::extraCompilerFactories();
|
||||||
const auto factoriesBegin = factories.constBegin();
|
const auto factoriesBegin = factories.constBegin();
|
||||||
@@ -925,6 +903,9 @@ void QbsProject::updateCppCodeModel()
|
|||||||
qDeleteAll(m_extraCompilers);
|
qDeleteAll(m_extraCompilers);
|
||||||
m_extraCompilers.clear();
|
m_extraCompilers.clear();
|
||||||
|
|
||||||
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
|
|
||||||
CppTools::RawProjectParts rpps;
|
CppTools::RawProjectParts rpps;
|
||||||
foreach (const qbs::ProductData &prd, m_projectData.allProducts()) {
|
foreach (const qbs::ProductData &prd, m_projectData.allProducts()) {
|
||||||
QString cPch;
|
QString cPch;
|
||||||
@@ -951,7 +932,7 @@ void QbsProject::updateCppCodeModel()
|
|||||||
|
|
||||||
const CppTools::ProjectPart::QtVersion qtVersionForPart =
|
const CppTools::ProjectPart::QtVersion qtVersionForPart =
|
||||||
prd.moduleProperties().getModuleProperty("Qt.core", "version").isValid()
|
prd.moduleProperties().getModuleProperty("Qt.core", "version").isValid()
|
||||||
? qtVersionFromKit
|
? kitInfo.projectPartQtVersion
|
||||||
: CppTools::ProjectPart::NoQt;
|
: CppTools::ProjectPart::NoQt;
|
||||||
|
|
||||||
foreach (const qbs::GroupData &grp, prd.groups()) {
|
foreach (const qbs::GroupData &grp, prd.groups()) {
|
||||||
@@ -963,8 +944,8 @@ void QbsProject::updateCppCodeModel()
|
|||||||
QStringList cFlags;
|
QStringList cFlags;
|
||||||
QStringList cxxFlags;
|
QStringList cxxFlags;
|
||||||
getExpandedCompilerFlags(cFlags, cxxFlags, props);
|
getExpandedCompilerFlags(cFlags, cxxFlags, props);
|
||||||
rpp.setFlagsForC({cToolChain, cFlags});
|
rpp.setFlagsForC({kitInfo.cToolChain, cFlags});
|
||||||
rpp.setFlagsForCxx({cxxToolChain, cxxFlags});
|
rpp.setFlagsForCxx({kitInfo.cxxToolChain, cxxFlags});
|
||||||
|
|
||||||
QStringList list = props.getModulePropertiesAsStringList(
|
QStringList list = props.getModulePropertiesAsStringList(
|
||||||
QLatin1String(CONFIG_CPP_MODULE),
|
QLatin1String(CONFIG_CPP_MODULE),
|
||||||
@@ -1071,7 +1052,8 @@ void QbsProject::updateCppCodeModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
||||||
m_cppCodeModelUpdater->update({this, cToolChain, cxxToolChain, k, rpps});
|
m_cppCodeModelUpdater->update(
|
||||||
|
{this, kitInfo.cToolChain, kitInfo.cxxToolChain, kitInfo.kit, rpps});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsProject::updateQmlJsCodeModel()
|
void QbsProject::updateQmlJsCodeModel()
|
||||||
|
@@ -57,6 +57,7 @@
|
|||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <proparser/qmakevfs.h>
|
#include <proparser/qmakevfs.h>
|
||||||
#include <qtsupport/profilereader.h>
|
#include <qtsupport/profilereader.h>
|
||||||
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <qtsupport/qtversionmanager.h>
|
#include <qtsupport/qtversionmanager.h>
|
||||||
#include <cpptools/generatedcodemodelsupport.h>
|
#include <cpptools/generatedcodemodelsupport.h>
|
||||||
@@ -260,32 +261,12 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
|
|
||||||
m_toolChainWarnings.clear();
|
m_toolChainWarnings.clear();
|
||||||
|
|
||||||
const Kit *k = nullptr;
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
if (Target *target = activeTarget())
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
k = target->kit();
|
|
||||||
else
|
|
||||||
k = KitManager::defaultKit();
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
|
|
||||||
ToolChain *cToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
||||||
ToolChain *cxxToolChain
|
|
||||||
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
|
||||||
ProjectPart::QtVersion qtVersionForPart = ProjectPart::NoQt;
|
|
||||||
if (qtVersion) {
|
|
||||||
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
||||||
qtVersionForPart = ProjectPart::Qt4;
|
|
||||||
else
|
|
||||||
qtVersionForPart = ProjectPart::Qt5;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<QmakeProFile *> proFiles = rootProFile()->allProFiles();
|
|
||||||
|
|
||||||
QList<ProjectExplorer::ExtraCompiler *> generators;
|
QList<ProjectExplorer::ExtraCompiler *> generators;
|
||||||
CppTools::RawProjectParts rpps;
|
CppTools::RawProjectParts rpps;
|
||||||
for (const QmakeProFile *pro : proFiles) {
|
for (const QmakeProFile *pro : rootProFile()->allProFiles()) {
|
||||||
warnOnToolChainMismatch(pro);
|
warnOnToolChainMismatch(pro);
|
||||||
|
|
||||||
CppTools::RawProjectPart rpp;
|
CppTools::RawProjectPart rpp;
|
||||||
@@ -296,15 +277,15 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
rpp.setBuildTargetType(isExecutable ? CppTools::ProjectPart::Executable
|
rpp.setBuildTargetType(isExecutable ? CppTools::ProjectPart::Executable
|
||||||
: CppTools::ProjectPart::Library);
|
: CppTools::ProjectPart::Library);
|
||||||
|
|
||||||
rpp.setFlagsForCxx({cxxToolChain, pro->variableValue(Variable::CppFlags)});
|
rpp.setFlagsForCxx({kitInfo.cxxToolChain, pro->variableValue(Variable::CppFlags)});
|
||||||
rpp.setFlagsForC({cToolChain, pro->variableValue(Variable::CFlags)});
|
rpp.setFlagsForC({kitInfo.cToolChain, pro->variableValue(Variable::CFlags)});
|
||||||
rpp.setMacros(ProjectExplorer::Macro::toMacros(pro->cxxDefines()));
|
rpp.setMacros(ProjectExplorer::Macro::toMacros(pro->cxxDefines()));
|
||||||
rpp.setPreCompiledHeaders(pro->variableValue(Variable::PrecompiledHeader));
|
rpp.setPreCompiledHeaders(pro->variableValue(Variable::PrecompiledHeader));
|
||||||
rpp.setSelectedForBuilding(pro->includedInExactParse());
|
rpp.setSelectedForBuilding(pro->includedInExactParse());
|
||||||
|
|
||||||
// Qt Version
|
// Qt Version
|
||||||
if (pro->variableValue(Variable::Config).contains(QLatin1String("qt")))
|
if (pro->variableValue(Variable::Config).contains(QLatin1String("qt")))
|
||||||
rpp.setQtVersion(qtVersionForPart);
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
else
|
else
|
||||||
rpp.setQtVersion(ProjectPart::NoQt);
|
rpp.setQtVersion(ProjectPart::NoQt);
|
||||||
|
|
||||||
@@ -316,9 +297,8 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
headerPaths += headerPath;
|
headerPaths += headerPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qtVersion && !qtVersion->frameworkInstallPath().isEmpty()) {
|
if (kitInfo.qtVersion && !kitInfo.qtVersion->frameworkInstallPath().isEmpty())
|
||||||
headerPaths += {qtVersion->frameworkInstallPath(), HeaderPathType::Framework};
|
headerPaths += {kitInfo.qtVersion->frameworkInstallPath(), HeaderPathType::Framework};
|
||||||
}
|
|
||||||
rpp.setHeaderPaths(headerPaths);
|
rpp.setHeaderPaths(headerPaths);
|
||||||
|
|
||||||
// Files and generators
|
// Files and generators
|
||||||
@@ -343,7 +323,8 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CppTools::GeneratedCodeModelSupport::update(generators);
|
CppTools::GeneratedCodeModelSupport::update(generators);
|
||||||
m_cppCodeModelUpdater->update({this, cToolChain, cxxToolChain, k, rpps});
|
m_cppCodeModelUpdater->update(
|
||||||
|
{this, kitInfo.cToolChain, kitInfo.cxxToolChain, kitInfo.kit, rpps});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeProject::updateQmlJSCodeModel()
|
void QmakeProject::updateQmlJSCodeModel()
|
||||||
|
46
src/plugins/qtsupport/qtcppkitinfo.cpp
Normal file
46
src/plugins/qtsupport/qtcppkitinfo.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qtcppkitinfo.h"
|
||||||
|
|
||||||
|
#include "baseqtversion.h"
|
||||||
|
#include "qtkitinformation.h"
|
||||||
|
|
||||||
|
namespace QtSupport {
|
||||||
|
|
||||||
|
using namespace CppTools;
|
||||||
|
|
||||||
|
CppKitInfo::CppKitInfo(ProjectExplorer::Project *project)
|
||||||
|
: KitInfo(project)
|
||||||
|
{
|
||||||
|
if (kit && (qtVersion = QtKitInformation::qtVersion(kit))) {
|
||||||
|
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0))
|
||||||
|
projectPartQtVersion = ProjectPart::Qt4;
|
||||||
|
else
|
||||||
|
projectPartQtVersion = ProjectPart::Qt5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace QtSupport
|
44
src/plugins/qtsupport/qtcppkitinfo.h
Normal file
44
src/plugins/qtsupport/qtcppkitinfo.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "qtsupport_global.h"
|
||||||
|
|
||||||
|
#include <cpptools/cppkitinfo.h>
|
||||||
|
|
||||||
|
namespace QtSupport {
|
||||||
|
|
||||||
|
class BaseQtVersion;
|
||||||
|
|
||||||
|
class QTSUPPORT_EXPORT CppKitInfo : public CppTools::KitInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CppKitInfo(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
|
BaseQtVersion *qtVersion = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace QtSupport
|
@@ -11,6 +11,7 @@ HEADERS += \
|
|||||||
codegensettings.h \
|
codegensettings.h \
|
||||||
codegensettingspage.h \
|
codegensettingspage.h \
|
||||||
gettingstartedwelcomepage.h \
|
gettingstartedwelcomepage.h \
|
||||||
|
qtcppkitinfo.h \
|
||||||
qtprojectimporter.h \
|
qtprojectimporter.h \
|
||||||
qtsupportplugin.h \
|
qtsupportplugin.h \
|
||||||
qtsupport_global.h \
|
qtsupport_global.h \
|
||||||
@@ -38,6 +39,7 @@ SOURCES += \
|
|||||||
codegensettings.cpp \
|
codegensettings.cpp \
|
||||||
codegensettingspage.cpp \
|
codegensettingspage.cpp \
|
||||||
gettingstartedwelcomepage.cpp \
|
gettingstartedwelcomepage.cpp \
|
||||||
|
qtcppkitinfo.cpp \
|
||||||
qtprojectimporter.cpp \
|
qtprojectimporter.cpp \
|
||||||
qtsupportplugin.cpp \
|
qtsupportplugin.cpp \
|
||||||
qtkitconfigwidget.cpp \
|
qtkitconfigwidget.cpp \
|
||||||
|
@@ -63,6 +63,8 @@ Project {
|
|||||||
"codegensettingspagewidget.ui",
|
"codegensettingspagewidget.ui",
|
||||||
"qtconfigwidget.cpp",
|
"qtconfigwidget.cpp",
|
||||||
"qtconfigwidget.h",
|
"qtconfigwidget.h",
|
||||||
|
"qtcppkitinfo.cpp",
|
||||||
|
"qtcppkitinfo.h",
|
||||||
"qtprojectimporter.cpp",
|
"qtprojectimporter.cpp",
|
||||||
"qtprojectimporter.h",
|
"qtprojectimporter.h",
|
||||||
"qtsupport.qrc",
|
"qtsupport.qrc",
|
||||||
|
Reference in New Issue
Block a user