diff --git a/src/dune_config_file/dune_config_file.ml b/src/dune_config_file/dune_config_file.ml index 0b31881b5475..3220aa598d4e 100644 --- a/src/dune_config_file/dune_config_file.ml +++ b/src/dune_config_file/dune_config_file.ml @@ -11,6 +11,7 @@ module Dune_config = struct module Log = Dune_util.Log module Config = Dune_config.Config module Execution_env = Dune_util.Execution_env + module Feature_flags = Feature_flags (* the configuration file use the same version numbers as dune-project files for simplicity *) @@ -279,9 +280,14 @@ module Dune_config = struct ; concurrency = (if Execution_env.inside_dune then Fixed 1 else Auto) ; terminal_persistence = Clear_on_rebuild ; sandboxing_preference = [] - ; cache_enabled = `Disabled - ; cache_reproducibility_check = Skip - ; cache_storage_mode = None + ; cache_enabled = + (if Feature_flags.cache_enabled_by_default then `Enabled else `Disabled) + ; cache_reproducibility_check = + (if Feature_flags.cache_enabled_by_default then Check else Skip) + ; cache_storage_mode = + (if Feature_flags.cache_enabled_by_default + then Some (Dune_cache_storage.Mode.default ()) + else None) ; action_stdout_on_success = Print ; action_stderr_on_success = Print ; experimental = [] diff --git a/src/dune_config_file/feature_flags.ml b/src/dune_config_file/feature_flags.ml new file mode 100644 index 000000000000..f9521684aa35 --- /dev/null +++ b/src/dune_config_file/feature_flags.ml @@ -0,0 +1 @@ +let cache_enabled_by_default = false diff --git a/test/blackbox-tests/test-cases/default-cache.t b/test/blackbox-tests/test-cases/default-cache.t new file mode 100644 index 000000000000..03c9c8494255 --- /dev/null +++ b/test/blackbox-tests/test-cases/default-cache.t @@ -0,0 +1,34 @@ +The dune cache should be enabled by 'default' +(not by default on main branch since it's a feature flag) + $ export DUNE_CACHE=enabled + $ echo "(lang dune 3.16)" > dune-project + + $ cat > dune << EOF + > (library + > (name foo)) + > EOF + + $ cat > foo.ml << EOF + > let f x y = x + y + > EOF + +Set up cache directory + $ export DUNE_CACHE_ROOT=$(pwd)/dune_test_cache + $ mkdir $DUNE_CACHE_ROOT + + $ DUNE_CACHE=disabled dune build + $ ls $DUNE_CACHE_ROOT +We have not written anything to the cache yet. + +Change source files to force a recompilation + $ cat > foo.ml << EOF + > let f x y = x - y + > EOF + + $ dune build + $ ls $DUNE_CACHE_ROOT + files + meta + temp + values +Cache has been written to!