[gnome-builder/wip/gtk4-port: 1438/1774] plugins/valac: replace vala-pack with valac plugin




commit 065aae9a23d4a4fe72c8ac47a0973fd886eb5e34
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 9 09:41:11 2022 -0700

    plugins/valac: replace vala-pack with valac plugin
    
    This removes the vala-pack plugin which combined a pipeline error regex
    with an indenter. Since indenters will come from GtkSourceView in the
    GTK 4 port, we can just drop the indenter and focus on the error regex.
    
    That can be a more specialized "valac" plugin similar to the mono plugin
    for mcs/gmcs error output.

 meson_options.txt                            |   2 +-
 src/plugins/meson.build                      |   4 +-
 src/plugins/vala-pack/meson.build            |  13 ---
 src/plugins/vala-pack/vala-pack.plugin       |  11 ---
 src/plugins/vala-pack/vala_pack_plugin.py    | 136 ---------------------------
 src/plugins/valac/gbp-valac-pipeline-addin.c |  83 ++++++++++++++++
 src/plugins/valac/gbp-valac-pipeline-addin.h |  31 ++++++
 src/plugins/valac/meson.build                |  16 ++++
 src/plugins/valac/valac-plugin.c             |  37 ++++++++
 src/plugins/valac/valac.gresource.xml        |   6 ++
 src/plugins/valac/valac.plugin               |   9 ++
 11 files changed, 185 insertions(+), 163 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index 2abd6a9e0..db3d6c695 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -87,7 +87,7 @@ option('plugin_sysroot', type: 'boolean')
 option('plugin_todo', type: 'boolean')
 option('plugin_ts_language_server', type: 'boolean')
 option('plugin_update_manager', type: 'boolean')
-option('plugin_vala', type: 'boolean')
+option('plugin_valac', type: 'boolean')
 option('plugin_vagrant', type: 'boolean', value: false)
 option('plugin_valgrind', type: 'boolean')
 option('plugin_vls', type: 'boolean')
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 5cf3819a3..5596c62b1 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -132,7 +132,7 @@ subdir('ts-language-server')
 subdir('trim-spaces')
 subdir('update-manager')
 subdir('vagrant')
-#subdir('vala-pack')
+subdir('valac')
 subdir('valgrind')
 subdir('vcsui')
 subdir('vim')
