1 /* gbp-gcc-pipeline-addin.c
2 *
3 * Copyright 2017-2019 Christian Hergert <chergert@redhat.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21 #define G_LOG_DOMAIN "gbp-gcc-pipeline-addin"
22
23 #include "config.h"
24
25 #include "libide-foundry.h"
26
27 #include "gbp-gcc-pipeline-addin.h"
28
29 #define ERROR_FORMAT_REGEX \
30 "(?<filename>[a-zA-Z0-9\\+\\-\\.\\/_]+):" \
31 "(?<line>\\d+):" \
32 "(?<column>\\d+): " \
33 "(?<level>[\\w\\s]+): " \
34 "(?<message>.*)"
35
36 struct _GbpGccPipelineAddin
37 {
38 IdeObject parent_instance;
39 guint error_format_id;
40 };
41
42 static void
gbp_gcc_pipeline_addin_load(IdePipelineAddin * addin,IdePipeline * pipeline)43 gbp_gcc_pipeline_addin_load (IdePipelineAddin *addin,
44 IdePipeline *pipeline)
45 {
46 GbpGccPipelineAddin *self = (GbpGccPipelineAddin *)addin;
47
48 g_assert (GBP_IS_GCC_PIPELINE_ADDIN (self));
49 g_assert (IDE_IS_PIPELINE (pipeline));
50
51 self->error_format_id = ide_pipeline_add_error_format (pipeline,
52 ERROR_FORMAT_REGEX,
53 G_REGEX_CASELESS);
54 }
55
56 static void
gbp_gcc_pipeline_addin_unload(IdePipelineAddin * addin,IdePipeline * pipeline)57 gbp_gcc_pipeline_addin_unload (IdePipelineAddin *addin,
58 IdePipeline *pipeline)
59 {
60 GbpGccPipelineAddin *self = (GbpGccPipelineAddin *)addin;
61
62 g_assert (GBP_IS_GCC_PIPELINE_ADDIN (self));
63 g_assert (IDE_IS_PIPELINE (pipeline));
64
65 ide_pipeline_remove_error_format (pipeline, self->error_format_id);
66 self->error_format_id = 0;
67 }
68
69 static void
addin_iface_init(IdePipelineAddinInterface * iface)70 addin_iface_init (IdePipelineAddinInterface *iface)
71 {
72 iface->load = gbp_gcc_pipeline_addin_load;
73 iface->unload = gbp_gcc_pipeline_addin_unload;
74 }
75
G_DEFINE_FINAL_TYPE_WITH_CODE(GbpGccPipelineAddin,gbp_gcc_pipeline_addin,IDE_TYPE_OBJECT,G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN,addin_iface_init))76 G_DEFINE_FINAL_TYPE_WITH_CODE (GbpGccPipelineAddin, gbp_gcc_pipeline_addin, IDE_TYPE_OBJECT,
77 G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN, addin_iface_init))
78
79 static void gbp_gcc_pipeline_addin_class_init (GbpGccPipelineAddinClass *klass) { }
gbp_gcc_pipeline_addin_init(GbpGccPipelineAddin * self)80 static void gbp_gcc_pipeline_addin_init (GbpGccPipelineAddin *self) { }
81