From 9f88fc881f671d20170dc7463194f12530dfceda Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 16 Aug 2019 13:04:41 +0200 Subject: [PATCH] GenericProjectManager: Support framework paths Rather than adding yet another meta file, we use the .includes file with a special line prefix. Fixes: QTCREATORBUG-20099 Change-Id: I494e0143b8e0f1f8828a56d7487b2201f1680337 Reviewed-by: Eike Ziller --- .../creator-projects-generic.qdoc | 6 ++++-- .../genericprojectmanager/genericproject.cpp | 21 ++++++++++++++++--- .../genericprojectmanager/genericproject.h | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/src/projects/creator-only/creator-projects-generic.qdoc b/doc/src/projects/creator-only/creator-projects-generic.qdoc index 7c1f06ec35d..8ec7958d0eb 100644 --- a/doc/src/projects/creator-only/creator-projects-generic.qdoc +++ b/doc/src/projects/creator-only/creator-projects-generic.qdoc @@ -65,7 +65,7 @@ \li \l{Specifying Files}{.files} - \li \l{Specifying Include Paths}{.includes} + \li \l{Specifying Include Paths and Framework Paths}{.includes} \li \l{Specifying Defines}{.config} @@ -114,12 +114,14 @@ git ls-files "*.cpp" "*.h" > MyProject.files \endcode - \section1 Specifying Include Paths + \section1 Specifying Include Paths and Framework Paths The include paths are specified in the \tt{.includes} file, one include path per line. The paths can be either absolute or relative to the \tt{.includes} file. + Lines starting with "-F" are interpreted as framework paths. + \section1 Specifying Defines The defines are specified in the \tt{.config} file. The \tt{.config} file is diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index 9a1d7b130d1..3ce786124d1 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -291,7 +291,8 @@ bool GenericProject::addFiles(const QStringList &filePaths) for (const QString &filePath : filePaths) insertSorted(&newList, baseDir.relativeFilePath(filePath)); - const QSet includes = Utils::toSet(m_projectIncludePaths); + const auto includes = transform>(m_projectIncludePaths, + [](const HeaderPath &hp) { return hp.path; }); QSet toAdd; for (const QString &filePath : filePaths) { @@ -375,7 +376,21 @@ void GenericProject::parseProject(RefreshOptions options) if (options & Configuration) { m_rawProjectIncludePaths = readLines(m_includesFileName); - m_projectIncludePaths = processEntries(m_rawProjectIncludePaths); + QStringList normalPaths; + QStringList frameworkPaths; + for (const QString &rawPath : m_rawProjectIncludePaths) { + if (rawPath.startsWith("-F")) + frameworkPaths << rawPath.mid(2); + else + normalPaths << rawPath; + } + const auto stringsToHeaderPaths = [this](const QStringList &paths, HeaderPathType type) { + return transform(processEntries(paths), + [type](const QString &p) { return HeaderPath(p, type); + }); + }; + m_projectIncludePaths = stringsToHeaderPaths(normalPaths, HeaderPathType::User); + m_projectIncludePaths << stringsToHeaderPaths(frameworkPaths, HeaderPathType::Framework); m_cxxflags = readFlags(m_cxxflagsFileName); m_cflags = readFlags(m_cflagsFileName); @@ -499,7 +514,7 @@ void GenericProject::refreshCppCodeModel() rpp.setDisplayName(displayName()); rpp.setProjectFileLocation(projectFilePath().toString()); rpp.setQtVersion(kitInfo.projectPartQtVersion); - rpp.setIncludePaths(m_projectIncludePaths); + rpp.setHeaderPaths(m_projectIncludePaths); rpp.setConfigFileName(m_configFileName); rpp.setFlagsForCxx({nullptr, m_cxxflags}); rpp.setFlagsForC({nullptr, m_cflags}); diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h index 2072558f551..be1de1606e4 100644 --- a/src/plugins/genericprojectmanager/genericproject.h +++ b/src/plugins/genericprojectmanager/genericproject.h @@ -25,6 +25,7 @@ #pragma once +#include #include #include @@ -82,7 +83,7 @@ private: QStringList m_files; QHash m_rawListEntries; QStringList m_rawProjectIncludePaths; - QStringList m_projectIncludePaths; + ProjectExplorer::HeaderPaths m_projectIncludePaths; QStringList m_cxxflags; QStringList m_cflags;