forked from qt-creator/qt-creator
Meson: Use Utils::FilePaths in parser
Change-Id: Idb256110e519c642420580ebd159bcffa11c0f1b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -17,41 +17,5 @@
|
|||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BuildSystemFilesParser
|
|
||||||
{
|
|
||||||
std::vector<Utils::FilePath> m_files;
|
|
||||||
static void appendFiles(const std::optional<QJsonArray> &arr, std::vector<Utils::FilePath> &dest)
|
|
||||||
{
|
|
||||||
if (arr)
|
|
||||||
std::transform(std::cbegin(*arr),
|
|
||||||
std::cend(*arr),
|
|
||||||
std::back_inserter(dest),
|
|
||||||
[](const auto &file) {
|
|
||||||
return Utils::FilePath::fromString(file.toString());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
BuildSystemFilesParser(const Utils::FilePath &buildDir)
|
|
||||||
{
|
|
||||||
Utils::FilePath path = buildDir / Constants::MESON_INFO_DIR / Constants::MESON_INTRO_BUILDSYSTEM_FILES;
|
|
||||||
auto arr = load<QJsonArray>(path.toFSPathString());
|
|
||||||
appendFiles(arr, m_files);
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildSystemFilesParser(const QJsonDocument &js)
|
|
||||||
{
|
|
||||||
auto arr = get<QJsonArray>(js.object(), "projectinfo", "buildsystem_files");
|
|
||||||
appendFiles(arr, m_files);
|
|
||||||
const auto subprojects = get<QJsonArray>(js.object(), "projectinfo", "subprojects");
|
|
||||||
for (const auto &subproject : *subprojects) {
|
|
||||||
auto arr = get<QJsonArray>(subproject.toObject(), "buildsystem_files");
|
|
||||||
appendFiles(arr, m_files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Utils::FilePath> files() { return m_files; };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace MesonProjectManager
|
} // namespace MesonProjectManager
|
||||||
|
|||||||
@@ -81,12 +81,49 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BuildSystemFilesParser
|
||||||
|
{
|
||||||
|
static void appendFiles(const std::optional<QJsonArray> &arr, Utils::FilePaths &dest)
|
||||||
|
{
|
||||||
|
if (arr)
|
||||||
|
std::transform(std::cbegin(*arr),
|
||||||
|
std::cend(*arr),
|
||||||
|
std::back_inserter(dest),
|
||||||
|
[](const auto &file) {
|
||||||
|
return Utils::FilePath::fromString(file.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline Utils::FilePaths files(const Utils::FilePath &buildDir)
|
||||||
|
{
|
||||||
|
Utils::FilePaths files;
|
||||||
|
Utils::FilePath path = buildDir / Constants::MESON_INFO_DIR / Constants::MESON_INTRO_BUILDSYSTEM_FILES;
|
||||||
|
auto arr = load<QJsonArray>(path.toFSPathString());
|
||||||
|
appendFiles(arr, files);
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Utils::FilePaths files(const QJsonDocument &js)
|
||||||
|
{
|
||||||
|
Utils::FilePaths files;
|
||||||
|
auto arr = get<QJsonArray>(js.object(), "projectinfo", "buildsystem_files");
|
||||||
|
appendFiles(arr, files);
|
||||||
|
const auto subprojects = get<QJsonArray>(js.object(), "projectinfo", "subprojects");
|
||||||
|
for (const auto &subproject : *subprojects) {
|
||||||
|
auto arr = get<QJsonArray>(subproject.toObject(), "buildsystem_files");
|
||||||
|
appendFiles(arr, files);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Result
|
struct Result
|
||||||
{
|
{
|
||||||
TargetsList targets;
|
TargetsList targets;
|
||||||
BuildOptionsList buildOptions;
|
BuildOptionsList buildOptions;
|
||||||
std::vector<Utils::FilePath> buildSystemFiles;
|
Utils::FilePaths buildSystemFiles;
|
||||||
std::optional<MesonInfo> mesonInfo;
|
std::optional<MesonInfo> mesonInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +131,7 @@ inline Result parse(const Utils::FilePath &buildDir)
|
|||||||
{
|
{
|
||||||
return {TargetParser::targetList(buildDir),
|
return {TargetParser::targetList(buildDir),
|
||||||
BuildOptionsParser{buildDir}.takeBuildOptions(),
|
BuildOptionsParser{buildDir}.takeBuildOptions(),
|
||||||
BuildSystemFilesParser{buildDir}.files(),
|
BuildSystemFilesParser::files(buildDir),
|
||||||
InfoParser{buildDir}.info()};
|
InfoParser{buildDir}.info()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +140,7 @@ inline Result parse(const QByteArray &data)
|
|||||||
auto json = QJsonDocument::fromJson(data);
|
auto json = QJsonDocument::fromJson(data);
|
||||||
return {TargetParser::targetList(json),
|
return {TargetParser::targetList(json),
|
||||||
BuildOptionsParser{json}.takeBuildOptions(),
|
BuildOptionsParser{json}.takeBuildOptions(),
|
||||||
BuildSystemFilesParser{json}.files(),
|
BuildSystemFilesParser::files(json),
|
||||||
std::nullopt};
|
std::nullopt};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void addOptionsFile(std::unique_ptr<MesonProjectNode> &project)
|
|||||||
|
|
||||||
std::unique_ptr<MesonProjectNode> ProjectTree::buildTree(const Utils::FilePath &srcDir,
|
std::unique_ptr<MesonProjectNode> ProjectTree::buildTree(const Utils::FilePath &srcDir,
|
||||||
const TargetsList &targets,
|
const TargetsList &targets,
|
||||||
const std::vector<Utils::FilePath> &bsFiles)
|
const Utils::FilePaths &bsFiles)
|
||||||
{
|
{
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
std::set<Utils::FilePath> targetPaths;
|
std::set<Utils::FilePath> targetPaths;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
ProjectTree();
|
ProjectTree();
|
||||||
static std::unique_ptr<MesonProjectNode> buildTree(const Utils::FilePath &srcDir,
|
static std::unique_ptr<MesonProjectNode> buildTree(const Utils::FilePath &srcDir,
|
||||||
const TargetsList &targets,
|
const TargetsList &targets,
|
||||||
const std::vector<Utils::FilePath> &bsFiles);
|
const Utils::FilePaths &bsFiles);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user