Skip to content

Commit

Permalink
Added feature flag to enable dune cache by default
Browse files Browse the repository at this point in the history
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
  • Loading branch information
ElectreAAS committed Jul 11, 2024
1 parent 7c423c5 commit 73ad59c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/dune_config_file/dune_config_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions src/dune_config_file/feature_flags.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let cache_enabled_by_default = false
2 changes: 1 addition & 1 deletion src/dune_rules/format_rules.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open Import
val gen_rules : Super_context.t -> output_dir:Path.Build.t -> unit Memo.t

(** This must be called from the main directory, i.e. the ones containing the
source files and the the [formatted_dir_basename] sub-directory. *)
source files and the [formatted_dir_basename] sub-directory. *)
val setup_alias : dir:Path.Build.t -> unit Memo.t

val formatted_dir_basename : Filename.t
34 changes: 34 additions & 0 deletions test/blackbox-tests/test-cases/default-cache.t
Original file line number Diff line number Diff line change
@@ -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!

0 comments on commit 73ad59c

Please sign in to comment.