diff --git a/builder/builder-context.c b/builder/builder-context.c index c08bf8a4d..d22665299 100644 --- a/builder/builder-context.c +++ b/builder/builder-context.c @@ -58,6 +58,7 @@ struct BuilderContext gboolean build_extension; gboolean separate_locales; gboolean sandboxed; + gboolean rebuild_on_sdk_change; }; typedef struct @@ -389,6 +390,19 @@ builder_context_set_separate_locales (BuilderContext *self, self->separate_locales = !!separate_locales; } +gboolean +builder_context_get_rebuild_on_sdk_change (BuilderContext *self) +{ + return self->rebuild_on_sdk_change; +} + +void +builder_context_set_rebuild_on_sdk_change (BuilderContext *self, + gboolean rebuild_on_sdk_change) +{ + self->rebuild_on_sdk_change = !!rebuild_on_sdk_change; +} + gboolean builder_context_enable_ccache (BuilderContext *self, GError **error) diff --git a/builder/builder-context.h b/builder/builder-context.h index 8de9cd7cd..2bcf2b10c 100644 --- a/builder/builder-context.h +++ b/builder/builder-context.h @@ -76,6 +76,9 @@ void builder_context_set_build_extension (BuilderContext *self, gboolean builder_context_get_separate_locales (BuilderContext *self); void builder_context_set_separate_locales (BuilderContext *self, gboolean separate_locales); +gboolean builder_context_get_rebuild_on_sdk_change (BuilderContext *self); +void builder_context_set_rebuild_on_sdk_change (BuilderContext *self, + gboolean rebuild_on_sdk_change); BuilderContext *builder_context_new (GFile *base_dir, GFile *app_dir); diff --git a/builder/builder-main.c b/builder/builder-main.c index 68fadd014..fbc8c530c 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -47,6 +47,7 @@ static gboolean opt_keep_build_dirs; static gboolean opt_force_clean; static gboolean opt_allow_missing_runtimes; static gboolean opt_sandboxed; +static gboolean opt_rebuild_on_sdk_change; static char *opt_stop_at; static char *opt_arch; static char *opt_repo; @@ -81,6 +82,7 @@ static GOptionEntry entries[] = { { "sandbox", 0, 0, G_OPTION_ARG_NONE, &opt_sandboxed, "Enforce sandboxing, disabling build-args", NULL }, { "stop-at", 0, 0, G_OPTION_ARG_STRING, &opt_stop_at, "Stop building at this module (implies --build-only)", "MODULENAME"}, { "jobs", 0, 0, G_OPTION_ARG_INT, &opt_jobs, "Number of parallel jobs to build (default=NCPU)", "JOBS"}, + { "rebuild-on-sdk-change", 0, 0, G_OPTION_ARG_NONE, &opt_rebuild_on_sdk_change, "Rebuild if sdk changes", NULL }, { NULL } }; @@ -324,6 +326,7 @@ main (int argc, builder_context_set_keep_build_dirs (build_context, opt_keep_build_dirs); builder_context_set_sandboxed (build_context, opt_sandboxed); builder_context_set_jobs (build_context, opt_jobs); + builder_context_set_rebuild_on_sdk_change (build_context, opt_rebuild_on_sdk_change); if (opt_arch) builder_context_set_arch (build_context, opt_arch); diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index 40de19057..74f3d8e8b 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -1274,7 +1274,10 @@ builder_manifest_checksum (BuilderManifest *self, builder_cache_checksum_str (cache, self->runtime); builder_cache_checksum_str (cache, builder_manifest_get_runtime_version (self)); builder_cache_checksum_str (cache, self->sdk); - builder_cache_checksum_str (cache, self->sdk_commit); + /* Always rebuild on sdk change if we're actually including the sdk in the cache */ + if (self->writable_sdk || self->build_runtime || + builder_context_get_rebuild_on_sdk_change (context)) + builder_cache_checksum_str (cache, self->sdk_commit); builder_cache_checksum_str (cache, self->var); builder_cache_checksum_str (cache, self->metadata); builder_cache_checksum_strv (cache, self->tags); diff --git a/doc/flatpak-builder.xml b/doc/flatpak-builder.xml index 992d657eb..77de49496 100644 --- a/doc/flatpak-builder.xml +++ b/doc/flatpak-builder.xml @@ -822,6 +822,16 @@ + + + + + Record the exact version of the sdk in the cache, and rebuild everything + if it changes. This is useful if you're building against an API-unstable + runtime, like a nightly build. + + +