Meson: Get rid of MesonInfo, use QVersionNumber directly

Change-Id: I482cfdfe988c10e592b0f2bf106b6ace41cf44ad
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-07-25 07:21:33 +02:00
parent f9bb9feda4
commit 41bdcabe5f
6 changed files with 9 additions and 31 deletions

View File

@@ -18,7 +18,6 @@ add_qtc_plugin(MesonProjectManager
mesonbuildconfiguration.h mesonbuildconfiguration.h
mesonbuildsystem.cpp mesonbuildsystem.cpp
mesonbuildsystem.h mesonbuildsystem.h
mesoninfo.h
mesoninfoparser.h mesoninfoparser.h
mesonoutputparser.cpp mesonoutputparser.cpp
mesonoutputparser.h mesonoutputparser.h

View File

@@ -4,7 +4,6 @@
#pragma once #pragma once
#include "common.h" #include "common.h"
#include "mesoninfo.h"
#include "mesonpluginconstants.h" #include "mesonpluginconstants.h"
#include <QFile> #include <QFile>
@@ -12,19 +11,18 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonValue> #include <QJsonValue>
#include <QVersionNumber>
namespace MesonProjectManager::Internal { namespace MesonProjectManager::Internal {
class InfoParser class InfoParser
{ {
static inline MesonInfo load_info(const QJsonObject &obj) static inline QVersionNumber load_info(const QJsonObject &obj)
{ {
MesonInfo info; auto version = obj["meson_version"].toObject();
auto v = obj["meson_version"].toObject(); return {version["major"].toInt(), version["minor"].toInt(), version["patch"].toInt()};
info.mesonVersion = {v["major"].toInt(), v["minor"].toInt(), v["patch"].toInt()};
return info;
} }
MesonInfo m_info; QVersionNumber m_info;
public: public:
InfoParser(const Utils::FilePath &buildDir) InfoParser(const Utils::FilePath &buildDir)
@@ -35,7 +33,7 @@ public:
m_info = load_info(*obj); m_info = load_info(*obj);
} }
MesonInfo info() { return m_info; } QVersionNumber info() { return m_info; }
}; };
} // namespace MesonProjectManager::Internal } // namespace MesonProjectManager::Internal

View File

@@ -1,17 +0,0 @@
// Copyright (C) 2020 Alexis Jeandet.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QVersionNumber>
namespace MesonProjectManager {
namespace Internal {
struct MesonInfo
{
QVersionNumber mesonVersion;
};
} // namespace Internal
} // namespace MesonProjectManager

View File

@@ -6,7 +6,6 @@
#include "buildoptions.h" #include "buildoptions.h"
#include "buildoptionsparser.h" #include "buildoptionsparser.h"
#include "infoparser.h" #include "infoparser.h"
#include "mesoninfo.h"
#include "target.h" #include "target.h"
#include <utils/filepath.h> #include <utils/filepath.h>
@@ -123,7 +122,7 @@ struct Result
TargetsList targets; TargetsList targets;
BuildOptionsList buildOptions; BuildOptionsList buildOptions;
Utils::FilePaths buildSystemFiles; Utils::FilePaths buildSystemFiles;
std::optional<MesonInfo> mesonInfo; std::optional<QVersionNumber> mesonInfo;
}; };
inline Result parse(const Utils::FilePath &buildDir) inline Result parse(const Utils::FilePath &buildDir)
@@ -155,7 +154,7 @@ inline Result parse(QIODevice *introFile)
return {}; return {};
} }
inline std::optional<MesonInfo> mesonInfo(const Utils::FilePath &buildDir) inline std::optional<QVersionNumber> mesonInfo(const Utils::FilePath &buildDir)
{ {
return InfoParser{buildDir}.info(); return InfoParser{buildDir}.info();
} }

View File

@@ -24,7 +24,6 @@ Project {
"mesonactionsmanager.cpp", "mesonactionsmanager.cpp",
"mesonactionsmanager.h", "mesonactionsmanager.h",
"buildoptions.h", "buildoptions.h",
"mesoninfo.h",
"mesoninfoparser.h", "mesoninfoparser.h",
"buildoptionsparser.h", "buildoptionsparser.h",
"common.h", "common.h",

View File

@@ -311,7 +311,7 @@ bool MesonProjectParser::usesSameMesonVersion(const FilePath &buildPath)
{ {
auto info = MesonInfoParser::mesonInfo(buildPath); auto info = MesonInfoParser::mesonInfo(buildPath);
auto meson = MesonTools::toolById(m_meson, ToolType::Meson); auto meson = MesonTools::toolById(m_meson, ToolType::Meson);
return info && meson && info->mesonVersion == meson->version(); return info && meson && *info == meson->version();
} }
bool MesonProjectParser::run(const Command &command, bool MesonProjectParser::run(const Command &command,