[gnome-builder/wip/gtk4-port] plugins/waf: port Waf build system plugin to C



commit 65b2bc23b3793447364f13937e3b454774cb0425
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 25 17:15:03 2022 -0700

    plugins/waf: port Waf build system plugin to C

 src/plugins/waf/gbp-waf-build-system-discovery.c |  48 +++++
 src/plugins/waf/gbp-waf-build-system-discovery.h |  32 ++++
 src/plugins/waf/gbp-waf-build-system.c           | 191 +++++++++++++++++++
 src/plugins/waf/gbp-waf-build-system.h           |  36 ++++
 src/plugins/waf/gbp-waf-build-target-provider.c  | 215 +++++++++++++++++++++
 src/plugins/waf/gbp-waf-build-target-provider.h  |  32 ++++
 src/plugins/waf/gbp-waf-build-target.c           | 117 ++++++++++++
 src/plugins/waf/gbp-waf-build-target.h           |  33 ++++
 src/plugins/waf/gbp-waf-pipeline-addin.c         | 167 ++++++++++++++++
 src/plugins/waf/gbp-waf-pipeline-addin.h         |  32 ++++
 src/plugins/waf/gbp-waf-run-command-provider.c   | 230 +++++++++++++++++++++++
 src/plugins/waf/gbp-waf-run-command-provider.h   |  32 ++++
 src/plugins/waf/meson.build                      |  24 ++-
 src/plugins/waf/waf-plugin.c                     |  55 ++++++
 src/plugins/waf/waf.gresource.xml                |   6 +
 src/plugins/waf/waf.plugin                       |   9 +-
 16 files changed, 1246 insertions(+), 13 deletions(-)
