Skip to content

Commit

Permalink
Rename exclude-user-rules => enabled-except-user-rules
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb committed Sep 21, 2024
1 parent 2f902c7 commit 7490811
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ let init (builder : Builder.t) =
let cache_config =
match config.cache_enabled with
| Disabled -> Dune_cache.Config.Disabled
| Exclude_user_rules | Enabled ->
| Enabled_except_user_rules | Enabled ->
Enabled
{ storage_mode = Option.value config.cache_storage_mode ~default:Hardlink
; reproducibility_check = config.cache_reproducibility_check
Expand Down Expand Up @@ -1266,7 +1266,7 @@ let init (builder : Builder.t) =
:= if c.builder.require_dune_project_file then Error else Warn;
(Dune_engine.Clflags.can_go_in_shared_cache_default
:= match config.cache_enabled with
| Disabled | Exclude_user_rules -> false
| Disabled | Enabled_except_user_rules -> false
| Enabled -> true);
Log.info
[ Pp.textf
Expand Down
7 changes: 4 additions & 3 deletions doc/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Here, ``<setting>`` must be one of:

* ``disabled``: disables the Dune cache completely.

* ``exclude-user-rules``: enables the Dune cache, but excludes user-written
rules. This setting is a conservative choice that can avoid breaking rules
whose dependencies are not correctly specified. Currently the default.
* ``enabled-except-user-rules``: enables the Dune cache, but excludes
user-written rules. This setting is a conservative choice that can avoid
breaking rules whose dependencies are not correctly specified. Currently the
default.

* ``enabled``: enables the Dune cache unconditionally.

Expand Down
8 changes: 4 additions & 4 deletions doc/changes/10944.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- A new Dune cache setting: `exclude-user-rules`, which enables the Dune cache,
but excludes user-written rules from it. This is a conservative choice that
can avoid breaking rules whose dependencies are not correctly specified. This
is the current default. (#10944, @nojb)
- A new Dune cache setting: `enabled-except-user-rules`, which enables the Dune
cache, but excludes user-written rules from it. This is a conservative choice
that can avoid breaking rules whose dependencies are not correctly
specified. This is the current default. (#10944, @nojb)
2 changes: 1 addition & 1 deletion doc/reference/config/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ where ``<setting>`` is one of:

- ``enabled`` enables Dune cache.

- ``exclude-user-rules`` enables Dune cache, but exclude user-written
- ``enabled-except-user-rules`` enables the Dune cache, but exclude user-written
rules. This setting is a conservative choice that can avoid breaking rules
whose dependencies are not correctly specified. Currently the default.

Expand Down
15 changes: 9 additions & 6 deletions src/dune_config_file/dune_config_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,34 @@ module Dune_config = struct
module Toggle = struct
type t =
| Disabled
| Exclude_user_rules
| Enabled_except_user_rules
| Enabled

let to_string = function
| Disabled -> "disabled"
| Exclude_user_rules -> "exclude-user-rules"
| Enabled_except_user_rules -> "enabled-except-user-rules"
| Enabled -> "enabled"
;;

let all =
List.map ~f:(fun x -> to_string x, x) [ Disabled; Exclude_user_rules; Enabled ]
List.map
~f:(fun x -> to_string x, x)
[ Disabled; Enabled_except_user_rules; Enabled ]
;;

let decode ~check =
let open Dune_lang.Decoder in
enum'
[ to_string Disabled, return Disabled
; to_string Enabled, return Enabled
; to_string Exclude_user_rules, check (3, 17) >>> return Exclude_user_rules
; ( to_string Enabled_except_user_rules
, check (3, 17) >>> return Enabled_except_user_rules )
]
;;

let to_dyn = function
| Disabled -> Dyn.variant "Disabed" []
| Exclude_user_rules -> Dyn.variant "Exclude_user_rules" []
| Enabled_except_user_rules -> Dyn.variant "Enabled_except_user_rules" []
| Enabled -> Dyn.variant "Enabled" []
;;
end
Expand Down Expand Up @@ -348,7 +351,7 @@ module Dune_config = struct
; concurrency = (if Execution_env.inside_dune then Fixed 1 else Auto)
; terminal_persistence = Clear_on_rebuild
; sandboxing_preference = []
; cache_enabled = Exclude_user_rules
; cache_enabled = Enabled_except_user_rules
; cache_reproducibility_check = Skip
; cache_storage_mode = Some (Dune_cache_storage.Mode.default ())
; action_stdout_on_success = Print
Expand Down
2 changes: 1 addition & 1 deletion src/dune_config_file/dune_config_file.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Dune_config : sig
module Toggle : sig
type t =
| Disabled
| Exclude_user_rules
| Enabled_except_user_rules
| Enabled

val all : (string * t) list
Expand Down
6 changes: 3 additions & 3 deletions test/expect-tests/dune_config_file/dune_config_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let%expect_test "cache-check-probability 0.1" =
; concurrency = Fixed 1
; terminal_persistence = Clear_on_rebuild
; sandboxing_preference = []
; cache_enabled = Exclude_user_rules
; cache_enabled = Enabled_except_user_rules
; cache_reproducibility_check = Check_with_probability 0.1
; cache_storage_mode = Some Hardlink
; action_stdout_on_success = Print
Expand All @@ -45,7 +45,7 @@ let%expect_test "cache-storage-mode copy" =
; concurrency = Fixed 1
; terminal_persistence = Clear_on_rebuild
; sandboxing_preference = []
; cache_enabled = Exclude_user_rules
; cache_enabled = Enabled_except_user_rules
; cache_reproducibility_check = Skip
; cache_storage_mode = Some Copy
; action_stdout_on_success = Print
Expand All @@ -68,7 +68,7 @@ let%expect_test "cache-storage-mode hardlink" =
; concurrency = Fixed 1
; terminal_persistence = Clear_on_rebuild
; sandboxing_preference = []
; cache_enabled = Exclude_user_rules
; cache_enabled = Enabled_except_user_rules
; cache_reproducibility_check = Skip
; cache_storage_mode = Some Hardlink
; action_stdout_on_success = Print
Expand Down

0 comments on commit 7490811

Please sign in to comment.