[gnome-builder] build-system: port to using IdeConfiguration
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build-system: port to using IdeConfiguration
- Date: Mon, 15 Feb 2016 04:59:32 +0000 (UTC)
commit 3070914d228b5f7a0dc50af9b1895e3180f8a429
Author: Christian Hergert <chergert redhat com>
Date: Sun Feb 14 20:48:45 2016 -0800
build-system: port to using IdeConfiguration
libide/ide-build-system.c | 63 +++++++++--------
libide/ide-build-system.h | 6 +-
libide/ide-builder.c | 175 ++++++++++++++++++++++++++++++++++++++-------
libide/ide-builder.h | 29 ++++----
4 files changed, 198 insertions(+), 75 deletions(-)
---
diff --git a/libide/ide-build-system.c b/libide/ide-build-system.c
index 90b7f33..e2cf3b3 100644
--- a/libide/ide-build-system.c
+++ b/libide/ide-build-system.c
@@ -19,10 +19,14 @@
#include <glib/gi18n.h>
#include "ide-build-system.h"
+#include "ide-configuration.h"
#include "ide-context.h"
#include "ide-device.h"
+#include "ide-device-manager.h"
#include "ide-file.h"
#include "ide-object.h"
+#include "ide-runtime.h"
+#include "ide-runtime-manager.h"
typedef struct
{
@@ -104,9 +108,28 @@ ide_build_system_get_build_flags_finish (IdeBuildSystem *self,
return g_new0 (gchar*, 1);
}
+static IdeBuilder *
+ide_build_system_real_get_builder (IdeBuildSystem *self,
+ IdeConfiguration *configuration,
+ GError **error)
+{
+ g_assert (IDE_IS_BUILD_SYSTEM (self));
+ g_assert (IDE_IS_CONFIGURATION (configuration));
+
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("%s() is not supported on %s build system."),
+ G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (self)));
+
+ return NULL;
+}
+
static void
ide_build_system_default_init (IdeBuildSystemInterface *iface)
{
+ iface->get_builder = ide_build_system_real_get_builder;
+
properties [PROP_PROJECT_FILE] =
g_param_spec_object ("project-file",
"Project File",
@@ -196,43 +219,23 @@ ide_build_system_new_finish (GAsyncResult *result,
/**
* ide_build_system_get_builder:
* @system: The #IdeBuildSystem to perform the build.
- * @config: (nullable): The configuration options for the build.
- * @device: The #IdeDevice the result should be able to run on.
+ * @configuration: An #IdeConfiguration.
*
- * This function should return an #IdeBuilder that can be used to perform a
- * build of the project using the configuration specified. @device may be
- * a non-local device, for which cross-compilation may be necessary.
+ * This function returns an #IdeBuilder that can be used to perform a
+ * build of the project using the configuration specified.
+ *
+ * See ide_builder_build_async() for more information.
*
* Returns: (transfer full): An #IdeBuilder or %NULL and @error is set.
*/
IdeBuilder *
-ide_build_system_get_builder (IdeBuildSystem *system,
- GKeyFile *config,
- IdeDevice *device,
- GError **error)
+ide_build_system_get_builder (IdeBuildSystem *system,
+ IdeConfiguration *configuration,
+ GError **error)
{
- IdeBuildSystemInterface *iface;
- IdeBuilder *ret = NULL;
- g_autoptr(GKeyFile) local = NULL;
-
g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (system), NULL);
- g_return_val_if_fail (IDE_IS_DEVICE (device), NULL);
-
- if (config == NULL)
- config = local = g_key_file_new ();
-
- iface = IDE_BUILD_SYSTEM_GET_IFACE (system);
-
- if (iface->get_builder)
- ret = iface->get_builder (system, config, device, error);
- else
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("%s() is not supported on %s build system."),
- G_STRFUNC,
- g_type_name (G_TYPE_FROM_INSTANCE (system)));
+ g_return_val_if_fail (IDE_IS_CONFIGURATION (configuration), NULL);
- return ret;
+ return IDE_BUILD_SYSTEM_GET_IFACE (system)->get_builder (system, configuration, error);
}
diff --git a/libide/ide-build-system.h b/libide/ide-build-system.h
index ef286c6..3cb9e98 100644
--- a/libide/ide-build-system.h
+++ b/libide/ide-build-system.h
@@ -35,8 +35,7 @@ struct _IdeBuildSystemInterface
gint (*get_priority) (IdeBuildSystem *system);
IdeBuilder *(*get_builder) (IdeBuildSystem *system,
- GKeyFile *config,
- IdeDevice *device,
+ IdeConfiguration *configuration,
GError **error);
void (*get_build_flags_async) (IdeBuildSystem *self,
IdeFile *file,
@@ -65,8 +64,7 @@ void ide_build_system_new_async (IdeContext *c
IdeBuildSystem *ide_build_system_new_finish (GAsyncResult *result,
GError **error);
IdeBuilder *ide_build_system_get_builder (IdeBuildSystem *system,
- GKeyFile *config,
- IdeDevice *device,
+ IdeConfiguration *configuration,
GError **error);
G_END_DECLS
diff --git a/libide/ide-builder.c b/libide/ide-builder.c
index 520e177..982f0d2 100644
--- a/libide/ide-builder.c
+++ b/libide/ide-builder.c
@@ -20,13 +20,90 @@
#include "ide-build-result.h"
#include "ide-builder.h"
+#include "ide-configuration.h"
-G_DEFINE_ABSTRACT_TYPE (IdeBuilder, ide_builder, IDE_TYPE_OBJECT)
+typedef struct
+{
+ IdeConfiguration *configuration;
+} IdeBuilderPrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (IdeBuilder, ide_builder, IDE_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_CONFIGURATION,
+ LAST_PROP
+};
+
+static GParamSpec *properties [LAST_PROP];
+
+/**
+ * ide_builder_get_configuration:
+ * @self: An #IdeBuilder.
+ *
+ * Gets the configuration to use for the builder.
+ *
+ * Returns: (transfer none): An #IdeConfiguration.
+ */
+IdeConfiguration *
+ide_builder_get_configuration (IdeBuilder *self)
+{
+ IdeBuilderPrivate *priv = ide_builder_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_BUILDER (self), NULL);
+
+ return priv->configuration;
+}
+
+static void
+ide_builder_set_configuration (IdeBuilder *self,
+ IdeConfiguration *configuration)
+{
+ IdeBuilderPrivate *priv = ide_builder_get_instance_private (self);
+
+ g_assert (IDE_IS_BUILDER (self));
+ g_assert (!configuration || IDE_IS_CONFIGURATION (configuration));
+
+ if (g_set_object (&priv->configuration, configuration))
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONFIGURATION]);
+}
+
+static void
+ide_builder_real_build_async (IdeBuilder *self,
+ IdeBuilderBuildFlags flags,
+ IdeBuildResult **result,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ g_assert (IDE_IS_BUILDER (self));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ g_assert (!result || *result == NULL);
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("%s does not support building"),
+ G_OBJECT_TYPE_NAME (self));
+}
+
+static IdeBuildResult *
+ide_builder_real_build_finish (IdeBuilder *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_assert (IDE_IS_BUILDER (self));
+ g_assert (G_IS_TASK (result));
+
+ return g_task_propagate_pointer (G_TASK (result), error);
+}
/**
* ide_builder_build_async:
* @result: (out) (transfer none): A location for an #IdeBuildResult.
- *
*/
void
ide_builder_build_async (IdeBuilder *builder,
@@ -36,29 +113,13 @@ ide_builder_build_async (IdeBuilder *builder,
GAsyncReadyCallback callback,
gpointer user_data)
{
- IdeBuilderClass *klass;
-
g_return_if_fail (IDE_IS_BUILDER (builder));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
- if (result)
+ if (result != NULL)
*result = NULL;
- klass = IDE_BUILDER_GET_CLASS (builder);
-
- if (klass->build_async)
- {
- klass->build_async (builder, flags, result, cancellable, callback, user_data);
- return;
- }
-
- g_warning (_("%s does not implement build_async()"),
- g_type_name (G_TYPE_FROM_INSTANCE (builder)));
-
- g_task_report_new_error (builder, callback, user_data,
- ide_builder_build_async,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("No implementation of build_async()"));
+ IDE_BUILDER_GET_CLASS (builder)->build_async (builder, flags, result, cancellable, callback, user_data);
}
/**
@@ -73,18 +134,12 @@ ide_builder_build_finish (IdeBuilder *builder,
GAsyncResult *result,
GError **error)
{
- IdeBuilderClass *klass;
IdeBuildResult *ret = NULL;
g_return_val_if_fail (IDE_IS_BUILDER (builder), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- klass = IDE_BUILDER_GET_CLASS (builder);
-
- if (klass->build_finish)
- ret = klass->build_finish (builder, result, error);
- else if (G_IS_TASK (result))
- ret = g_task_propagate_pointer (G_TASK (result), error);
+ ret = IDE_BUILDER_GET_CLASS (builder)->build_finish (builder, result, error);
g_return_val_if_fail (!ret || IDE_IS_BUILD_RESULT (ret), NULL);
@@ -92,8 +147,74 @@ ide_builder_build_finish (IdeBuilder *builder,
}
static void
+ide_builder_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeBuilder *self = IDE_BUILDER(object);
+
+ switch (prop_id)
+ {
+ case PROP_CONFIGURATION:
+ g_value_set_object (value, ide_builder_get_configuration (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void
+ide_builder_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeBuilder *self = IDE_BUILDER(object);
+
+ switch (prop_id)
+ {
+ case PROP_CONFIGURATION:
+ ide_builder_set_configuration (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void
+ide_builder_finalize (GObject *object)
+{
+ IdeBuilder *self = (IdeBuilder *)object;
+ IdeBuilderPrivate *priv = ide_builder_get_instance_private (self);
+
+ g_clear_object (&priv->configuration);
+
+ G_OBJECT_CLASS (ide_builder_parent_class)->finalize (object);
+}
+
+static void
ide_builder_class_init (IdeBuilderClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ide_builder_finalize;
+ object_class->get_property = ide_builder_get_property;
+ object_class->set_property = ide_builder_set_property;
+
+ klass->build_async = ide_builder_real_build_async;
+ klass->build_finish = ide_builder_real_build_finish;
+
+ properties [PROP_CONFIGURATION] =
+ g_param_spec_object ("configuration",
+ "Configuration",
+ "Configuration",
+ IDE_TYPE_CONFIGURATION,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
}
static void
diff --git a/libide/ide-builder.h b/libide/ide-builder.h
index 0232c6f..36604e3 100644
--- a/libide/ide-builder.h
+++ b/libide/ide-builder.h
@@ -29,11 +29,11 @@ G_DECLARE_DERIVABLE_TYPE (IdeBuilder, ide_builder, IDE, BUILDER, IdeObject)
typedef enum
{
- IDE_BUILDER_BUILD_FLAGS_NONE = 0,
- IDE_BUILDER_BUILD_FLAGS_FORCE_REBUILD = 1 << 0,
-
- /* TODO: this belongs as a vfunc instead */
- IDE_BUILDER_BUILD_FLAGS_CLEAN = 1 << 1,
+ IDE_BUILDER_BUILD_FLAGS_NONE = 0,
+ IDE_BUILDER_BUILD_FLAGS_FORCE_BOOTSTRAP = 1 << 0,
+ IDE_BUILDER_BUILD_FLAGS_FORCE_CLEAN = 1 << 1,
+ IDE_BUILDER_BUILD_FLAGS_NO_BUILD = 1 << 2,
+ IDE_BUILDER_BUILD_FLAGS_NO_CONFIGURE = 1 << 3,
} IdeBuilderBuildFlags;
struct _IdeBuilderClass
@@ -51,15 +51,16 @@ struct _IdeBuilderClass
GError **error);
};
-void ide_builder_build_async (IdeBuilder *builder,
- IdeBuilderBuildFlags flags,
- IdeBuildResult **result,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-IdeBuildResult *ide_builder_build_finish (IdeBuilder *builder,
- GAsyncResult *result,
- GError **error);
+IdeConfiguration *ide_builder_get_configuration (IdeBuilder *self);
+void ide_builder_build_async (IdeBuilder *builder,
+ IdeBuilderBuildFlags flags,
+ IdeBuildResult **result,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IdeBuildResult *ide_builder_build_finish (IdeBuilder *builder,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]