[gnome-builder: 24/139] buildconfig: move .buildconfig support to plugin



commit b5d86ab78bdc8a2df5d8a4381267516008d332d3
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 15:21:13 2019 -0800

    buildconfig: move .buildconfig support to plugin
    
    This moves the .buildconfig configuration provider into a plugin to avoid
    the complications of having it directly in libide. It's still hidden, so
    that it cannot be disabled, but no longer clutters libide.

 src/libide/buildconfig/OVERVIEW.md                 | 27 -----------------
 src/libide/buildconfig/buildconfig.plugin          |  9 ------
 src/libide/buildconfig/meson.build                 | 21 -------------
 .../buildconfig/buildconfig-plugin.c}              | 17 +++++------
 src/plugins/buildconfig/buildconfig.gresource.xml  |  6 ++++
 src/plugins/buildconfig/buildconfig.plugin         |  9 ++++++
 .../ide-buildconfig-configuration-provider.c       | 35 +++++++++-------------
 .../ide-buildconfig-configuration-provider.h       |  2 +-
 .../buildconfig/ide-buildconfig-configuration.c    |  2 +-
 .../buildconfig/ide-buildconfig-configuration.h    |  9 +-----
 .../buildconfig/ide-buildconfig-pipeline-addin.c   | 10 +++----
 .../buildconfig/ide-buildconfig-pipeline-addin.h   |  2 +-
 src/plugins/buildconfig/meson.build                | 14 +++++++++
 13 files changed, 60 insertions(+), 103 deletions(-)
---
diff --git a/src/libide/buildconfig/ide-buildconfig-plugin.c b/src/plugins/buildconfig/buildconfig-plugin.c
similarity index 76%
rename from src/libide/buildconfig/ide-buildconfig-plugin.c
rename to src/plugins/buildconfig/buildconfig-plugin.c
index 816521779..c85cc12ed 100644
--- a/src/libide/buildconfig/ide-buildconfig-plugin.c
+++ b/src/plugins/buildconfig/buildconfig-plugin.c
@@ -1,4 +1,4 @@
-/* ide-buildsystem-plugin.c
+/* buildconfig-plugin.c
  *
  * Copyright 2016 Matthew Leeds <mleeds redhat com>
  *
@@ -18,19 +18,18 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#define G_LOG_DOMAIN "ide-buildsystem-plugin"
+#define G_LOG_DOMAIN "buildconfig-plugin"
 
 #include "config.h"
 
-#include "object-modules.h"
+#include <libpeas/peas.h>
+#include <libide-foundry.h>
 
-#include "buildconfig/ide-buildconfig-configuration-provider.h"
-#include "buildconfig/ide-buildconfig-pipeline-addin.h"
-#include "buildsystem/ide-build-pipeline-addin.h"
-#include "config/ide-configuration-provider.h"
+#include "ide-buildconfig-configuration-provider.h"
+#include "ide-buildconfig-pipeline-addin.h"
 
-void
-ide_buildconfig_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_buildconfig_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_CONFIGURATION_PROVIDER,
diff --git a/src/plugins/buildconfig/buildconfig.gresource.xml 
b/src/plugins/buildconfig/buildconfig.gresource.xml
new file mode 100644
index 000000000..73c7ff6c8
--- /dev/null
+++ b/src/plugins/buildconfig/buildconfig.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/buildconfig">
+    <file>buildconfig.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/buildconfig/buildconfig.plugin b/src/plugins/buildconfig/buildconfig.plugin
new file mode 100644
index 000000000..0bc4662b6
--- /dev/null
+++ b/src/plugins/buildconfig/buildconfig.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Authors=Christian Hergert <christian hergert me>
+Builtin=true
+Copyright=Copyright © 2015-2018 Christian Hergert
+Description=Support for .buildconfig files
+Embedded=_gbp_buildconfig_register_types
+Hidden=true
+Module=buildconfig
+Name=Buildconfig Support
diff --git a/src/libide/buildconfig/ide-buildconfig-configuration-provider.c 
b/src/plugins/buildconfig/ide-buildconfig-configuration-provider.c
similarity index 96%
rename from src/libide/buildconfig/ide-buildconfig-configuration-provider.c
rename to src/plugins/buildconfig/ide-buildconfig-configuration-provider.c
index 02135e192..d7e087d05 100644
--- a/src/libide/buildconfig/ide-buildconfig-configuration-provider.c
+++ b/src/plugins/buildconfig/ide-buildconfig-configuration-provider.c
@@ -27,17 +27,14 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
+#include <libide-foundry.h>
+#include <libide-threading.h>
+
 #include "ide-context.h"
 #include "ide-debug.h"
 
-#include "buildconfig/ide-buildconfig-configuration.h"
-#include "buildconfig/ide-buildconfig-configuration-provider.h"
-#include "config/ide-configuration-manager.h"
-#include "config/ide-configuration-provider.h"
-#include "config/ide-configuration.h"
-#include "buildsystem/ide-environment.h"
-#include "vcs/ide-vcs.h"
-#include "threading/ide-task.h"
+#include "ide-buildconfig-configuration.h"
+#include "ide-buildconfig-configuration-provider.h"
 
 #define DOT_BUILDCONFIG ".buildconfig"
 
@@ -193,17 +190,14 @@ ide_buildconfig_configuration_provider_create (IdeBuildconfigConfigurationProvid
 {
   g_autoptr(IdeConfiguration) config = NULL;
   g_autofree gchar *env_group = NULL;
-  IdeContext *context;
 
   g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
   g_assert (self->key_file != NULL);
   g_assert (config_id != NULL);
 
-  context = ide_object_get_context (IDE_OBJECT (self));
-
   config = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
-                         "context", context,
                          "id", config_id,
+                         "parent", self,
                          NULL);
 
   load_string (config, self->key_file, config_id, "config-opts", "config-opts");
@@ -294,9 +288,9 @@ ide_buildconfig_configuration_provider_load_async (IdeConfigurationProvider *pro
 add_default:
   /* "Default" is not translated because .buildconfig can be checked in */
   fallback = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
-                           "context", context,
                            "display-name", "Default",
                            "id", "default",
+                           "parent", self,
                            "runtime-id", "host",
                            "toolchain-id", "default",
                            NULL);
@@ -382,7 +376,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
     }
 
   context = ide_object_get_context (IDE_OBJECT (self));
-  manager = ide_context_get_configuration_manager (context);
+  manager = ide_configuration_manager_from_context (context);
   path = ide_context_build_filename (context, DOT_BUILDCONFIG, NULL);
   file = g_file_new_for_path (path);
 
@@ -409,7 +403,6 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
 
       config_id = ide_configuration_get_id (config);
       env_group = g_strdup_printf ("%s.environment", config_id);
-      env = ide_configuration_get_environment (config);
 
       /*
        * Track our known group names, so we can remove missing names after
@@ -586,13 +579,12 @@ ide_buildconfig_configuration_provider_delete (IdeConfigurationProvider *provide
   if (self->configs->len == 0)
     {
       g_autoptr(IdeConfiguration) new_config = NULL;
-      IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
 
       /* "Default" is not translated because .buildconfig can be checked in */
       new_config = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
-                                 "context", context,
                                  "display-name", "Default",
                                  "id", "default",
+                                 "parent", self,
                                  "runtime-id", "host",
                                  "toolchain-id", "default",
                                  NULL);
@@ -631,7 +623,7 @@ ide_buildconfig_configuration_provider_duplicate (IdeConfigurationProvider *prov
   context = ide_object_get_context (IDE_OBJECT (self));
   g_assert (IDE_IS_CONTEXT (context));
 
-  manager = ide_context_get_configuration_manager (context);
+  manager = ide_configuration_manager_from_context (context);
   g_assert (IDE_IS_CONFIGURATION_MANAGER (manager));
 
   config_id = ide_configuration_get_id (config);
@@ -648,8 +640,8 @@ ide_buildconfig_configuration_provider_duplicate (IdeConfigurationProvider *prov
 
   new_config = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
                              "id", new_config_id,
-                             "context", context,
                              "display-name", new_name,
+                             "parent", self,
                              NULL);
 
   ide_environment_copy_into (env, ide_configuration_get_environment (new_config), TRUE);
@@ -660,8 +652,7 @@ ide_buildconfig_configuration_provider_duplicate (IdeConfigurationProvider *prov
     {
       GParamSpec *pspec = pspecs[i];
 
-      if (g_str_equal (pspec->name, "context") ||
-          g_str_equal (pspec->name, "id") ||
+      if (g_str_equal (pspec->name, "id") ||
           g_str_equal (pspec->name, "display-name") ||
           g_type_is_a (pspec->value_type, G_TYPE_BOXED) ||
           g_type_is_a (pspec->value_type, G_TYPE_OBJECT))
@@ -727,6 +718,8 @@ ide_buildconfig_configuration_provider_removed (IdeConfigurationProvider *provid
 
   /* It's possible we already removed it by now */
   g_ptr_array_remove (self->configs, config);
+
+  ide_object_destroy (IDE_OBJECT (config));
 }
 
 static void
diff --git a/src/libide/buildconfig/ide-buildconfig-configuration-provider.h 
b/src/plugins/buildconfig/ide-buildconfig-configuration-provider.h
similarity index 97%
rename from src/libide/buildconfig/ide-buildconfig-configuration-provider.h
rename to src/plugins/buildconfig/ide-buildconfig-configuration-provider.h
index dd74d35e9..83fb0d7f5 100644
--- a/src/libide/buildconfig/ide-buildconfig-configuration-provider.h
+++ b/src/plugins/buildconfig/ide-buildconfig-configuration-provider.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include "ide-object.h"
+#include <libide-core.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/libide/buildconfig/ide-buildconfig-configuration.c 
b/src/plugins/buildconfig/ide-buildconfig-configuration.c
similarity index 98%
rename from src/libide/buildconfig/ide-buildconfig-configuration.c
rename to src/plugins/buildconfig/ide-buildconfig-configuration.c
index 6ae3c9ede..f4386a0c4 100644
--- a/src/libide/buildconfig/ide-buildconfig-configuration.c
+++ b/src/plugins/buildconfig/ide-buildconfig-configuration.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "buildconfig/ide-buildconfig-configuration.h"
+#include "ide-buildconfig-configuration.h"
 
 struct _IdeBuildconfigConfiguration
 {
diff --git a/src/libide/buildconfig/ide-buildconfig-configuration.h 
b/src/plugins/buildconfig/ide-buildconfig-configuration.h
similarity index 90%
rename from src/libide/buildconfig/ide-buildconfig-configuration.h
rename to src/plugins/buildconfig/ide-buildconfig-configuration.h
index 574be397a..f7700e698 100644
--- a/src/libide/buildconfig/ide-buildconfig-configuration.h
+++ b/src/plugins/buildconfig/ide-buildconfig-configuration.h
@@ -20,25 +20,18 @@
 
 #pragma once
 
-#include "ide-version-macros.h"
-
-#include "config/ide-configuration.h"
+#include <libide-foundry.h>
 
 G_BEGIN_DECLS
 
 #define IDE_TYPE_BUILDCONFIG_CONFIGURATION (ide_buildconfig_configuration_get_type())
 
-IDE_AVAILABLE_IN_3_32
 G_DECLARE_FINAL_TYPE (IdeBuildconfigConfiguration, ide_buildconfig_configuration, IDE, 
BUILDCONFIG_CONFIGURATION, IdeConfiguration)
 
-IDE_AVAILABLE_IN_3_32
 const gchar * const *ide_buildconfig_configuration_get_prebuild  (IdeBuildconfigConfiguration *self);
-IDE_AVAILABLE_IN_3_32
 void                 ide_buildconfig_configuration_set_prebuild  (IdeBuildconfigConfiguration *self,
                                                                   const gchar * const         *prebuild);
-IDE_AVAILABLE_IN_3_32
 const gchar * const *ide_buildconfig_configuration_get_postbuild (IdeBuildconfigConfiguration *self);
-IDE_AVAILABLE_IN_3_32
 void                 ide_buildconfig_configuration_set_postbuild (IdeBuildconfigConfiguration *self,
                                                                   const gchar * const         *postbuild);
 
diff --git a/src/libide/buildconfig/ide-buildconfig-pipeline-addin.c 
b/src/plugins/buildconfig/ide-buildconfig-pipeline-addin.c
similarity index 93%
rename from src/libide/buildconfig/ide-buildconfig-pipeline-addin.c
rename to src/plugins/buildconfig/ide-buildconfig-pipeline-addin.c
index 2ad766e80..f75032e68 100644
--- a/src/libide/buildconfig/ide-buildconfig-pipeline-addin.c
+++ b/src/plugins/buildconfig/ide-buildconfig-pipeline-addin.c
@@ -22,11 +22,11 @@
 
 #include "config.h"
 
-#include "ide-debug.h"
+#include <libide-foundry.h>
+#include <libide-threading.h>
 
-#include "buildconfig/ide-buildconfig-configuration.h"
-#include "buildconfig/ide-buildconfig-pipeline-addin.h"
-#include "subprocess/ide-subprocess-launcher.h"
+#include "ide-buildconfig-configuration.h"
+#include "ide-buildconfig-pipeline-addin.h"
 
 static void
 add_command (IdeBuildPipelineAddin  *addin,
@@ -61,7 +61,7 @@ add_command (IdeBuildPipelineAddin  *addin,
 
   ide_subprocess_launcher_set_environ (launcher, (const gchar * const *)env);
 
-  stage_id = ide_build_pipeline_connect_launcher (pipeline, phase, priority, launcher);
+  stage_id = ide_build_pipeline_attach_launcher (pipeline, phase, priority, launcher);
   ide_build_pipeline_addin_track (addin, stage_id);
 }
 
diff --git a/src/libide/buildconfig/ide-buildconfig-pipeline-addin.h 
b/src/plugins/buildconfig/ide-buildconfig-pipeline-addin.h
similarity index 95%
rename from src/libide/buildconfig/ide-buildconfig-pipeline-addin.h
rename to src/plugins/buildconfig/ide-buildconfig-pipeline-addin.h
index ce6038f63..2d01f444c 100644
--- a/src/libide/buildconfig/ide-buildconfig-pipeline-addin.h
+++ b/src/plugins/buildconfig/ide-buildconfig-pipeline-addin.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include "buildsystem/ide-build-pipeline-addin.h"
+#include <libide-foundry.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/buildconfig/meson.build b/src/plugins/buildconfig/meson.build
new file mode 100644
index 000000000..d1e51c7ae
--- /dev/null
+++ b/src/plugins/buildconfig/meson.build
@@ -0,0 +1,14 @@
+plugins_sources += files([
+  'buildconfig-plugin.c',
+  'ide-buildconfig-configuration.c',
+  'ide-buildconfig-configuration-provider.c',
+  'ide-buildconfig-pipeline-addin.c',
+])
+
+plugin_buildconfig_resources = gnome.compile_resources(
+  'buildconfig-resources',
+  'buildconfig.gresource.xml',
+  c_name: 'gbp_buildconfig',
+)
+
+plugins_sources += plugin_buildconfig_resources[0]


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