[gnome-builder] mkdirs: allow specifying directory cleanup during rebuild
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] mkdirs: allow specifying directory cleanup during rebuild
- Date: Tue, 8 Aug 2017 23:39:18 +0000 (UTC)
commit 4b9dcd26903e08dd15626c5e1f4b20f479ba90e3
Author: Christian Hergert <chergert redhat com>
Date: Tue Aug 8 16:17:04 2017 -0700
mkdirs: allow specifying directory cleanup during rebuild
When creating directories, we might want to have them reaped for us when
the project is rebuilt. This sets the flag for the staging directory with
flatpak builds. This shouldn't cause much rebuilding since we will still
check out an OSTree cache point.
libide/buildsystem/ide-build-stage-mkdirs.c | 28 +++++++++++++++++++++++++-
libide/buildsystem/ide-build-stage-mkdirs.h | 3 +-
plugins/flatpak/gbp-flatpak-pipeline-addin.c | 4 +-
3 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-stage-mkdirs.c b/libide/buildsystem/ide-build-stage-mkdirs.c
index 5282e62..1559140 100644
--- a/libide/buildsystem/ide-build-stage-mkdirs.c
+++ b/libide/buildsystem/ide-build-stage-mkdirs.c
@@ -35,6 +35,7 @@ typedef struct
gchar *path;
gboolean with_parents;
gint mode;
+ guint remove_on_rebuild : 1;
} Path;
typedef struct
@@ -127,6 +128,28 @@ ide_build_stage_mkdirs_execute (IdeBuildStage *stage,
}
static void
+ide_build_stage_mkdirs_reap (IdeBuildStage *stage,
+ DzlDirectoryReaper *reaper)
+{
+ IdeBuildStageMkdirs *self = (IdeBuildStageMkdirs *)stage;
+ IdeBuildStageMkdirsPrivate *priv = ide_build_stage_mkdirs_get_instance_private (self);
+
+ g_assert (IDE_IS_BUILD_STAGE_MKDIRS (self));
+ g_assert (DZL_IS_DIRECTORY_REAPER (reaper));
+
+ for (guint i = 0; i < priv->paths->len; i++)
+ {
+ const Path *path = &g_array_index (priv->paths, Path, i);
+
+ if (path->remove_on_rebuild)
+ {
+ g_autoptr(GFile) file = g_file_new_for_path (path->path);
+ dzl_directory_reaper_add_directory (reaper, file, 0);
+ }
+ }
+}
+
+static void
ide_build_stage_mkdirs_finalize (GObject *object)
{
IdeBuildStageMkdirs *self = (IdeBuildStageMkdirs *)object;
@@ -147,6 +170,7 @@ ide_build_stage_mkdirs_class_init (IdeBuildStageMkdirsClass *klass)
stage_class->execute = ide_build_stage_mkdirs_execute;
stage_class->query = ide_build_stage_mkdirs_query;
+ stage_class->reap = ide_build_stage_mkdirs_reap;
}
static void
@@ -170,7 +194,8 @@ void
ide_build_stage_mkdirs_add_path (IdeBuildStageMkdirs *self,
const gchar *path,
gboolean with_parents,
- gint mode)
+ gint mode,
+ gboolean remove_on_rebuild)
{
IdeBuildStageMkdirsPrivate *priv = ide_build_stage_mkdirs_get_instance_private (self);
Path ele = { 0 };
@@ -181,6 +206,7 @@ ide_build_stage_mkdirs_add_path (IdeBuildStageMkdirs *self,
ele.path = g_strdup (path);
ele.with_parents = with_parents;
ele.mode = mode;
+ ele.remove_on_rebuild = !!remove_on_rebuild;
g_array_append_val (priv->paths, ele);
}
diff --git a/libide/buildsystem/ide-build-stage-mkdirs.h b/libide/buildsystem/ide-build-stage-mkdirs.h
index 3f25659..3530169 100644
--- a/libide/buildsystem/ide-build-stage-mkdirs.h
+++ b/libide/buildsystem/ide-build-stage-mkdirs.h
@@ -41,7 +41,8 @@ IdeBuildStage *ide_build_stage_mkdirs_new (IdeContext *context);
void ide_build_stage_mkdirs_add_path (IdeBuildStageMkdirs *self,
const gchar *path,
gboolean with_parents,
- gint mode);
+ gint mode,
+ gboolean remove_on_rebuild);
G_END_DECLS
diff --git a/plugins/flatpak/gbp-flatpak-pipeline-addin.c b/plugins/flatpak/gbp-flatpak-pipeline-addin.c
index 33ea29f..5cb2610 100644
--- a/plugins/flatpak/gbp-flatpak-pipeline-addin.c
+++ b/plugins/flatpak/gbp-flatpak-pipeline-addin.c
@@ -76,8 +76,8 @@ register_mkdirs_stage (GbpFlatpakPipelineAddin *self,
repo_dir = gbp_flatpak_get_repo_dir (config);
staging_dir = gbp_flatpak_get_staging_dir (config);
- ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), repo_dir, TRUE, 0750);
- ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), staging_dir, TRUE, 0750);
+ ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), repo_dir, TRUE, 0750, FALSE);
+ ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), staging_dir, TRUE, 0750, TRUE);
stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_PREPARE, PREPARE_MKDIRS, mkdirs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]