Commit def23121 authored by Daniel Mensinger's avatar Daniel Mensinger
Browse files

meson: Added project info introspection support

parent bf9c6a0d
......@@ -9,6 +9,7 @@ set(mesonbuilder_SRCS
mintro/mesonintrospectjob.cpp
mintro/mesonoptions.cpp
mintro/mesonprojectinfo.cpp
mintro/mesontargets.cpp
mintro/mesontests.cpp
......
......@@ -265,9 +265,9 @@ KJob* MesonManager::createImportJob(ProjectFolderItem* item)
}
}
auto introJob
= new MesonIntrospectJob(project, buildDir, { MesonIntrospectJob::TARGETS, MesonIntrospectJob::TESTS },
MesonIntrospectJob::BUILD_DIR, this);
auto introJob = new MesonIntrospectJob(
project, buildDir, { MesonIntrospectJob::TARGETS, MesonIntrospectJob::TESTS, MesonIntrospectJob::PROJECTINFO },
MesonIntrospectJob::BUILD_DIR, this);
KDirWatchPtr watcher = m_projectWatchers[project];
if (!watcher) {
......
......@@ -24,8 +24,8 @@
#include "mesonoptions.h"
#include <debug.h>
#include <KProcess>
#include <KLocalizedString>
#include <KProcess>
#include <QDir>
#include <QJsonArray>
......@@ -219,6 +219,14 @@ QString MesonIntrospectJob::import(BuildDir buildDir)
}
}
auto projectInfoJSON = rawData[QStringLiteral("projectinfo")];
if (projectInfoJSON.isObject()) {
m_res_projectInfo = std::make_shared<MesonProjectInfo>(projectInfoJSON.toObject());
if (!m_res_projectInfo) {
qCWarning(KDEV_Meson) << "MINTRO: Failed to parse projectinfo";
}
}
auto targetsJSON = rawData[QStringLiteral("targets")];
if (targetsJSON.isArray()) {
m_res_targets = std::make_shared<MesonTargets>(targetsJSON.toArray());
......@@ -271,6 +279,11 @@ MesonOptsPtr MesonIntrospectJob::buildOptions()
return m_res_options;
}
MesonProjectInfoPtr MesonIntrospectJob::projectInfo()
{
return m_res_projectInfo;
}
MesonTargetsPtr MesonIntrospectJob::targets()
{
return m_res_targets;
......
......@@ -21,6 +21,7 @@
#include "mesonconfig.h"
#include "mesonoptions.h"
#include "mesonprojectinfo.h"
#include "mesontargets.h"
#include "mesontests.h"
......@@ -55,6 +56,7 @@ public:
QString getTypeString(Type type) const;
MesonOptsPtr buildOptions();
MesonProjectInfoPtr projectInfo();
MesonTargetsPtr targets();
MesonTestSuitesPtr tests();
......@@ -75,6 +77,7 @@ private:
// The results
MesonOptsPtr m_res_options = nullptr;
MesonProjectInfoPtr m_res_projectInfo = nullptr;
MesonTargetsPtr m_res_targets = nullptr;
MesonTestSuitesPtr m_res_tests = nullptr;
};
/* This file is part of KDevelop
Copyright 2019 Daniel Mensinger <daniel@mensinger-ka.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mesonprojectinfo.h"
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonValue>
#include <debug.h>
MesonProjectInfo::MesonProjectInfo(const QJsonObject& json)
{
fromJSON(json);
}
MesonProjectInfo::~MesonProjectInfo() {}
void MesonProjectInfo::fromJSON(const QJsonObject& json)
{
m_name = json[QStringLiteral("descriptive_name")].toString();
m_version = json[QStringLiteral("version")].toString();
qCDebug(KDEV_Meson) << "MINTRO: Meson project" << m_name << "version" << m_version << "info loaded";
}
QString MesonProjectInfo::name() const
{
return m_name;
}
QString MesonProjectInfo::version() const
{
return m_version;
}
/* This file is part of KDevelop
Copyright 2019 Daniel Mensinger <daniel@mensinger-ka.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include <QString>
#include <memory>
class MesonProjectInfo;
class QJsonObject;
using MesonProjectInfoPtr = std::shared_ptr<MesonProjectInfo>;
class MesonProjectInfo
{
public:
explicit MesonProjectInfo(QJsonObject const& json);
virtual ~MesonProjectInfo();
void fromJSON(QJsonObject const& json);
QString name() const;
QString version() const;
private:
QString m_name;
QString m_version;
};
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