forked from qt-creator/qt-creator
Meson: Hide versionNumber() in cpp and make it static
Change-Id: I0132de7b6a7df7dd5d6ae4f1ddef52d5af33729a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -5,13 +5,10 @@
|
|||||||
|
|
||||||
#include "buildoptions.h"
|
#include "buildoptions.h"
|
||||||
#include "buildoptionsparser.h"
|
#include "buildoptionsparser.h"
|
||||||
#include "common.h"
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QVersionNumber>
|
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace MesonProjectManager::Internal::MesonInfoParser {
|
namespace MesonProjectManager::Internal::MesonInfoParser {
|
||||||
@@ -123,16 +120,6 @@ struct Result
|
|||||||
Utils::FilePaths buildSystemFiles;
|
Utils::FilePaths buildSystemFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QVersionNumber versionNumber(const Utils::FilePath &buildDir)
|
|
||||||
{
|
|
||||||
const Utils::FilePath jsonFile = buildDir / Constants::MESON_INFO_DIR / Constants::MESON_INFO;
|
|
||||||
auto obj = load<QJsonObject>(jsonFile.toFSPathString());
|
|
||||||
if (!obj)
|
|
||||||
return {};
|
|
||||||
auto version = obj->value("meson_version").toObject();
|
|
||||||
return {version["major"].toInt(), version["minor"].toInt(), version["patch"].toInt()};
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Result parse(const Utils::FilePath &buildDir)
|
inline Result parse(const Utils::FilePath &buildDir)
|
||||||
{
|
{
|
||||||
return {TargetParser::targetList(buildDir),
|
return {TargetParser::targetList(buildDir),
|
||||||
|
|||||||
@@ -307,9 +307,19 @@ bool MesonProjectParser::matchesKit(const KitData &kit)
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QVersionNumber versionNumber(const FilePath &buildDir)
|
||||||
|
{
|
||||||
|
const Utils::FilePath jsonFile = buildDir / Constants::MESON_INFO_DIR / Constants::MESON_INFO;
|
||||||
|
auto obj = load<QJsonObject>(jsonFile.toFSPathString());
|
||||||
|
if (!obj)
|
||||||
|
return {};
|
||||||
|
auto version = obj->value("meson_version").toObject();
|
||||||
|
return {version["major"].toInt(), version["minor"].toInt(), version["patch"].toInt()};
|
||||||
|
}
|
||||||
|
|
||||||
bool MesonProjectParser::usesSameMesonVersion(const FilePath &buildPath)
|
bool MesonProjectParser::usesSameMesonVersion(const FilePath &buildPath)
|
||||||
{
|
{
|
||||||
auto version = MesonInfoParser::versionNumber(buildPath);
|
auto version = versionNumber(buildPath);
|
||||||
auto meson = MesonTools::toolById(m_meson, ToolType::Meson);
|
auto meson = MesonTools::toolById(m_meson, ToolType::Meson);
|
||||||
return !version.isNull() && meson && version == meson->version();
|
return !version.isNull() && meson && version == meson->version();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user