[gnome-builder] pipeline: allow disabling stages
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] pipeline: allow disabling stages
- Date: Wed, 8 Mar 2017 00:47:36 +0000 (UTC)
commit 5d9d174590ce9bf2c4bac81d350131e93bda213c
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 7 16:46:25 2017 -0800
pipeline: allow disabling stages
If a stage is disabled, it will be skipped over. It can be convenient if
we need to disable something except for certain uses.
libide/buildsystem/ide-build-pipeline.c | 8 ++++
libide/buildsystem/ide-build-stage.c | 58 +++++++++++++++++++++++++++++++
libide/buildsystem/ide-build-stage.h | 3 ++
3 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-pipeline.c b/libide/buildsystem/ide-build-pipeline.c
index 4fadda2..b31ebd0 100644
--- a/libide/buildsystem/ide-build-pipeline.c
+++ b/libide/buildsystem/ide-build-pipeline.c
@@ -1106,6 +1106,10 @@ ide_build_pipeline_try_chain (IdeBuildPipeline *self,
if (((entry->phase & IDE_BUILD_PHASE_MASK) & self->requested_mask) == 0)
return;
+ /* Skip past the stage if it is disabled. */
+ if (ide_build_stage_get_disabled (entry->stage))
+ continue;
+
chained = ide_build_stage_chain (stage, entry->stage);
IDE_TRACE_MSG ("Checking if %s chains to stage[%d] (%s) = %s",
@@ -1175,6 +1179,10 @@ ide_build_pipeline_tick_execute (IdeBuildPipeline *self,
g_assert (entry->stage != NULL);
g_assert (IDE_IS_BUILD_STAGE (entry->stage));
+ /* Ignore the stage if it is disabled */
+ if (ide_build_stage_get_disabled (entry->stage))
+ continue;
+
if ((entry->phase & IDE_BUILD_PHASE_MASK) & self->requested_mask)
{
self->current_stage = entry->stage;
diff --git a/libide/buildsystem/ide-build-stage.c b/libide/buildsystem/ide-build-stage.c
index 9b5c19a..b91ab2e 100644
--- a/libide/buildsystem/ide-build-stage.c
+++ b/libide/buildsystem/ide-build-stage.c
@@ -35,6 +35,7 @@ typedef struct
GOutputStream *stdout_stream;
gint n_pause;
guint completed : 1;
+ guint disabled : 1;
guint transient : 1;
} IdeBuildStagePrivate;
@@ -43,6 +44,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeBuildStage, ide_build_stage, IDE_TYPE_OBJECT)
enum {
PROP_0,
PROP_COMPLETED,
+ PROP_DISABLED,
PROP_NAME,
PROP_STDOUT_PATH,
PROP_TRANSIENT,
@@ -267,6 +269,10 @@ ide_build_stage_get_property (GObject *object,
g_value_set_boolean (value, ide_build_stage_get_completed (self));
break;
+ case PROP_DISABLED:
+ g_value_set_boolean (value, ide_build_stage_get_disabled (self));
+ break;
+
case PROP_NAME:
g_value_set_string (value, ide_build_stage_get_name (self));
break;
@@ -294,6 +300,10 @@ ide_build_stage_set_property (GObject *object,
ide_build_stage_set_completed (self, g_value_get_boolean (value));
break;
+ case PROP_DISABLED:
+ ide_build_stage_set_disabled (self, g_value_get_boolean (value));
+ break;
+
case PROP_NAME:
ide_build_stage_set_name (self, g_value_get_string (value));
break;
@@ -338,6 +348,24 @@ ide_build_stage_class_init (IdeBuildStageClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
+ * IdeBuildStage:disabled:
+ *
+ * If the build stage is disabled. This allows you to have a stage that is
+ * attached but will not be activated during execution.
+ *
+ * You may enable it later and then re-execute the pipeline.
+ *
+ * If the stage is both transient and disabled, it will not be removed during
+ * the transient cleanup phase.
+ */
+ properties [PROP_DISABLED] =
+ g_param_spec_boolean ("disabled",
+ "Disabled",
+ "If the stage has been disabled",
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
* IdeBuildStage:name:
*
* The name of the build stage. This is only used by UI to view
@@ -937,7 +965,37 @@ ide_build_stage_chain (IdeBuildStage *self,
g_return_val_if_fail (IDE_IS_BUILD_STAGE (self), FALSE);
g_return_val_if_fail (IDE_IS_BUILD_STAGE (next), FALSE);
+ if (ide_build_stage_get_disabled (next))
+ return FALSE;
+
g_signal_emit (self, signals[CHAIN], 0, next, &ret);
return ret;
}
+
+gboolean
+ide_build_stage_get_disabled (IdeBuildStage *self)
+{
+ IdeBuildStagePrivate *priv = ide_build_stage_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_BUILD_STAGE (self), FALSE);
+
+ return priv->disabled;
+}
+
+void
+ide_build_stage_set_disabled (IdeBuildStage *self,
+ gboolean disabled)
+{
+ IdeBuildStagePrivate *priv = ide_build_stage_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_BUILD_STAGE (self));
+
+ disabled = !!disabled;
+
+ if (priv->disabled != disabled)
+ {
+ priv->disabled = disabled;
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DISABLED]);
+ }
+}
diff --git a/libide/buildsystem/ide-build-stage.h b/libide/buildsystem/ide-build-stage.h
index 32370f1..832dc61 100644
--- a/libide/buildsystem/ide-build-stage.h
+++ b/libide/buildsystem/ide-build-stage.h
@@ -189,6 +189,9 @@ const gchar *ide_build_stage_get_stdout_path (IdeBuildStage *self);
gboolean ide_build_stage_get_completed (IdeBuildStage *self);
void ide_build_stage_set_completed (IdeBuildStage *self,
gboolean completed);
+gboolean ide_build_stage_get_disabled (IdeBuildStage *self);
+void ide_build_stage_set_disabled (IdeBuildStage *self,
+ gboolean disabled);
gboolean ide_build_stage_get_transient (IdeBuildStage *self);
void ide_build_stage_set_transient (IdeBuildStage *self,
gboolean transient);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]