Commit 2fa15f22 authored by Erik Verbruggen's avatar Erik Verbruggen

QbsProject: put different languages into separate project parts.

This is in preparation for changes to the ProjectParts, where one part
can only hold files for 1 language.

Change-Id: If8a64895847806677d5cd51344ae774313798e00
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent b84a47ff
......@@ -90,7 +90,6 @@ static const char CONFIG_SYSTEM_INCLUDEPATHS[] = "systemIncludePaths";
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
static const char CONFIG_SYSTEM_FRAMEWORKPATHS[] = "systemFrameworkPaths";
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
static const char CONFIGURATION_PATH[] = "<configuration>";
// --------------------------------------------------------------------
// QbsProject:
......@@ -613,13 +612,8 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
if (!prj.isValid())
return;
Kit *k = 0;
QtSupport::BaseQtVersion *qtVersion = 0;
if (Target *target = activeTarget())
k = target->kit();
else
k = KitManager::defaultKit();
qtVersion = QtSupport::QtKitInformation::qtVersion(k);
QtSupport::BaseQtVersion *qtVersion =
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit());
CppTools::CppModelManagerInterface *modelmanager =
CppTools::CppModelManagerInterface::instance();
......@@ -629,28 +623,29 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
CppTools::ProjectInfo pinfo = modelmanager->projectInfo(this);
pinfo.clearProjectParts();
CppTools::ProjectPart::QtVersion qtVersionForPart
= CppTools::ProjectPart::NoQt;
CppTools::ProjectPartBuilder ppBuilder(pinfo);
if (qtVersion) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
qtVersionForPart = CppTools::ProjectPart::Qt4;
ppBuilder.setQtVersion(CppTools::ProjectPart::Qt4);
else
qtVersionForPart = CppTools::ProjectPart::Qt5;
ppBuilder.setQtVersion(CppTools::ProjectPart::Qt5);
} else {
ppBuilder.setQtVersion(CppTools::ProjectPart::NoQt);
}
QHash<QString, QString> uiFiles;
QStringList allFiles;
foreach (const qbs::ProductData &prd, prj.allProducts()) {
foreach (const qbs::GroupData &grp, prd.groups()) {
const qbs::PropertyMap &props = grp.properties();
const QStringList cxxFlags = props.getModulePropertiesAsStringList(
QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_CXXFLAGS));
const QStringList cFlags = props.getModulePropertiesAsStringList(
QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_CFLAGS));
ppBuilder.setCxxFlags(props.getModulePropertiesAsStringList(
QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_CXXFLAGS)));
ppBuilder.setCFlags(props.getModulePropertiesAsStringList(
QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_CFLAGS)));
QStringList list = props.getModulePropertiesAsStringList(
QLatin1String(CONFIG_CPP_MODULE),
......@@ -663,6 +658,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
data[pos] = ' ';
grpDefines += (QByteArray("#define ") + data + '\n');
}
ppBuilder.setDefines(grpDefines);
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_INCLUDEPATHS));
......@@ -683,22 +679,18 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
FileName::fromUserInput(p).toString(),
CppTools::ProjectPart::HeaderPath::FrameworkPath);
ppBuilder.setHeaderPaths(grpHeaderPaths);
const QString pch = props.getModuleProperty(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString();
ppBuilder.setPreCompiledHeaders(QStringList() << pch);
CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart);
part->project = this;
part->displayName = grp.name();
part->projectFile = QString::fromLatin1("%1:%2:%3")
ppBuilder.setDisplayName(grp.name());
ppBuilder.setProjectFile(QString::fromLatin1("%1:%2:%3")
.arg(grp.location().fileName())
.arg(grp.location().line())
.arg(grp.location().column());
part->evaluateToolchain(ToolChainKitInformation::toolChain(k),
cxxFlags,
cFlags,
SysRootKitInformation::sysRoot(k));
.arg(grp.location().column()));
CppTools::ProjectFileAdder adder(part->files);
foreach (const QString &file, grp.allFilePaths()) {
if (file.endsWith(QLatin1String(".ui"))) {
QStringList generated = m_rootProjectNode->qbsProject()
......@@ -706,22 +698,15 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
if (generated.count() == 1)
uiFiles.insert(file, generated.at(0));
}
if (adder.maybeAdd(file))
allFiles.append(file);
}
part->files << CppTools::ProjectFile(QLatin1String(CONFIGURATION_PATH),
CppTools::ProjectFile::CXXHeader);
part->qtVersion = qtVersionForPart;
part->headerPaths += grpHeaderPaths;
part->precompiledHeaders = QStringList(pch);
part->projectDefines += grpDefines;
pinfo.appendProjectPart(part);
const QList<Core::Id> languages =
ppBuilder.createProjectPartsForFiles(grp.allFilePaths());
foreach (Core::Id language, languages)
setProjectLanguage(language, true);
}
}
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
if (pinfo.projectParts().isEmpty())
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment