[gnome-builder/wip/chergert/pipeline-merge: 60/76] buildconfig: add IdeBuildconfigConfiguration
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/pipeline-merge: 60/76] buildconfig: add IdeBuildconfigConfiguration
- Date: Wed, 8 Feb 2017 20:23:10 +0000 (UTC)
commit f5bf9da07c58706c823e8b3eee7666ac5ade1781
Author: Christian Hergert <chergert redhat com>
Date: Sat Feb 4 11:32:16 2017 -0800
buildconfig: add IdeBuildconfigConfiguration
This moves some custom stuff (like command queues) to the buildconfig
subclass. We will also need to add a pipeline stage to attach these to
the proper build phase.
libide/Makefile.am | 2 +
.../ide-buildconfig-configuration-provider.c | 54 ++-----
libide/buildsystem/ide-buildconfig-configuration.c | 167 ++++++++++++++++++++
libide/buildsystem/ide-buildconfig-configuration.h | 39 +++++
libide/ide.h | 1 +
5 files changed, 220 insertions(+), 43 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index a45ede2..4d24c57 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -40,6 +40,7 @@ libide_1_0_la_public_headers = \
buildsystem/ide-build-stage-transfer.h \
buildsystem/ide-build-system.h \
buildsystem/ide-build-target.h \
+ buildsystem/ide-buildconfig-configuration.h \
buildsystem/ide-buildconfig-configuration-provider.h \
buildsystem/ide-configuration-manager.h \
buildsystem/ide-configuration.h \
@@ -211,6 +212,7 @@ libide_1_0_la_public_sources = \
buildsystem/ide-build-stage-transfer.c \
buildsystem/ide-build-system.c \
buildsystem/ide-build-target.c \
+ buildsystem/ide-buildconfig-configuration.c \
buildsystem/ide-buildconfig-configuration-provider.c \
buildsystem/ide-configuration-manager.c \
buildsystem/ide-configuration.c \
diff --git a/libide/buildsystem/ide-buildconfig-configuration-provider.c
b/libide/buildsystem/ide-buildconfig-configuration-provider.c
index 5529758..b8bab0b 100644
--- a/libide/buildsystem/ide-buildconfig-configuration-provider.c
+++ b/libide/buildsystem/ide-buildconfig-configuration-provider.c
@@ -25,8 +25,7 @@
#include "ide-internal.h"
#include "ide-macros.h"
-#include "buildsystem/ide-build-command.h"
-#include "buildsystem/ide-build-command-queue.h"
+#include "buildsystem/ide-buildconfig-configuration.h"
#include "buildsystem/ide-buildconfig-configuration-provider.h"
#include "buildsystem/ide-configuration-manager.h"
#include "buildsystem/ide-configuration-provider.h"
@@ -347,36 +346,6 @@ load_environ (IdeConfiguration *configuration,
}
}
-static void
-load_command_queue (IdeBuildCommandQueue *cmdq,
- GKeyFile *key_file,
- const gchar *group,
- const gchar *name)
-
-{
- g_auto(GStrv) commands = NULL;
-
- g_assert (IDE_IS_BUILD_COMMAND_QUEUE (cmdq));
- g_assert (key_file != NULL);
- g_assert (group != NULL);
- g_assert (name != NULL);
-
- commands = g_key_file_get_string_list (key_file, group, name, NULL, NULL);
-
- if (commands != NULL)
- {
- for (guint i = 0; commands [i]; i++)
- {
- g_autoptr(IdeBuildCommand) command = NULL;
-
- command = g_object_new (IDE_TYPE_BUILD_COMMAND,
- "command-text", commands [i],
- NULL);
- ide_build_command_queue_append (cmdq, command);
- }
- }
-}
-
static gboolean
ide_buildconfig_configuration_provider_load_group (IdeBuildconfigConfigurationProvider *self,
GKeyFile *key_file,
@@ -393,7 +362,7 @@ ide_buildconfig_configuration_provider_load_group (IdeBuildconfigConfigurationPr
context = ide_object_get_context (IDE_OBJECT (self->manager));
- configuration = g_object_new (IDE_TYPE_CONFIGURATION,
+ configuration = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
"id", group,
"context", context,
NULL);
@@ -407,20 +376,20 @@ ide_buildconfig_configuration_provider_load_group (IdeBuildconfigConfigurationPr
if (g_key_file_has_key (key_file, group, "prebuild", NULL))
{
- g_autoptr(IdeBuildCommandQueue) cmdq = NULL;
+ g_auto(GStrv) commands = NULL;
- cmdq = ide_build_command_queue_new ();
- load_command_queue (cmdq, key_file, group, "prebuild");
- _ide_configuration_set_prebuild (configuration, cmdq);
+ commands = g_key_file_get_string_list (key_file, group, "prebuild", NULL, NULL);
+ ide_buildconfig_configuration_set_prebuild (IDE_BUILDCONFIG_CONFIGURATION (configuration),
+ (const gchar * const *)commands);
}
if (g_key_file_has_key (key_file, group, "postbuild", NULL))
{
- g_autoptr(IdeBuildCommandQueue) cmdq = NULL;
+ g_auto(GStrv) commands = NULL;
- cmdq = ide_build_command_queue_new ();
- load_command_queue (cmdq, key_file, group, "postbuild");
- _ide_configuration_set_postbuild (configuration, cmdq);
+ commands = g_key_file_get_string_list (key_file, group, "postbuild", NULL, NULL);
+ ide_buildconfig_configuration_set_postbuild (IDE_BUILDCONFIG_CONFIGURATION (configuration),
+ (const gchar * const *)commands);
}
env_group = g_strdup_printf ("%s.environment", group);
@@ -532,12 +501,11 @@ ide_buildconfig_configuration_provider_load_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- IdeBuildconfigConfigurationProvider *self = (IdeBuildconfigConfigurationProvider *)object;
GError *error = NULL;
IDE_ENTRY;
- g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (self));
+ g_assert (IDE_IS_BUILDCONFIG_CONFIGURATION_PROVIDER (object));
g_assert (G_IS_TASK (result));
if (!g_task_propagate_boolean (G_TASK (result), &error))
diff --git a/libide/buildsystem/ide-buildconfig-configuration.c
b/libide/buildsystem/ide-buildconfig-configuration.c
new file mode 100644
index 0000000..40b5a57
--- /dev/null
+++ b/libide/buildsystem/ide-buildconfig-configuration.c
@@ -0,0 +1,167 @@
+/* ide-buildconfig-configuration.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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "buildsystem/ide-buildconfig-configuration.h"
+
+struct _IdeBuildconfigConfiguration
+{
+ IdeConfiguration parent_instance;
+ gchar **prebuild;
+ gchar **postbuild;
+};
+
+enum {
+ PROP_0,
+ PROP_PREBUILD,
+ PROP_POSTBUILD,
+ N_PROPS
+};
+
+G_DEFINE_TYPE (IdeBuildconfigConfiguration, ide_buildconfig_configuration, IDE_TYPE_CONFIGURATION)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+ide_buildconfig_configuration_finalize (GObject *object)
+{
+ IdeBuildconfigConfiguration *self = (IdeBuildconfigConfiguration *)object;
+
+ g_clear_pointer (&self->prebuild, g_strfreev);
+ g_clear_pointer (&self->postbuild, g_strfreev);
+
+ G_OBJECT_CLASS (ide_buildconfig_configuration_parent_class)->finalize (object);
+}
+
+static void
+ide_buildconfig_configuration_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeBuildconfigConfiguration *self = (IdeBuildconfigConfiguration *)object;
+
+ switch (prop_id)
+ {
+ case PROP_PREBUILD:
+ g_value_set_boxed (value, ide_buildconfig_configuration_get_prebuild (self));
+ break;
+
+ case PROP_POSTBUILD:
+ g_value_set_boxed (value, ide_buildconfig_configuration_get_postbuild (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_buildconfig_configuration_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeBuildconfigConfiguration *self = (IdeBuildconfigConfiguration *)object;
+
+ switch (prop_id)
+ {
+ case PROP_PREBUILD:
+ ide_buildconfig_configuration_set_prebuild (self, g_value_get_boxed (value));
+ break;
+
+ case PROP_POSTBUILD:
+ ide_buildconfig_configuration_set_postbuild (self, g_value_get_boxed (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_buildconfig_configuration_class_init (IdeBuildconfigConfigurationClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ide_buildconfig_configuration_finalize;
+ object_class->get_property = ide_buildconfig_configuration_get_property;
+ object_class->set_property = ide_buildconfig_configuration_set_property;
+
+ properties [PROP_PREBUILD] =
+ g_param_spec_boxed ("prebuild", NULL, NULL,
+ G_TYPE_STRV,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ properties [PROP_POSTBUILD] =
+ g_param_spec_boxed ("postbuild", NULL, NULL,
+ G_TYPE_STRV,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+ide_buildconfig_configuration_init (IdeBuildconfigConfiguration *self)
+{
+}
+
+const gchar * const *
+ide_buildconfig_configuration_get_prebuild (IdeBuildconfigConfiguration *self)
+{
+ g_return_val_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION (self), NULL);
+
+ return (const gchar * const *)self->prebuild;
+}
+
+const gchar * const *
+ide_buildconfig_configuration_get_postbuild (IdeBuildconfigConfiguration *self)
+{
+ g_return_val_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION (self), NULL);
+
+ return (const gchar * const *)self->prebuild;
+}
+
+void
+ide_buildconfig_configuration_set_prebuild (IdeBuildconfigConfiguration *self,
+ const gchar * const *prebuild)
+{
+ g_return_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION (self));
+
+ if (self->prebuild != (gchar **)prebuild)
+ {
+ g_strfreev (self->prebuild);
+ self->prebuild = g_strdupv ((gchar **)prebuild);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PREBUILD]);
+ }
+}
+
+void
+ide_buildconfig_configuration_set_postbuild (IdeBuildconfigConfiguration *self,
+ const gchar * const *postbuild)
+{
+ g_return_if_fail (IDE_IS_BUILDCONFIG_CONFIGURATION (self));
+
+ if (self->postbuild != (gchar **)postbuild)
+ {
+ g_strfreev (self->postbuild);
+ self->postbuild = g_strdupv ((gchar **)postbuild);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_POSTBUILD]);
+ }
+}
diff --git a/libide/buildsystem/ide-buildconfig-configuration.h
b/libide/buildsystem/ide-buildconfig-configuration.h
new file mode 100644
index 0000000..36eff2c
--- /dev/null
+++ b/libide/buildsystem/ide-buildconfig-configuration.h
@@ -0,0 +1,39 @@
+/* ide-buildconfig-configuration.h
+ *
+ * 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/>.
+ */
+
+#ifndef IDE_BUILDCONFIG_CONFIGURATION_H
+#define IDE_BUILDCONFIG_CONFIGURATION_H
+
+#include "buildsystem/ide-configuration.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_BUILDCONFIG_CONFIGURATION (ide_buildconfig_configuration_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeBuildconfigConfiguration, ide_buildconfig_configuration, IDE,
BUILDCONFIG_CONFIGURATION, IdeConfiguration)
+
+const gchar * const *ide_buildconfig_configuration_get_prebuild (IdeBuildconfigConfiguration *self);
+void ide_buildconfig_configuration_set_prebuild (IdeBuildconfigConfiguration *self,
+ const gchar * const *prebuild);
+const gchar * const *ide_buildconfig_configuration_get_postbuild (IdeBuildconfigConfiguration *self);
+void ide_buildconfig_configuration_set_postbuild (IdeBuildconfigConfiguration *self,
+ const gchar * const *postbuild);
+
+G_END_DECLS
+
+#endif /* IDE_BUILDCONFIG_CONFIGURATION_H */
diff --git a/libide/ide.h b/libide/ide.h
index ab9ed5e..f0c9b97 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
#include "buildsystem/ide-build-stage-transfer.h"
#include "buildsystem/ide-build-system.h"
#include "buildsystem/ide-build-target.h"
+#include "buildsystem/ide-buildconfig-configuration.h"
#include "buildsystem/ide-buildconfig-configuration-provider.h"
#include "buildsystem/ide-configuration-manager.h"
#include "buildsystem/ide-configuration.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]