From 75c24ce2919dd25a5dcce9322c49792754e16ead Mon Sep 17 00:00:00 2001 From: Olaf Leidinger Date: Fri, 17 May 2019 18:08:40 +0200 Subject: [PATCH] Feature: Use CCACHE_DIR from environment, if set Closes: #288 Approved by: alexlarsson --- doc/flatpak-builder.xml | 3 ++- src/builder-context.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/flatpak-builder.xml b/doc/flatpak-builder.xml index 9434a4cd..b9395f93 100644 --- a/doc/flatpak-builder.xml +++ b/doc/flatpak-builder.xml @@ -344,7 +344,8 @@ - Enable use of ccache in the build (needs ccache in the sdk) + Enable use of ccache in the build (needs ccache in the sdk). The default ccache folder can be + overridden by setting the environment variable CCACHE_DIR. diff --git a/src/builder-context.c b/src/builder-context.c index a9b7733e..dde12790 100644 --- a/src/builder-context.c +++ b/src/builder-context.c @@ -202,7 +202,18 @@ builder_context_constructed (GObject *object) self->build_dir = g_file_get_child (self->state_dir, "build"); self->cache_dir = g_file_get_child (self->state_dir, "cache"); self->checksums_dir = g_file_get_child (self->state_dir, "checksums"); - self->ccache_dir = g_file_get_child (self->state_dir, "ccache"); + + // Check, if CCACHE_DIR is set in environment and use it, instead of subdir of state_dir + const char * env_ccache_dir = g_getenv ("CCACHE_DIR"); + if (env_ccache_dir && g_path_is_absolute(env_ccache_dir)) + { + g_debug ("Using CCACHE_DIR '%s'", env_ccache_dir); + self->ccache_dir = g_file_new_for_path (env_ccache_dir); + } + else + { + self->ccache_dir = g_file_get_child(self->state_dir, "ccache"); + } } static void