[gnome-builder/wip/chergert/pipeline: 44/48] gcc: port to IdeBuildPipeline



commit ea358b7c84b8928120332245f3aa5da71513fd42
Author: Christian Hergert <chergert redhat com>
Date:   Fri Feb 3 13:59:06 2017 -0800

    gcc: port to IdeBuildPipeline
    
    This reduces the GCC diagnostics to simply register the regex for
    extraction when the build pipeline executes. This means that we do not
    need to many handlers for logs which should keep overhead low as we add
    additional error formats (such as for vala).

 plugins/gcc/Makefile.am                            |    4 +-
 plugins/gcc/gbp-gcc-build-result-addin.c           |  267 --------------------
 plugins/gcc/gbp-gcc-pipeline-addin.c               |   74 ++++++
 ...ild-result-addin.h => gbp-gcc-pipeline-addin.h} |   14 +-
 plugins/gcc/gbp-gcc-plugin.c                       |    6 +-
 5 files changed, 85 insertions(+), 280 deletions(-)
---
diff --git a/plugins/gcc/Makefile.am b/plugins/gcc/Makefile.am
index b772044..1e269c4 100644
--- a/plugins/gcc/Makefile.am
+++ b/plugins/gcc/Makefile.am
@@ -7,8 +7,8 @@ plugin_LTLIBRARIES = libgcc-plugin.la
 dist_plugin_DATA = gcc.plugin
 
 libgcc_plugin_la_SOURCES = \
-       gbp-gcc-build-result-addin.c \
-       gbp-gcc-build-result-addin.h \
+       gbp-gcc-pipeline-addin.c \
+       gbp-gcc-pipeline-addin.h \
        gbp-gcc-plugin.c
 
 libgcc_plugin_la_CFLAGS = $(PLUGIN_CFLAGS)
diff --git a/plugins/gcc/gbp-gcc-pipeline-addin.c b/plugins/gcc/gbp-gcc-pipeline-addin.c
new file mode 100644
index 0000000..d73b68f
--- /dev/null
+++ b/plugins/gcc/gbp-gcc-pipeline-addin.c
@@ -0,0 +1,74 @@
+/* gbp-gcc-pipeline-addin.c
+ *
+ * Copyright (C) 2017 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/>.
+ */
+
+#define G_LOG_DOMAIN "gbp-gcc-pipeline-addin"
+
+#include "gbp-gcc-pipeline-addin.h"
+
+#define ERROR_FORMAT_REGEX              \
+  "(?<filename>[a-zA-Z0-9\\-\\.\\/]+):" \
+  "(?<line>\\d+):"                      \
+  "(?<column>\\d+): "                   \
+  "(?<level>[\\w\\s]+): "               \
+  "(?<message>.*)"
+
+struct _GbpGccPipelineAddin
+{
+  IdeObject parent_instance;
+  guint     error_format_id;
+};
+
+static void
+gbp_gcc_pipeline_addin_load (IdeBuildPipelineAddin *addin,
+                             IdeBuildPipeline      *pipeline)
+{
+  GbpGccPipelineAddin *self = (GbpGccPipelineAddin *)addin;
+
+  g_assert (GBP_IS_GCC_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+
+  self->error_format_id = ide_build_pipeline_add_error_format (pipeline,
+                                                               ERROR_FORMAT_REGEX,
+                                                               G_REGEX_CASELESS);
+}
+
+static void
+gbp_gcc_pipeline_addin_unload (IdeBuildPipelineAddin *addin,
+                               IdeBuildPipeline      *pipeline)
+{
+  GbpGccPipelineAddin *self = (GbpGccPipelineAddin *)addin;
+
+  g_assert (GBP_IS_GCC_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+
+  ide_build_pipeline_remove_error_format (pipeline, self->error_format_id);
+  self->error_format_id = 0;
+}
+
+static void
+addin_iface_init (IdeBuildPipelineAddinInterface *iface)
+{
+  iface->load = gbp_gcc_pipeline_addin_load;
+  iface->unload = gbp_gcc_pipeline_addin_unload;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GbpGccPipelineAddin, gbp_gcc_pipeline_addin, IDE_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_BUILD_PIPELINE_ADDIN, addin_iface_init))
+
+static void gbp_gcc_pipeline_addin_class_init (GbpGccPipelineAddinClass *klass) { }
+static void gbp_gcc_pipeline_addin_init (GbpGccPipelineAddin *self) { }
diff --git a/plugins/gcc/gbp-gcc-build-result-addin.h b/plugins/gcc/gbp-gcc-pipeline-addin.h
similarity index 63%
rename from plugins/gcc/gbp-gcc-build-result-addin.h
rename to plugins/gcc/gbp-gcc-pipeline-addin.h
index 2a77a0b..ac614da 100644
--- a/plugins/gcc/gbp-gcc-build-result-addin.h
+++ b/plugins/gcc/gbp-gcc-pipeline-addin.h
@@ -1,6 +1,6 @@
-/* gbp-gcc-build-result-addin.h
+/* gbp-gcc-pipeline-addin.h
  *
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2017 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
@@ -16,17 +16,17 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GBP_GCC_BUILD_RESULT_ADDIN_H
-#define GBP_GCC_BUILD_RESULT_ADDIN_H
+#ifndef GBP_GCC_PIPELINE_ADDIN_H
+#define GBP_GCC_PIPELINE_ADDIN_H
 
 #include <ide.h>
 
 G_BEGIN_DECLS
 
-#define GBP_TYPE_GCC_BUILD_RESULT_ADDIN (gbp_gcc_build_result_addin_get_type())
+#define GBP_TYPE_GCC_PIPELINE_ADDIN (gbp_gcc_pipeline_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpGccBuildResultAddin, gbp_gcc_build_result_addin, GBP, GCC_BUILD_RESULT_ADDIN, 
IdeObject)
+G_DECLARE_FINAL_TYPE (GbpGccPipelineAddin, gbp_gcc_pipeline_addin, GBP, GCC_PIPELINE_ADDIN, IdeObject)
 
 G_END_DECLS
 
-#endif /* GBP_GCC_BUILD_RESULT_ADDIN_H */
+#endif /* GBP_GCC_PIPELINE_ADDIN_H */
diff --git a/plugins/gcc/gbp-gcc-plugin.c b/plugins/gcc/gbp-gcc-plugin.c
index 5504323..d3ea3b2 100644
--- a/plugins/gcc/gbp-gcc-plugin.c
+++ b/plugins/gcc/gbp-gcc-plugin.c
@@ -19,12 +19,10 @@
 #include <ide.h>
 #include <libpeas/peas.h>
 
-#include "gbp-gcc-build-result-addin.h"
+#include "gbp-gcc-pipeline-addin.h"
 
 void
 peas_register_types (PeasObjectModule *module)
 {
-  peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_BUILD_RESULT_ADDIN,
-                                              GBP_TYPE_GCC_BUILD_RESULT_ADDIN);
+  peas_object_module_register_extension_type (module, IDE_TYPE_BUILD_PIPELINE_ADDIN, 
GBP_TYPE_GCC_PIPELINE_ADDIN);
 }


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