@@ -206,7 +206,7 @@ status += [
   'Sysroot .............................. : @0@'.format(get_option('plugin_sysroot')),
   'Todo ................................. : @0@'.format(get_option('plugin_todo')),
   'Update Manager ....................... : @0@'.format(get_option('plugin_update_manager')),
-  'Vala Pack ............................ : @0@'.format(get_option('plugin_vala')),
+  'Vala Compiler ........................ : @0@'.format(get_option('plugin_valac')),
   'Vagrant .............................. : @0@ **'.format(get_option('plugin_vagrant')),
   'Valgrind ............................. : @0@'.format(get_option('plugin_valgrind')),
   'Waf .................................. : @0@'.format(get_option('plugin_waf')),
diff --git a/src/plugins/valac/gbp-valac-pipeline-addin.c b/src/plugins/valac/gbp-valac-pipeline-addin.c
new file mode 100644
index 000000000..b6b9d1344
--- /dev/null
+++ b/src/plugins/valac/gbp-valac-pipeline-addin.c
@@ -0,0 +1,83 @@
+/* gbp-valac-pipeline-addin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-valac-pipeline-addin"
+
+#include "config.h"
+
+#include <libide-foundry.h>
+
+#include "gbp-valac-pipeline-addin.h"
+
+struct _GbpValacPipelineAddin
+{
+  IdeObject parent_instance;
+  guint     error_format_id;
+};
+
+static void
+gbp_valac_pipeline_addin_load (IdePipelineAddin *addin,
+                              IdePipeline      *pipeline)
+{
+  GbpValacPipelineAddin *self = (GbpValacPipelineAddin *)addin;
+
+  g_assert (IDE_IS_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+
+  self->error_format_id = ide_pipeline_add_error_format (pipeline,
+                                                         "(?<filename>[a-zA-Z0-9\\-\\.\\/_]+.vala):"
+                                                         
"(?<line>\\d+).(?<column>\\d+)-(?<line2>\\d+).(?<column2>\\d+): "
+                                                         "(?<level>[\\w\\s]+): "
+                                                         "(?<message>.*)",
+                                                         G_REGEX_OPTIMIZE);
+}
+
+static void
+gbp_valac_pipeline_addin_unload (IdePipelineAddin *addin,
+                                IdePipeline      *pipeline)
+{
+  GbpValacPipelineAddin *self = (GbpValacPipelineAddin *)addin;
+
+  g_assert (IDE_IS_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+
+  ide_pipeline_remove_error_format (pipeline, self->error_format_id);
+  self->error_format_id = 0;
+}
+
+static void
+pipeline_addin_iface_init (IdePipelineAddinInterface *iface)
+{
+  iface->load = gbp_valac_pipeline_addin_load;
+  iface->unload = gbp_valac_pipeline_addin_unload;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpValacPipelineAddin, gbp_valac_pipeline_addin, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN, pipeline_addin_iface_init))
+
+static void
+gbp_valac_pipeline_addin_class_init (GbpValacPipelineAddinClass *klass)
+{
+}
+
+static void
+gbp_valac_pipeline_addin_init (GbpValacPipelineAddin *self)
+{
+}
diff --git a/src/plugins/valac/gbp-valac-pipeline-addin.h b/src/plugins/valac/gbp-valac-pipeline-addin.h
new file mode 100644
index 000000000..126f4dcc9
--- /dev/null
+++ b/src/plugins/valac/gbp-valac-pipeline-addin.h
@@ -0,0 +1,31 @@
+/* gbp-valac-pipeline-addin.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_VALAC_PIPELINE_ADDIN (gbp_valac_pipeline_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpValacPipelineAddin, gbp_valac_pipeline_addin, GBP, VALAC_PIPELINE_ADDIN, IdeObject)
+
+G_END_DECLS
diff --git a/src/plugins/valac/meson.build b/src/plugins/valac/meson.build
new file mode 100644
index 000000000..1722f372e
--- /dev/null
+++ b/src/plugins/valac/meson.build
@@ -0,0 +1,16 @@
+if get_option('plugin_valac')
+
+plugins_sources += files([
+  'valac-plugin.c',
+  'gbp-valac-pipeline-addin.c',
+])
+
+plugin_valac_resources = gnome.compile_resources(
+  'valac-resources',
+  'valac.gresource.xml',
+  c_name: 'gbp_valac',
+)
+
+plugins_sources += plugin_valac_resources
+
+endif
diff --git a/src/plugins/valac/valac-plugin.c b/src/plugins/valac/valac-plugin.c
new file mode 100644
index 000000000..a7088387e
--- /dev/null
+++ b/src/plugins/valac/valac-plugin.c
@@ -0,0 +1,37 @@
+/* valac-plugin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "valac-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-foundry.h>
+
+#include "gbp-valac-pipeline-addin.h"
+
+_IDE_EXTERN void
+_gbp_valac_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PIPELINE_ADDIN,
+                                              GBP_TYPE_VALAC_PIPELINE_ADDIN);
+}
diff --git a/src/plugins/valac/valac.gresource.xml b/src/plugins/valac/valac.gresource.xml
new file mode 100644
index 000000000..e521b80f4
--- /dev/null
+++ b/src/plugins/valac/valac.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/valac">
+    <file>valac.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/valac/valac.plugin b/src/plugins/valac/valac.plugin
new file mode 100644
index 000000000..04fdae13f
--- /dev/null
+++ b/src/plugins/valac/valac.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Authors=Christian Hergert <christian hergert me>
+Builtin=true
+Copyright=Copyright © 2015-2022 Christian Hergert
+Description=Extracts build errors from the vala compiler
+Embedded=_gbp_valac_register_types
+Module=valac
+Name=Vala Compiler
+X-Category=compilers


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]