[gnome-builder] plugins/autotools: port to GTK 4



commit ab9220793b063f94384648c6c2384418dcd137e9
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 22:09:02 2022 -0700

    plugins/autotools: port to GTK 4
    
     - Cleanup title in file browser
     - Remove dazzle usage including counters
     - Port to updated pipeline API

 src/plugins/autotools/autotools.plugin             |  2 +-
 src/plugins/autotools/ide-autotools-build-system.c |  9 ++--
 src/plugins/autotools/ide-autotools-make-stage.c   |  2 +-
 .../autotools/ide-autotools-makecache-stage.c      | 32 ++++++-----
 .../autotools/ide-autotools-pipeline-addin.c       |  2 +-
 src/plugins/autotools/ide-makecache-target.c       | 11 ++--
 src/plugins/autotools/ide-makecache.c              | 63 ++++++++++------------
 src/plugins/autotools/ide-makecache.h              |  1 +
 8 files changed, 58 insertions(+), 64 deletions(-)
---
diff --git a/src/plugins/autotools/autotools.plugin b/src/plugins/autotools/autotools.plugin
index 93cbe5b98..45fe8e6f4 100644
--- a/src/plugins/autotools/autotools.plugin
+++ b/src/plugins/autotools/autotools.plugin
@@ -7,5 +7,5 @@ Embedded=_ide_autotools_register_types
 Hidden=true
 Module=autotools
 Name=Autotools
-X-Project-File-Filter-Name=Autotools Project (configure.ac)
+X-Project-File-Filter-Name=Autotools (configure.ac)
 X-Project-File-Filter-Pattern=configure.ac,configure.in
diff --git a/src/plugins/autotools/ide-autotools-build-system.c 
b/src/plugins/autotools/ide-autotools-build-system.c
index 8ab29a0ab..4daa8eceb 100644
--- a/src/plugins/autotools/ide-autotools-build-system.c
+++ b/src/plugins/autotools/ide-autotools-build-system.c
@@ -24,9 +24,10 @@
 
 #include <gio/gio.h>
 #include <gtksourceview/gtksource.h>
+#include <string.h>
+
 #include <libide-foundry.h>
 #include <libide-vcs.h>
-#include <string.h>
 
 #include "ide-autotools-build-system.h"
 #include "ide-autotools-makecache-stage.h"
@@ -74,8 +75,8 @@ is_configure (GFile *file)
   g_assert (G_IS_FILE (file));
 
   name = g_file_get_basename (file);
-  return dzl_str_equal0 (name, "configure.ac") ||
-         dzl_str_equal0 (name, "configure.in");
+  return ide_str_equal0 (name, "configure.ac") ||
+         ide_str_equal0 (name, "configure.in");
 }
 
 static gboolean
@@ -237,7 +238,7 @@ looks_like_makefile (IdeBuffer *buffer)
 
       lang_id = gtk_source_language_get_id (language);
 
-      if (dzl_str_equal0 (lang_id, "automake") || dzl_str_equal0 (lang_id, "makefile"))
+      if (ide_str_equal0 (lang_id, "automake") || ide_str_equal0 (lang_id, "makefile"))
         return TRUE;
     }
 
