@@ -54,7 +54,8 @@ static gboolean opt_show_deps;
5454static gboolean opt_show_manifest ;
5555static gboolean opt_disable_download ;
5656static gboolean opt_disable_updates ;
57- static gboolean opt_ccache ;
57+ static gboolean opt_ccache ; /* deprecated, kept for compat */
58+ static gboolean opt_no_ccache ;
5859static gboolean opt_require_changes ;
5960static gboolean opt_keep_build_dirs ;
6061static gboolean opt_delete_build_dirs ;
@@ -102,7 +103,8 @@ static GOptionEntry entries[] = {
102103 { "add-tag" , 0 , 0 , G_OPTION_ARG_STRING_ARRAY , & opt_add_tags , "Add a tag to the build" , "TAG" },
103104 { "remove-tag" , 0 , 0 , G_OPTION_ARG_STRING_ARRAY , & opt_remove_tags , "Remove a tag from the build" , "TAG" },
104105 { "run" , 0 , 0 , G_OPTION_ARG_NONE , & opt_run , "Run a command in the build directory (see --run --help)" , NULL },
105- { "ccache" , 0 , 0 , G_OPTION_ARG_NONE , & opt_ccache , "Use ccache" , NULL },
106+ { "ccache" , 0 , G_OPTION_FLAG_HIDDEN , G_OPTION_ARG_NONE , & opt_ccache , "Use ccache (deprecated as it is auto-enabled when available in SDK)" , NULL },
107+ { "no-ccache" , 0 , 0 , G_OPTION_ARG_NONE , & opt_no_ccache , "Disable ccache use" , NULL },
106108 { "disable-cache" , 0 , 0 , G_OPTION_ARG_NONE , & opt_disable_cache , "Disable cache lookups" , NULL },
107109 { "disable-tests" , 0 , 0 , G_OPTION_ARG_NONE , & opt_disable_tests , "Don't run tests" , NULL },
108110 { "disable-rofiles-fuse" , 0 , 0 , G_OPTION_ARG_NONE , & opt_disable_rofiles , "Disable rofiles-fuse use" , NULL },
@@ -158,7 +160,8 @@ static GOptionEntry run_entries[] = {
158160 { "run" , 0 , 0 , G_OPTION_ARG_NONE , & opt_run , "Run a command in the build directory" , NULL },
159161 { "log-session-bus" , 0 , 0 , G_OPTION_ARG_NONE , & opt_log_session_bus , N_ ("Log session bus calls" ), NULL },
160162 { "log-system-bus" , 0 , 0 , G_OPTION_ARG_NONE , & opt_log_system_bus , N_ ("Log system bus calls" ), NULL },
161- { "ccache" , 0 , 0 , G_OPTION_ARG_NONE , & opt_ccache , "Use ccache" , NULL },
163+ { "ccache" , 0 , G_OPTION_FLAG_HIDDEN , G_OPTION_ARG_NONE , & opt_ccache , "Use ccache (deprecated as it is auto-enabled when available in SDK)" , NULL },
164+ { "no-ccache" , 0 , 0 , G_OPTION_ARG_NONE , & opt_no_ccache , "Disable ccache use" , NULL },
162165 { "state-dir" , 0 , 0 , G_OPTION_ARG_FILENAME , & opt_state_dir , "Use this directory for state instead of .flatpak-builder" , "PATH" },
163166 { NULL }
164167};
@@ -690,12 +693,6 @@ main (int argc,
690693 builder_context_set_stop_at (build_context , opt_stop_at );
691694 }
692695
693- if (!builder_context_set_enable_ccache (build_context , opt_ccache , & error ))
694- {
695- g_printerr ("Can't initialize ccache use: %s\n" , error -> message );
696- return 1 ;
697- }
698-
699696 if (opt_from_git )
700697 {
701698 g_autofree char * manifest_dirname = g_path_get_dirname (manifest_rel_path );
@@ -954,6 +951,25 @@ main (int argc,
954951 return 1 ;
955952 }
956953
954+ if (!opt_no_ccache )
955+ {
956+ gboolean want_ccache = FALSE;
957+ const char * sdk_path = builder_manifest_get_sdk_path (manifest );
958+
959+ if (sdk_path != NULL )
960+ want_ccache = builder_context_ccache_available_in_sdk (build_context , sdk_path );
961+
962+ if (!want_ccache && opt_ccache )
963+ g_printerr ("Warning: --ccache passed but ccache not found in SDK, ignoring\n" );
964+
965+ if (want_ccache &&
966+ !builder_context_set_enable_ccache (build_context , TRUE, & error ))
967+ {
968+ g_printerr ("Can't initialize ccache use: %s\n" , error -> message );
969+ return 1 ;
970+ }
971+ }
972+
957973 if (!opt_finish_only &&
958974 !opt_export_only &&
959975 !opt_disable_download &&
0 commit comments