---
diff --git a/src/plugins/waf/gbp-waf-build-system-discovery.c 
b/src/plugins/waf/gbp-waf-build-system-discovery.c
new file mode 100644
index 000000000..2358c0b8f
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-system-discovery.c
@@ -0,0 +1,48 @@
+/* gbp-waf-build-system-discovery.c
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-waf-build-system-discovery"
+
+#include "config.h"
+
+#include "gbp-waf-build-system-discovery.h"
+
+struct _GbpWafBuildSystemDiscovery
+{
+  IdeSimpleBuildSystemDiscovery parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpWafBuildSystemDiscovery, gbp_waf_build_system_discovery, 
IDE_TYPE_SIMPLE_BUILD_SYSTEM_DISCOVERY)
+
+static void
+gbp_waf_build_system_discovery_class_init (GbpWafBuildSystemDiscoveryClass *klass)
+{
+}
+
+static void
+gbp_waf_build_system_discovery_init (GbpWafBuildSystemDiscovery *self)
+{
+  g_object_set (self,
+                "glob", "wscript",
+                "hint", "waf",
+                "priority", 1000,
+                NULL);
+}
diff --git a/src/plugins/waf/gbp-waf-build-system-discovery.h 
b/src/plugins/waf/gbp-waf-build-system-discovery.h
new file mode 100644
index 000000000..68bb169fd
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-system-discovery.h
@@ -0,0 +1,32 @@
+/* gbp-waf-build-system-discovery.h
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-foundry.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_WAF_BUILD_SYSTEM_DISCOVERY (gbp_waf_build_system_discovery_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafBuildSystemDiscovery, gbp_waf_build_system_discovery, GBP, 
WAF_BUILD_SYSTEM_DISCOVERY, IdeSimpleBuildSystemDiscovery)
+
+G_END_DECLS
diff --git a/src/plugins/waf/gbp-waf-build-system.c b/src/plugins/waf/gbp-waf-build-system.c
new file mode 100644
index 000000000..3eb709b7c
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-system.c
@@ -0,0 +1,191 @@
+/* gbp-waf-build-system.c
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-waf-build-system"
+
+#include "config.h"
+
+#include "gbp-waf-build-system.h"
+
+struct _GbpWafBuildSystem
+{
+  IdeObject  parent_instance;
+  GFile     *project_file;
+};
+
+enum {
+  PROP_0,
+  PROP_PROJECT_FILE,
+  N_PROPS
+};
+
+static char *
+gbp_waf_build_system_get_id (IdeBuildSystem *build_system)
+{
+  return g_strdup ("waf");
+}
+
+static char *
+gbp_waf_build_system_get_display_name (IdeBuildSystem *build_system)
+{
+  return g_strdup ("Waf");
+}
+
+static int
+gbp_waf_build_system_get_priority (IdeBuildSystem *build_system)
+{
+  return 1000;
+}
+
+static void
+build_system_iface_init (IdeBuildSystemInterface *iface)
+{
+  iface->get_id = gbp_waf_build_system_get_id;
+  iface->get_display_name = gbp_waf_build_system_get_display_name;
+  iface->get_priority = gbp_waf_build_system_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpWafBuildSystem, gbp_waf_build_system, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_BUILD_SYSTEM, build_system_iface_init))
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_waf_build_system_dispose (GObject *object)
+{
+  GbpWafBuildSystem *self = (GbpWafBuildSystem *)object;
+
+  g_clear_object (&self->project_file);
+
+  G_OBJECT_CLASS (gbp_waf_build_system_parent_class)->dispose (object);
+}
+
+static void
+gbp_waf_build_system_get_property (GObject    *object,
+                                     guint       prop_id,
+                                     GValue     *value,
+                                     GParamSpec *pspec)
+{
+  GbpWafBuildSystem *self = GBP_WAF_BUILD_SYSTEM (object);
+
+  switch (prop_id)
+    {
+    case PROP_PROJECT_FILE:
+      g_value_set_object (value, self->project_file);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_waf_build_system_set_property (GObject      *object,
+                                     guint         prop_id,
+                                     const GValue *value,
+                                     GParamSpec   *pspec)
+{
+  GbpWafBuildSystem *self = GBP_WAF_BUILD_SYSTEM (object);
+
+  switch (prop_id)
+    {
+    case PROP_PROJECT_FILE:
+      g_set_object (&self->project_file, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_waf_build_system_class_init (GbpWafBuildSystemClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = gbp_waf_build_system_dispose;
+  object_class->get_property = gbp_waf_build_system_get_property;
+  object_class->set_property = gbp_waf_build_system_set_property;
+
+  properties [PROP_PROJECT_FILE] =
+    g_param_spec_object ("project-file",
+                         "Project File",
+                         "The project file (Waf.toml)",
+                         G_TYPE_FILE,
+                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gbp_waf_build_system_init (GbpWafBuildSystem *self)
+{
+}
+
+gboolean
+gbp_waf_build_system_wants_python2 (GbpWafBuildSystem  *self,
+                                    GError            **error)
+{
+  g_autofree char *contents = NULL;
+  IdeLineReader reader;
+  char *line;
+  gsize line_len;
+  gsize len = 0;
+
+  g_return_val_if_fail (GBP_IS_WAF_BUILD_SYSTEM (self), FALSE);
+  g_return_val_if_fail (self->project_file != NULL, FALSE);
+
+  if (!g_file_load_contents (self->project_file, NULL, &contents, &len, NULL, error))
+    return TRUE;
+
+  ide_line_reader_init (&reader, contents, len);
+  if ((line = ide_line_reader_next (&reader, &line_len)))
+    {
+      line[line_len] = 0;
+
+      if (strstr (line, "python3") != NULL)
+        return FALSE;
+    }
+
+  return TRUE;
+}
+
+char *
+gbp_waf_build_system_locate_waf (GbpWafBuildSystem *self)
+{
+  g_autoptr(GFile) parent = NULL;
+  g_autoptr(GFile) waf = NULL;
+
+  g_return_val_if_fail (GBP_IS_WAF_BUILD_SYSTEM (self), NULL);
+  g_return_val_if_fail (G_IS_FILE (self->project_file), NULL);
+
+  if (g_file_query_file_type (self->project_file, 0, NULL) == G_FILE_TYPE_DIRECTORY)
+    parent = g_object_ref (self->project_file);
+  else
+    parent = g_file_get_parent (self->project_file);
+
+  waf = g_file_get_child (parent, "waf");
+
+  if (g_file_query_exists (waf, NULL))
+    return g_file_get_path (waf);
+
+  return g_strdup ("waf");
+}
diff --git a/src/plugins/waf/gbp-waf-build-system.h b/src/plugins/waf/gbp-waf-build-system.h
new file mode 100644
index 000000000..f9cb5e590
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-system.h
@@ -0,0 +1,36 @@
+/* gbp-waf-build-system.h
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-foundry.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_WAF_BUILD_SYSTEM (gbp_waf_build_system_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafBuildSystem, gbp_waf_build_system, GBP, WAF_BUILD_SYSTEM, IdeObject)
+
+gboolean  gbp_waf_build_system_wants_python2 (GbpWafBuildSystem  *self,
+                                              GError            **error);
+char     *gbp_waf_build_system_locate_waf    (GbpWafBuildSystem  *self);
+
+G_END_DECLS
diff --git a/src/plugins/waf/gbp-waf-build-target-provider.c b/src/plugins/waf/gbp-waf-build-target-provider.c
new file mode 100644
index 000000000..c4bf7ccb4
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-target-provider.c
@@ -0,0 +1,215 @@
+/* gbp-waf-build-target-provider.c
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-waf-build-target-provider"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-foundry.h>
+#include <libide-threading.h>
+
+#include "gbp-waf-build-system.h"
+#include "gbp-waf-build-target.h"
+#include "gbp-waf-build-target-provider.h"
+
+struct _GbpWafBuildTargetProvider
+{
+  IdeObject parent_instance;
+};
+
+static void
+gbp_waf_build_target_provider_list_cb (GObject      *object,
+                                      GAsyncResult *result,
+                                      gpointer      user_data)
+{
+  IdeSubprocess *subprocess = (IdeSubprocess *)object;
+  g_autoptr(IdeTask) task = user_data;
+  g_autoptr(GError) error = NULL;
+  g_autoptr(GPtrArray) ar = NULL;
+  g_autofree char *stdout_buf = NULL;
+  IdeLineReader reader;
+  char *line;
+  gsize line_len;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_SUBPROCESS (subprocess));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (IDE_IS_TASK (task));
+
+  if (!ide_subprocess_communicate_utf8_finish (subprocess, result, &stdout_buf, NULL, &error))
+    {
+      ide_task_return_error (task, g_steal_pointer (&error));
+      IDE_EXIT;
+    }
+
+  ide_line_reader_init (&reader, stdout_buf, -1);
+
+  /* Skip first two lines */
+  ide_line_reader_next (&reader, &line_len);
+  ide_line_reader_next (&reader, &line_len);
+
+  ar = g_ptr_array_new_with_free_func (g_object_unref);
+
+  while ((line = ide_line_reader_next (&reader, &line_len)))
+    {
+      g_autoptr(IdeBuildTarget) build_target = NULL;
+
+      line[line_len] = 0;
+
+      g_strstrip (line);
+
+      /* Skip last line -> "'list' finished successfully (time)" */
+      if (g_str_has_prefix (line, "'list' "))
+        break;
+
+      g_ptr_array_add (ar, gbp_waf_build_target_new (line));
+    }
+
+  ide_task_return_pointer (task, g_steal_pointer (&ar), g_ptr_array_unref);
+
+  IDE_EXIT;
+}
+
+static void
+gbp_waf_build_target_provider_get_targets_async (IdeBuildTargetProvider *provider,
+                                                 GCancellable           *cancellable,
+                                                 GAsyncReadyCallback     callback,
+                                                 gpointer                user_data)
+{
+  GbpWafBuildTargetProvider *self = (GbpWafBuildTargetProvider *)provider;
+  g_autoptr(IdeSubprocessLauncher) launcher  = NULL;
+  g_autoptr(IdeSubprocess) subprocess = NULL;
+  g_autoptr(IdeBuildTarget) build_target = NULL;
+  g_autoptr(GListStore) store = NULL;
+  g_autoptr(IdeTask) task = NULL;
+  g_autoptr(GError) error = NULL;
+  g_autofree char *waf = NULL;
+  IdeBuildManager *build_manager;
+  IdeBuildSystem *build_system;
+  IdePipeline *pipeline;
+  IdeContext *context;
+  const char *python;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_WAF_BUILD_TARGET_PROVIDER (self));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  task = ide_task_new (self, cancellable, callback, user_data);
+  ide_task_set_source_tag (task, gbp_waf_build_target_provider_get_targets_async);
+
+  context = ide_object_get_context (IDE_OBJECT (self));
+  build_system = ide_build_system_from_context (context);
+
+  if (!GBP_IS_WAF_BUILD_SYSTEM (build_system))
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_NOT_SUPPORTED,
+                                 "Not a waf build system");
+      IDE_EXIT;
+    }
+
+  build_manager = ide_build_manager_from_context (context);
+  pipeline = ide_build_manager_get_pipeline (build_manager);
+
+  if (pipeline == NULL ||
+      !ide_pipeline_is_ready (pipeline) ||
+      ide_pipeline_get_phase (pipeline) < IDE_PIPELINE_PHASE_CONFIGURE)
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_NOT_SUPPORTED,
+                                 "Pipeline not ready, cannot list run commands");
+      IDE_EXIT;
+    }
+
+  waf = gbp_waf_build_system_locate_waf (GBP_WAF_BUILD_SYSTEM (build_system));
+  if (gbp_waf_build_system_wants_python2 (GBP_WAF_BUILD_SYSTEM (build_system), NULL))
+    python = "python2";
+  else
+    python = "python3";
+
+  launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT (python, waf, "list", "--color=no"));
+  /* There appears to be some installations that will write to stderr instead of stdout */
+  ide_subprocess_launcher_set_flags (launcher,
+                                     (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
+                                      G_SUBPROCESS_FLAGS_STDERR_MERGE));
+  ide_subprocess_launcher_set_cwd (launcher, ide_pipeline_get_srcdir (pipeline));
+
+  if (!(subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error)))
+    {
+      ide_task_return_error (task, g_steal_pointer (&error));
+      IDE_EXIT;
+    }
+
+  ide_subprocess_communicate_utf8_async (subprocess,
+                                         NULL,
+                                         cancellable,
+                                         gbp_waf_build_target_provider_list_cb,
+                                         g_steal_pointer (&task));
+
+  IDE_EXIT;
+}
+
+static GPtrArray *
+gbp_waf_build_target_provider_get_targets_finish (IdeBuildTargetProvider  *provider,
+                                                  GAsyncResult            *result,
+                                                  GError                 **error)
+{
+  GPtrArray *ret;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_WAF_BUILD_TARGET_PROVIDER (provider));
+  g_assert (IDE_IS_TASK (result));
+
+  ret = ide_task_propagate_pointer (IDE_TASK (result), error);
+
+  /* transfer full semantics */
+  IDE_PTR_ARRAY_CLEAR_FREE_FUNC (ret);
+
+  IDE_RETURN (ret);
+}
+
+static void
+build_target_provider_iface_init (IdeBuildTargetProviderInterface *iface)
+{
+  iface->get_targets_async = gbp_waf_build_target_provider_get_targets_async;
+  iface->get_targets_finish = gbp_waf_build_target_provider_get_targets_finish;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpWafBuildTargetProvider, gbp_waf_build_target_provider, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_BUILD_TARGET_PROVIDER, 
build_target_provider_iface_init))
+
+static void
+gbp_waf_build_target_provider_class_init (GbpWafBuildTargetProviderClass *klass)
+{
+}
+
+static void
+gbp_waf_build_target_provider_init (GbpWafBuildTargetProvider *self)
+{
+}
diff --git a/src/plugins/waf/gbp-waf-build-target-provider.h b/src/plugins/waf/gbp-waf-build-target-provider.h
new file mode 100644
index 000000000..71208c17e
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-target-provider.h
@@ -0,0 +1,32 @@
+/* gbp-waf-build-target-provider.h
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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_WAF_BUILD_TARGET_PROVIDER (gbp_waf_build_target_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafBuildTargetProvider, gbp_waf_build_target_provider, GBP, 
WAF_BUILD_TARGET_PROVIDER, IdeObject)
+
+G_END_DECLS
diff --git a/src/plugins/waf/gbp-waf-build-target.c b/src/plugins/waf/gbp-waf-build-target.c
new file mode 100644
index 000000000..5cb62a64c
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-target.c
@@ -0,0 +1,117 @@
+/* gbp-waf-build-target.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-waf-build-target"
+
+#include "config.h"
+
+#include <libide-foundry.h>
+
+#include "gbp-waf-build-target.h"
+
+struct _GbpWafBuildTarget
+{
+  IdeObject parent_instance;
+  char *name;
+};
+
+static GFile *
+gbp_waf_build_target_get_install_directory (IdeBuildTarget *build_target)
+{
+  return NULL;
+}
+
+static char **
+gbp_waf_build_target_get_argv (IdeBuildTarget *build_target)
+{
+  return NULL;
+}
+
+static char *
+gbp_waf_build_target_get_display_name (IdeBuildTarget *build_target)
+{
+  return g_strdup (GBP_WAF_BUILD_TARGET (build_target)->name);
+}
+
+static char *
+gbp_waf_build_target_get_name (IdeBuildTarget *build_target)
+{
+  return g_strdup (GBP_WAF_BUILD_TARGET (build_target)->name);
+}
+
+static IdeArtifactKind
+gbp_waf_build_target_get_kind (IdeBuildTarget *build_target)
+{
+  return IDE_ARTIFACT_KIND_NONE;
+}
+
+static int
+gbp_waf_build_target_get_priority (IdeBuildTarget *build_target)
+{
+  return 0;
+}
+
+static void
+build_target_iface_init (IdeBuildTargetInterface *iface)
+{
+  iface->get_argv = gbp_waf_build_target_get_argv;
+  iface->get_display_name = gbp_waf_build_target_get_display_name;
+  iface->get_install_directory = gbp_waf_build_target_get_install_directory;
+  iface->get_kind = gbp_waf_build_target_get_kind;
+  iface->get_name = gbp_waf_build_target_get_name;
+  iface->get_priority = gbp_waf_build_target_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpWafBuildTarget, gbp_waf_build_target, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_BUILD_TARGET, build_target_iface_init))
+
+static void
+gbp_waf_build_target_finalize (GObject *object)
+{
+  GbpWafBuildTarget *self = (GbpWafBuildTarget *)object;
+
+  g_clear_pointer (&self->name, g_free);
+
+  G_OBJECT_CLASS (gbp_waf_build_target_parent_class)->finalize (object);
+}
+
+static void
+gbp_waf_build_target_class_init (GbpWafBuildTargetClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gbp_waf_build_target_finalize;
+}
+
+static void
+gbp_waf_build_target_init (GbpWafBuildTarget *self)
+{
+}
+
+GbpWafBuildTarget *
+gbp_waf_build_target_new (const char *name)
+{
+  GbpWafBuildTarget *self;
+
+  self = g_object_new (GBP_TYPE_WAF_BUILD_TARGET, NULL);
+  self->name = g_strdup (name);
+
+  return self;
+}
diff --git a/src/plugins/waf/gbp-waf-build-target.h b/src/plugins/waf/gbp-waf-build-target.h
new file mode 100644
index 000000000..740c2774c
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-build-target.h
@@ -0,0 +1,33 @@
+/* gbp-waf-build-target.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_WAF_BUILD_TARGET (gbp_waf_build_target_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafBuildTarget, gbp_waf_build_target, GBP, WAF_BUILD_TARGET, IdeObject)
+
+GbpWafBuildTarget *gbp_waf_build_target_new (const char *name);
+
+G_END_DECLS
diff --git a/src/plugins/waf/gbp-waf-pipeline-addin.c b/src/plugins/waf/gbp-waf-pipeline-addin.c
new file mode 100644
index 000000000..c1028d120
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-pipeline-addin.c
@@ -0,0 +1,167 @@
+/* gbp-waf-pipeline-addin.c
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-waf-pipeline-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-foundry.h>
+
+#include "gbp-waf-build-system.h"
+#include "gbp-waf-pipeline-addin.h"
+
+struct _GbpWafPipelineAddin
+{
+  IdeObject parent_instance;
+};
+
+static void
+query_cb (IdePipelineStage *stage,
+          IdePipeline      *pipeline,
+          GPtrArray        *targets,
+          GCancellable     *cancellable,
+          gpointer          user_data)
+{
+  g_assert (IDE_IS_PIPELINE_STAGE (stage));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  /* Always defer to waf to check if build is needed */
+  ide_pipeline_stage_set_completed (stage, FALSE);
+
+  /* TODO: You can use @targets to limit what targets to build */
+}
+
+static void
+gbp_waf_pipeline_addin_load (IdePipelineAddin *addin,
+                             IdePipeline      *pipeline)
+{
+  g_autoptr(IdeSubprocessLauncher) config_launcher = NULL;
+  g_autoptr(IdeSubprocessLauncher) build_launcher = NULL;
+  g_autoptr(IdeSubprocessLauncher) clean_launcher = NULL;
+  g_autoptr(IdeSubprocessLauncher) install_launcher = NULL;
+  g_autoptr(IdePipelineStage) build_stage = NULL;
+  g_autoptr(IdePipelineStage) install_stage = NULL;
+  g_autoptr(IdePipelineStage) config_stage = NULL;
+  g_autofree char *waf = NULL;
+  IdeBuildSystem *build_system;
+  g_auto(GStrv) waf_argv = NULL;
+  const char *config_opts;
+  const char *python;
+  const char *prefix;
+  const char *srcdir;
+  IdeContext *context;
+  IdeConfig *config;
+  guint id;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_WAF_PIPELINE_ADDIN (addin));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+
+  context = ide_object_get_context (IDE_OBJECT (addin));
+  build_system = ide_build_system_from_context (context);
+
+  if (!GBP_IS_WAF_BUILD_SYSTEM (build_system))
+    IDE_EXIT;
+
+  config = ide_pipeline_get_config (pipeline);
+  config_opts = ide_config_get_config_opts (config);
+  prefix = ide_config_get_prefix (config);
+  waf = gbp_waf_build_system_locate_waf (GBP_WAF_BUILD_SYSTEM (build_system));
+  srcdir = ide_pipeline_get_srcdir (pipeline);
+
+  if (gbp_waf_build_system_wants_python2 (GBP_WAF_BUILD_SYSTEM (build_system), NULL))
+    python = "python2";
+  else
+    python = "python3";
+
+  g_assert (prefix != NULL);
+  g_assert (python != NULL);
+  g_assert (IDE_IS_CONFIG (config));
+  g_assert (waf != NULL);
+
+  if (ide_str_equal0 (waf, "waf"))
+    waf_argv = g_strdupv ((char **)IDE_STRV_INIT ("waf"));
+  else
+    waf_argv = g_strdupv ((char **)IDE_STRV_INIT (python, waf));
+
+  config_launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_set_cwd (config_launcher, srcdir);
+  ide_subprocess_launcher_push_args (config_launcher, (const char * const *)waf_argv);
+  ide_subprocess_launcher_push_argv (config_launcher, "configure");
+  ide_subprocess_launcher_push_argv_format (config_launcher, "--prefix=%s", prefix);
+  ide_subprocess_launcher_push_argv_parsed (config_launcher, config_opts);
+  config_stage = ide_pipeline_stage_launcher_new (context, config_launcher);
+  ide_pipeline_stage_set_name (config_stage, _("Configuring project"));
+  id = ide_pipeline_attach (pipeline, IDE_PIPELINE_PHASE_CONFIGURE, 0, config_stage);
+  ide_pipeline_addin_track (addin, id);
+
+  build_launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_set_cwd (build_launcher, srcdir);
+  ide_subprocess_launcher_push_args (build_launcher, (const char * const *)waf_argv);
+  ide_subprocess_launcher_push_argv (build_launcher, "build");
+
+  clean_launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_set_cwd (clean_launcher, srcdir);
+  ide_subprocess_launcher_push_args (clean_launcher, (const char * const *)waf_argv);
+  ide_subprocess_launcher_push_argv (clean_launcher, "clean");
+
+  build_stage = ide_pipeline_stage_launcher_new (context, build_launcher);
+  ide_pipeline_stage_set_name (build_stage, _("Building project"));
+  ide_pipeline_stage_launcher_set_clean_launcher (IDE_PIPELINE_STAGE_LAUNCHER (build_stage), clean_launcher);
+  g_signal_connect (build_stage, "query", G_CALLBACK (query_cb), NULL);
+  id = ide_pipeline_attach (pipeline, IDE_PIPELINE_PHASE_BUILD, 0, build_stage);
+  ide_pipeline_addin_track (addin, id);
+
+  install_launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_set_cwd (install_launcher, srcdir);
+  ide_subprocess_launcher_push_args (install_launcher, (const char * const *)waf_argv);
+  ide_subprocess_launcher_push_argv (install_launcher, "install");
+
+  install_stage = ide_pipeline_stage_launcher_new (context, install_launcher);
+  ide_pipeline_stage_set_name (install_stage, _("Installing project"));
+  id = ide_pipeline_attach (pipeline, IDE_PIPELINE_PHASE_INSTALL, 0, install_stage);
+  ide_pipeline_addin_track (addin, id);
+
+  IDE_EXIT;
+}
+
+static void
+pipeline_addin_iface_init (IdePipelineAddinInterface *iface)
+{
+  iface->load = gbp_waf_pipeline_addin_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpWafPipelineAddin, gbp_waf_pipeline_addin, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN, pipeline_addin_iface_init))
+
+static void
+gbp_waf_pipeline_addin_class_init (GbpWafPipelineAddinClass *klass)
+{
+}
+
+static void
+gbp_waf_pipeline_addin_init (GbpWafPipelineAddin *self)
+{
+}
diff --git a/src/plugins/waf/gbp-waf-pipeline-addin.h b/src/plugins/waf/gbp-waf-pipeline-addin.h
new file mode 100644
index 000000000..fd66f7694
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-pipeline-addin.h
@@ -0,0 +1,32 @@
+/* gbp-waf-pipeline-addin.h
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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_WAF_PIPELINE_ADDIN (gbp_waf_pipeline_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafPipelineAddin, gbp_waf_pipeline_addin, GBP, WAF_PIPELINE_ADDIN, IdeObject)
+
+G_END_DECLS
diff --git a/src/plugins/waf/gbp-waf-run-command-provider.c b/src/plugins/waf/gbp-waf-run-command-provider.c
new file mode 100644
index 000000000..f3a17b0c8
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-run-command-provider.c
@@ -0,0 +1,230 @@
+/* gbp-waf-run-command-provider.c
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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-waf-run-command-provider"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-foundry.h>
+#include <libide-threading.h>
+
+#include "gbp-waf-build-system.h"
+#include "gbp-waf-run-command-provider.h"
+
+struct _GbpWafRunCommandProvider
+{
+  IdeObject parent_instance;
+};
+
+static void
+gbp_waf_run_command_provider_list_cb (GObject      *object,
+                                      GAsyncResult *result,
+                                      gpointer      user_data)
+{
+  IdeSubprocess *subprocess = (IdeSubprocess *)object;
+  g_autoptr(IdeTask) task = user_data;
+  g_autoptr(GError) error = NULL;
+  g_autoptr(GListStore) store = NULL;
+  g_autofree char *stdout_buf = NULL;
+  IdeLineReader reader;
+  char *line;
+  gsize line_len;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_SUBPROCESS (subprocess));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (IDE_IS_TASK (task));
+
+  if (!ide_subprocess_communicate_utf8_finish (subprocess, result, &stdout_buf, NULL, &error))
+    {
+      ide_task_return_error (task, g_steal_pointer (&error));
+      IDE_EXIT;
+    }
+
+  ide_line_reader_init (&reader, stdout_buf, -1);
+
+  /* Skip first two lines */
+  ide_line_reader_next (&reader, &line_len);
+  ide_line_reader_next (&reader, &line_len);
+
+  /* TODO: We pretend that everything is installed, how can we determine
+   * if that is really the case? This allows us to choose a target
+   * in the project-tree to run. There don't seem to be any options from
+   * "waf list" to get information about the targets.
+   */
+
+  store = g_list_store_new (IDE_TYPE_RUN_COMMAND);
+
+  while ((line = ide_line_reader_next (&reader, &line_len)))
+    {
+      g_autoptr(IdeRunCommand) run_command = NULL;
+      g_autofree char *id = NULL;
+
+      line[line_len] = 0;
+
+      g_strstrip (line);
+
+      /* Skip last line -> "'list' finished successfully (time)" */
+      if (g_str_has_prefix (line, "'list' "))
+        break;
+
+      /* Skip things that are outside tree */
+      if (g_str_has_prefix (line, ".."))
+        continue;
+
+      id = g_strdup_printf ("waf:%s", line);
+
+      run_command = ide_run_command_new ();
+      ide_run_command_set_id (run_command, id);
+      ide_run_command_set_priority (run_command, 0);
+      ide_run_command_set_display_name (run_command, line);
+      ide_run_command_set_argv (run_command, IDE_STRV_INIT (line));
+
+      g_list_store_append (store, run_command);
+    }
+
+  ide_task_return_pointer (task, g_steal_pointer (&store), g_object_unref);
+
+  IDE_EXIT;
+}
+
+static void
+gbp_waf_run_command_provider_list_commands_async (IdeRunCommandProvider *provider,
+                                                  GCancellable          *cancellable,
+                                                  GAsyncReadyCallback    callback,
+                                                  gpointer               user_data)
+{
+  GbpWafRunCommandProvider *self = (GbpWafRunCommandProvider *)provider;
+  g_autoptr(IdeSubprocessLauncher) launcher  = NULL;
+  g_autoptr(IdeSubprocess) subprocess = NULL;
+  g_autoptr(IdeRunCommand) run_command = NULL;
+  g_autoptr(GListStore) store = NULL;
+  g_autoptr(IdeTask) task = NULL;
+  g_autoptr(GError) error = NULL;
+  g_autofree char *waf = NULL;
+  IdeBuildManager *build_manager;
+  IdeBuildSystem *build_system;
+  IdePipeline *pipeline;
+  IdeContext *context;
+  const char *python;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_WAF_RUN_COMMAND_PROVIDER (self));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  task = ide_task_new (self, cancellable, callback, user_data);
+  ide_task_set_source_tag (task, gbp_waf_run_command_provider_list_commands_async);
+
+  context = ide_object_get_context (IDE_OBJECT (self));
+  build_system = ide_build_system_from_context (context);
+
+  if (!GBP_IS_WAF_BUILD_SYSTEM (build_system))
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_NOT_SUPPORTED,
+                                 "Not a waf build system");
+      IDE_EXIT;
+    }
+
+  build_manager = ide_build_manager_from_context (context);
+  pipeline = ide_build_manager_get_pipeline (build_manager);
+
+  if (pipeline == NULL ||
+      !ide_pipeline_is_ready (pipeline) ||
+      ide_pipeline_get_phase (pipeline) < IDE_PIPELINE_PHASE_CONFIGURE)
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_NOT_SUPPORTED,
+                                 "Pipeline not ready, cannot list run commands");
+      IDE_EXIT;
+    }
+
+  waf = gbp_waf_build_system_locate_waf (GBP_WAF_BUILD_SYSTEM (build_system));
+  if (gbp_waf_build_system_wants_python2 (GBP_WAF_BUILD_SYSTEM (build_system), NULL))
+    python = "python2";
+  else
+    python = "python3";
+
+  launcher = ide_pipeline_create_launcher (pipeline, NULL);
+  ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT (python, waf, "list", "--color=no"));
+  /* There appears to be some installations that will write to stderr instead of stdout */
+  ide_subprocess_launcher_set_flags (launcher,
+                                     (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
+                                      G_SUBPROCESS_FLAGS_STDERR_MERGE));
+  ide_subprocess_launcher_set_cwd (launcher, ide_pipeline_get_srcdir (pipeline));
+
+  if (!(subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error)))
+    {
+      ide_task_return_error (task, g_steal_pointer (&error));
+      IDE_EXIT;
+    }
+
+  ide_subprocess_communicate_utf8_async (subprocess,
+                                         NULL,
+                                         cancellable,
+                                         gbp_waf_run_command_provider_list_cb,
+                                         g_steal_pointer (&task));
+
+  IDE_EXIT;
+}
+
+static GListModel *
+gbp_waf_run_command_provider_list_commands_finish (IdeRunCommandProvider *provider,
+                                                     GAsyncResult *result,
+                                                     GError **error)
+{
+  GListModel *ret;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_WAF_RUN_COMMAND_PROVIDER (provider));
+  g_assert (IDE_IS_TASK (result));
+
+  ret = ide_task_propagate_pointer (IDE_TASK (result), error);
+
+  IDE_RETURN (ret);
+}
+
+static void
+run_command_provider_iface_init (IdeRunCommandProviderInterface *iface)
+{
+  iface->list_commands_async = gbp_waf_run_command_provider_list_commands_async;
+  iface->list_commands_finish = gbp_waf_run_command_provider_list_commands_finish;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpWafRunCommandProvider, gbp_waf_run_command_provider, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_RUN_COMMAND_PROVIDER, 
run_command_provider_iface_init))
+
+static void
+gbp_waf_run_command_provider_class_init (GbpWafRunCommandProviderClass *klass)
+{
+}
+
+static void
+gbp_waf_run_command_provider_init (GbpWafRunCommandProvider *self)
+{
+}
diff --git a/src/plugins/waf/gbp-waf-run-command-provider.h b/src/plugins/waf/gbp-waf-run-command-provider.h
new file mode 100644
index 000000000..c37eca8e9
--- /dev/null
+++ b/src/plugins/waf/gbp-waf-run-command-provider.h
@@ -0,0 +1,32 @@
+/* gbp-waf-run-command-provider.h
+ *
+ * Copyright 2019 Alex Mitchell
+ * Copyright 2016-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_WAF_RUN_COMMAND_PROVIDER (gbp_waf_run_command_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpWafRunCommandProvider, gbp_waf_run_command_provider, GBP, WAF_RUN_COMMAND_PROVIDER, 
IdeObject)
+
+G_END_DECLS
diff --git a/src/plugins/waf/meson.build b/src/plugins/waf/meson.build
index de81df877..126535380 100644
--- a/src/plugins/waf/meson.build
+++ b/src/plugins/waf/meson.build
@@ -1,13 +1,21 @@
 if get_option('plugin_waf')
 
-install_data('waf_plugin.py', install_dir: plugindir)
-
-configure_file(
-          input: 'waf.plugin',
-         output: 'waf.plugin',
-  configuration: config_h,
-        install: true,
-    install_dir: plugindir,
+plugins_sources += files([
+  'waf-plugin.c',
+  'gbp-waf-build-system-discovery.c',
+  'gbp-waf-build-system.c',
+  'gbp-waf-build-target.c',
+  'gbp-waf-build-target-provider.c',
+  'gbp-waf-pipeline-addin.c',
+  'gbp-waf-run-command-provider.c',
+])
+
+plugin_waf_resources = gnome.compile_resources(
+  'waf-resources',
+  'waf.gresource.xml',
+  c_name: 'gbp_waf',
 )
 
+plugins_sources += plugin_waf_resources
+
 endif
diff --git a/src/plugins/waf/waf-plugin.c b/src/plugins/waf/waf-plugin.c
new file mode 100644
index 000000000..744d9cbe2
--- /dev/null
+++ b/src/plugins/waf/waf-plugin.c
@@ -0,0 +1,55 @@
+/* waf-plugin.c
+ *
+ * Copyright 2016-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 "waf-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-editor.h>
+#include <libide-gui.h>
+#include <libide-tree.h>
+
+#include "gbp-waf-build-system.h"
+#include "gbp-waf-build-system-discovery.h"
+#include "gbp-waf-build-target-provider.h"
+#include "gbp-waf-pipeline-addin.h"
+#include "gbp-waf-run-command-provider.h"
+
+_IDE_EXTERN void
+_gbp_waf_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_BUILD_SYSTEM,
+                                              GBP_TYPE_WAF_BUILD_SYSTEM);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_BUILD_SYSTEM_DISCOVERY,
+                                              GBP_TYPE_WAF_BUILD_SYSTEM_DISCOVERY);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_BUILD_TARGET_PROVIDER,
+                                              GBP_TYPE_WAF_BUILD_TARGET_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PIPELINE_ADDIN,
+                                              GBP_TYPE_WAF_PIPELINE_ADDIN);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_RUN_COMMAND_PROVIDER,
+                                              GBP_TYPE_WAF_RUN_COMMAND_PROVIDER);
+}
diff --git a/src/plugins/waf/waf.gresource.xml b/src/plugins/waf/waf.gresource.xml
new file mode 100644
index 000000000..c13976b99
--- /dev/null
+++ b/src/plugins/waf/waf.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/waf">
+    <file>waf.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/waf/waf.plugin b/src/plugins/waf/waf.plugin
index e7faad23c..49377123a 100644
--- a/src/plugins/waf/waf.plugin
+++ b/src/plugins/waf/waf.plugin
@@ -1,11 +1,10 @@
 [Plugin]
 Authors=Alex Mitchel, Christian Hergert
-Copyright=Copyright 2019 Alex Mitchell, 2019 Christian Hergert
+Copyright=Copyright 2019 Alex Mitchell, 2019-2022 Christian Hergert
 Description=Provides integration with the Waf build system
-Loader=python3
-Module=waf_plugin
-Name=Waf
+Embedded=_gbp_waf_register_types
+Module=waf
+Name=Waf Build System
 X-Category=buildsystems
 X-Project-File-Filter-Name=Waf (waf)
 X-Project-File-Filter-Pattern=wscript
-X-Builder-ABI=@PACKAGE_ABI@


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