diff --git a/src/plugins/autotools/ide-autotools-make-stage.c 
b/src/plugins/autotools/ide-autotools-make-stage.c
index 139be69a7..b826fe45e 100644
--- a/src/plugins/autotools/ide-autotools-make-stage.c
+++ b/src/plugins/autotools/ide-autotools-make-stage.c
@@ -138,7 +138,7 @@ create_launcher (IdeAutotoolsMakeStage  *self,
    * we can parse the directory changes (Entering directory foo). Otherwise,
    * we can't really give users diagnostics that are in the proper directory.
    */
-  if (dzl_str_equal0 ("all", make_target))
+  if (ide_str_equal0 ("all", make_target))
     {
       ide_subprocess_launcher_setenv (launcher, "LANG", "C.UTF-8", TRUE);
       ide_subprocess_launcher_setenv (launcher, "LC_ALL", "C.UTF-8", TRUE);
diff --git a/src/plugins/autotools/ide-autotools-makecache-stage.c 
b/src/plugins/autotools/ide-autotools-makecache-stage.c
index c9f292e57..abb31fefc 100644
--- a/src/plugins/autotools/ide-autotools-makecache-stage.c
+++ b/src/plugins/autotools/ide-autotools-makecache-stage.c
@@ -73,14 +73,15 @@ ide_autotools_makecache_stage_makecache_cb (GObject      *object,
 
 static void
 ide_autotools_makecache_stage_build_cb (GObject      *object,
-                                          GAsyncResult *result,
-                                          gpointer      user_data)
+                                        GAsyncResult *result,
+                                        gpointer      user_data)
 {
   IdeAutotoolsMakecacheStage *self = (IdeAutotoolsMakecacheStage *)object;
   IdePipelineStage *stage = (IdePipelineStage *)object;
   g_autoptr(IdeTask) task = user_data;
   g_autoptr(GError) error = NULL;
   GCancellable *cancellable;
+  IdePipeline *pipeline;
 
   IDE_ENTRY;
 
@@ -97,7 +98,10 @@ ide_autotools_makecache_stage_build_cb (GObject      *object,
     }
 
   cancellable = ide_task_get_cancellable (task);
+  pipeline = ide_task_get_task_data (task);
+
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+  g_assert (IDE_IS_PIPELINE (pipeline));
 
   /*
    * Now that we have our makecache file created, we can mmap() it into our
@@ -105,6 +109,7 @@ ide_autotools_makecache_stage_build_cb (GObject      *object,
    */
 
   ide_makecache_new_for_cache_file_async (self->runtime,
+                                          pipeline,
                                           self->cache_file,
                                           cancellable,
                                           ide_autotools_makecache_stage_makecache_cb,
@@ -114,11 +119,11 @@ ide_autotools_makecache_stage_build_cb (GObject      *object,
 }
 
 static void
-ide_autotools_makecache_stage_build_async (IdePipelineStage       *stage,
-                                             IdePipeline    *pipeline,
-                                             GCancellable        *cancellable,
-                                             GAsyncReadyCallback  callback,
-                                             gpointer             user_data)
+ide_autotools_makecache_stage_build_async (IdePipelineStage    *stage,
+                                           IdePipeline         *pipeline,
+                                           GCancellable        *cancellable,
+                                           GAsyncReadyCallback  callback,
+                                           gpointer             user_data)
 {
   IdeAutotoolsMakecacheStage *self = (IdeAutotoolsMakecacheStage *)stage;
   g_autoptr(IdeTask) task = NULL;
@@ -131,6 +136,7 @@ ide_autotools_makecache_stage_build_async (IdePipelineStage       *stage,
 
   task = ide_task_new (self, cancellable, callback, user_data);
   ide_task_set_source_tag (task, ide_autotools_makecache_stage_build_async);
+  ide_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
 
   /*
    * First we need to build our launcher (performed by our parent class).
@@ -139,18 +145,18 @@ ide_autotools_makecache_stage_build_async (IdePipelineStage       *stage,
    */
 
   IDE_PIPELINE_STAGE_CLASS (ide_autotools_makecache_stage_parent_class)->build_async (stage,
-                                                                                        pipeline,
-                                                                                        cancellable,
-                                                                                        
ide_autotools_makecache_stage_build_cb,
-                                                                                        g_steal_pointer 
(&task));
+                                                                                      pipeline,
+                                                                                      cancellable,
+                                                                                      
ide_autotools_makecache_stage_build_cb,
+                                                                                      g_steal_pointer 
(&task));
 
   IDE_EXIT;
 }
 
 static gboolean
 ide_autotools_makecache_stage_build_finish (IdePipelineStage  *stage,
-                                              GAsyncResult   *result,
-                                              GError        **error)
+                                            GAsyncResult      *result,
+                                            GError           **error)
 {
   gboolean ret;
 
diff --git a/src/plugins/autotools/ide-autotools-pipeline-addin.c 
b/src/plugins/autotools/ide-autotools-pipeline-addin.c
index f1e8a3e68..a38602d85 100644
--- a/src/plugins/autotools/ide-autotools-pipeline-addin.c
+++ b/src/plugins/autotools/ide-autotools-pipeline-addin.c
@@ -273,7 +273,7 @@ register_configure_stage (IdeAutotoolsPipelineAddin  *self,
       ide_subprocess_launcher_push_argv (launcher, prefix_arg);
     }
 
-  if (!dzl_str_empty0 (config_opts))
+  if (!ide_str_empty0 (config_opts))
     {
       g_auto(GStrv) argv = NULL;
       gint argc = 0;
diff --git a/src/plugins/autotools/ide-makecache-target.c b/src/plugins/autotools/ide-makecache-target.c
index d60f03af4..456584bc8 100644
--- a/src/plugins/autotools/ide-makecache-target.c
+++ b/src/plugins/autotools/ide-makecache-target.c
@@ -20,16 +20,15 @@
 
 #define G_LOG_DOMAIN "ide-makecache-target"
 
-#include <dazzle.h>
+#include "config.h"
+
+#include <libide-io.h>
 
 #include "ide-makecache-target.h"
 
 G_DEFINE_BOXED_TYPE (IdeMakecacheTarget, ide_makecache_target,
                      ide_makecache_target_ref, ide_makecache_target_unref)
 
-DZL_DEFINE_COUNTER (instances, "IdeMakecacheTarget", "Instances",
-                    "Number of IdeMakecacheTarget instances.")
-
 struct _IdeMakecacheTarget
 {
   volatile gint  ref_count;
@@ -49,8 +48,6 @@ ide_makecache_target_unref (IdeMakecacheTarget *self)
       g_free (self->subdir);
       g_free (self->target);
       g_slice_free (IdeMakecacheTarget, self);
-
-      DZL_COUNTER_DEC (instances);
     }
 }
 
@@ -81,8 +78,6 @@ ide_makecache_target_new (const gchar *subdir,
   self->subdir = g_strdup (subdir);
   self->target = g_strdup (target);
 
-  DZL_COUNTER_INC (instances);
-
   return self;
 }
 
diff --git a/src/plugins/autotools/ide-makecache.c b/src/plugins/autotools/ide-makecache.c
index 58a8e4c41..c68fbf4f7 100644
--- a/src/plugins/autotools/ide-makecache.c
+++ b/src/plugins/autotools/ide-makecache.c
@@ -24,7 +24,6 @@
 #include "config.h"
 
 #include <ctype.h>
-#include <dazzle.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <gio/gio.h>
@@ -33,6 +32,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <libide-io.h>
 #include <libide-foundry.h>
 #include <libide-vcs.h>
 
@@ -51,10 +51,11 @@ struct _IdeMakecache
 
   GFile        *parent;
   GMappedFile  *mapped;
-  DzlTaskCache *file_targets_cache;
-  DzlTaskCache *file_flags_cache;
+  IdeTaskCache *file_targets_cache;
+  IdeTaskCache *file_flags_cache;
   GPtrArray    *build_targets;
   IdeRuntime   *runtime;
+  IdePipeline  *pipeline;
   const gchar  *make_name;
 };
 
@@ -84,8 +85,6 @@ typedef struct
 
 G_DEFINE_FINAL_TYPE (IdeMakecache, ide_makecache, IDE_TYPE_OBJECT)
 
-DZL_DEFINE_COUNTER (instances, "IdeMakecache", "Instances", "The number of IdeMakecache")
-
 static void
 get_build_targets_free (GetBuildTargets *data)
 {
@@ -641,7 +640,7 @@ ide_makecache_get_file_flags_worker (GTask        *task,
 
   IDE_ENTRY;
 
-  g_assert (DZL_IS_TASK_CACHE (source_object));
+  g_assert (IDE_IS_TASK_CACHE (source_object));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
   g_assert (G_IS_TASK (task));
   g_assert (lookup != NULL);
@@ -710,11 +709,8 @@ ide_makecache_get_file_flags_worker (GTask        *task,
       }
 #endif
 
-      launcher = ide_runtime_create_launcher (lookup->self->runtime, &error);
-
-      if (launcher == NULL)
+      if (!(launcher = ide_pipeline_create_launcher (lookup->self->pipeline, &error)))
         {
-          g_assert (error != NULL);
           g_task_return_error (task, g_steal_pointer (&error));
           IDE_EXIT;
         }
@@ -830,7 +826,7 @@ ide_makecache_get_file_targets_worker (GTask        *task,
 
   IDE_ENTRY;
 
-  g_assert (DZL_IS_TASK_CACHE (source_object));
+  g_assert (IDE_IS_TASK_CACHE (source_object));
   g_assert (G_IS_TASK (task));
   g_assert (lookup != NULL);
   g_assert (lookup->mapped != NULL);
@@ -902,7 +898,7 @@ ide_makecache_get_file_targets_worker (GTask        *task,
 }
 
 static void
-ide_makecache_get_file_targets_dispatch (DzlTaskCache  *cache,
+ide_makecache_get_file_targets_dispatch (IdeTaskCache  *cache,
                                          gconstpointer  key,
                                          GTask         *task,
                                          gpointer       user_data)
@@ -911,7 +907,7 @@ ide_makecache_get_file_targets_dispatch (DzlTaskCache  *cache,
   FileTargetsLookup *lookup;
   GFile *file = (GFile *)key;
 
-  g_assert (DZL_IS_TASK_CACHE (cache));
+  g_assert (IDE_IS_TASK_CACHE (cache));
   g_assert (IDE_IS_MAKECACHE (self));
   g_assert (G_IS_FILE (file));
   g_assert (G_IS_TASK (task));
@@ -994,7 +990,7 @@ ide_makecache_get_file_flags__get_targets_cb (GObject      *object,
 }
 
 static void
-ide_makecache_get_file_flags_dispatch (DzlTaskCache  *cache,
+ide_makecache_get_file_flags_dispatch (IdeTaskCache  *cache,
                                        gconstpointer  key,
                                        GTask         *task,
                                        gpointer       user_data)
@@ -1045,14 +1041,13 @@ ide_makecache_finalize (GObject *object)
   g_clear_object (&self->file_targets_cache);
   g_clear_object (&self->file_flags_cache);
   g_clear_object (&self->runtime);
+  g_clear_object (&self->pipeline);
   g_clear_object (&self->parent);
 
   g_clear_pointer (&self->mapped, g_mapped_file_unref);
   g_clear_pointer (&self->build_targets, g_ptr_array_unref);
 
   G_OBJECT_CLASS (ide_makecache_parent_class)->finalize (object);
-
-  DZL_COUNTER_DEC (instances);
 }
 
 static void
@@ -1066,11 +1061,9 @@ ide_makecache_class_init (IdeMakecacheClass *klass)
 static void
 ide_makecache_init (IdeMakecache *self)
 {
-  DZL_COUNTER_INC (instances);
-
   self->make_name = "make";
 
-  self->file_targets_cache = dzl_task_cache_new ((GHashFunc)g_file_hash,
+  self->file_targets_cache = ide_task_cache_new ((GHashFunc)g_file_hash,
                                                  (GEqualFunc)g_file_equal,
                                                  g_object_ref,
                                                  g_object_unref,
@@ -1081,9 +1074,9 @@ ide_makecache_init (IdeMakecache *self)
                                                  self,
                                                  NULL);
 
-  dzl_task_cache_set_name (self->file_targets_cache, "makecache: file-targets-cache");
+  ide_task_cache_set_name (self->file_targets_cache, "makecache: file-targets-cache");
 
-  self->file_flags_cache = dzl_task_cache_new ((GHashFunc)g_file_hash,
+  self->file_flags_cache = ide_task_cache_new ((GHashFunc)g_file_hash,
                                                (GEqualFunc)g_file_equal,
                                                g_object_ref,
                                                g_object_unref,
@@ -1094,7 +1087,7 @@ ide_makecache_init (IdeMakecache *self)
                                                self,
                                                NULL);
 
-  dzl_task_cache_set_name (self->file_flags_cache, "makecache: file-flags-cache");
+  ide_task_cache_set_name (self->file_flags_cache, "makecache: file-flags-cache");
 }
 
 static void
@@ -1121,6 +1114,7 @@ ide_makecache_validate_worker (GTask        *task,
 
 void
 ide_makecache_new_for_cache_file_async (IdeRuntime          *runtime,
+                                        IdePipeline         *pipeline,
                                         GFile               *cache_file,
                                         GCancellable        *cancellable,
                                         GAsyncReadyCallback  callback,
@@ -1136,6 +1130,7 @@ ide_makecache_new_for_cache_file_async (IdeRuntime          *runtime,
   IDE_ENTRY;
 
   g_return_if_fail (IDE_IS_RUNTIME (runtime));
+  g_return_if_fail (IDE_IS_PIPELINE (pipeline));
   g_return_if_fail (G_IS_FILE (cache_file));
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
@@ -1186,6 +1181,7 @@ ide_makecache_new_for_cache_file_async (IdeRuntime          *runtime,
   self->parent = g_steal_pointer (&parent);
   self->mapped = g_steal_pointer (&mapped);
   self->runtime = g_object_ref (runtime);
+  self->pipeline = g_object_ref (pipeline);
 
   if (ide_runtime_contains_program_in_path (runtime, "gmake", NULL))
     self->make_name = "gmake";
@@ -1217,12 +1213,12 @@ ide_makecache_get_file_targets__task_cache_get_cb (GObject      *object,
                                                    GAsyncResult *result,
                                                    gpointer      user_data)
 {
-  DzlTaskCache *cache = (DzlTaskCache *)object;
+  IdeTaskCache *cache = (IdeTaskCache *)object;
   g_autoptr(GTask) task = user_data;
   g_autoptr(GError) error = NULL;
   GPtrArray *ret;
 
-  if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
+  if (!(ret = ide_task_cache_get_finish (cache, result, &error)))
     {
       g_assert (error != NULL);
       g_task_return_error (task, g_steal_pointer (&error));
@@ -1248,7 +1244,7 @@ ide_makecache_get_file_targets_async (IdeMakecache        *self,
 
   task = g_task_new (self, cancellable, callback, user_data);
 
-  dzl_task_cache_get_async (self->file_targets_cache,
+  ide_task_cache_get_async (self->file_targets_cache,
                             file,
                             FALSE,
                             cancellable,
@@ -1288,12 +1284,12 @@ ide_makecache_get_file_flags__task_cache_get_cb (GObject      *object,
                                                  GAsyncResult *result,
                                                  gpointer      user_data)
 {
-  DzlTaskCache *cache = (DzlTaskCache *)object;
+  IdeTaskCache *cache = (IdeTaskCache *)object;
   g_autoptr(GTask) task = user_data;
   g_autoptr(GError) error = NULL;
   gchar **ret;
 
-  if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
+  if (!(ret = ide_task_cache_get_finish (cache, result, &error)))
     {
       g_assert (error != NULL);
       g_task_return_error (task, g_steal_pointer (&error));
@@ -1319,7 +1315,7 @@ ide_makecache_get_file_flags_async (IdeMakecache        *self,
 
   task = g_task_new (self, cancellable, callback, user_data);
 
-  dzl_task_cache_get_async (self->file_flags_cache,
+  ide_task_cache_get_async (self->file_flags_cache,
                             file,
                             FALSE,
                             cancellable,
@@ -1452,7 +1448,7 @@ find_install_dir (const gchar *key,
   const gchar *path = NULL;
 
   if (g_str_has_prefix (key, "nodist_"))
-    key += DZL_LITERAL_LENGTH ("nodist_");
+    key += strlen ("nodist_");
 
   parts = g_strsplit (key, "_", 2);
   dirkey = parts[0];
@@ -1709,7 +1705,6 @@ ide_makecache_get_build_targets_async (IdeMakecache        *self,
 {
   g_autoptr(GTask) task = NULL;
   GetBuildTargets *data;
-  IdeRuntime *runtime;
   GPtrArray *ret;
   guint i;
 
@@ -1725,12 +1720,8 @@ ide_makecache_get_build_targets_async (IdeMakecache        *self,
   data->context = ide_object_ref_context (IDE_OBJECT (self));
   data->configmgr = ide_config_manager_from_context (data->context);
   data->config = ide_config_manager_get_current (data->configmgr);
-
-  if ((runtime = ide_config_get_runtime (data->config)))
-    {
-      data->runtime = g_object_ref (runtime);
-      data->launcher = ide_runtime_create_launcher (runtime, NULL);
-    }
+  data->runtime = g_object_ref (self->runtime);
+  data->launcher = ide_pipeline_create_launcher (self->pipeline, NULL);
 
   g_task_set_task_data (task, data, (GDestroyNotify)get_build_targets_free);
 
diff --git a/src/plugins/autotools/ide-makecache.h b/src/plugins/autotools/ide-makecache.h
index 75604b247..d9dd9cfc3 100644
--- a/src/plugins/autotools/ide-makecache.h
+++ b/src/plugins/autotools/ide-makecache.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (IdeMakecache, ide_makecache, IDE, MAKECACHE, IdeObject)
 
 void                 ide_makecache_new_for_cache_file_async  (IdeRuntime           *runtime,
+                                                              IdePipeline          *pipeline,
                                                               GFile                *cache_file,
                                                               GCancellable         *cancellable,
                                                               GAsyncReadyCallback   callback,


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