Skip to content

Commit

Permalink
refactor(pkg): tweak experimental flag names (#10928)
Browse files Browse the repository at this point in the history
If only have "enable" flags, it will be impossible to disable existing
flags once we change the defaults. With this change, we can tweak the
defaults without adding/removing more flags.

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Sep 18, 2024
1 parent 4f86203 commit 3f31387
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
28 changes: 18 additions & 10 deletions boot/configure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ let default_toggles : (string * [ `Disabled | `Enabled ]) list =
[ "toolchains", `Disabled; "pkg_build_progress", `Disabled; "lock_dev_tool", `Disabled ]
;;

let toggles = ref default_toggles

let toggle name v =
toggles := List.map !toggles ~f:(fun (x, y) -> x, if x = name then v else y)
;;

let toggle =
let toggles = [ "enable", `Enabled; "disable", `Disabled ] in
let options = List.map toggles ~f:fst in
fun name -> Arg.Symbol (options, fun s -> List.assoc s toggles |> toggle name)
;;

let () =
let bad fmt = ksprintf (fun s -> raise (Arg.Bad s)) fmt in
let library_path = ref [] in
Expand All @@ -32,7 +44,6 @@ let () =
let sbindir = ref None in
let libexecdir = ref None in
let datadir = ref None in
let toggles = ref default_toggles in
let cwd = lazy (Sys.getcwd ()) in
let dir_of_string s =
if Filename.is_relative s then Filename.concat (Lazy.force cwd) s else s
Expand All @@ -46,9 +57,6 @@ let () =
let dir = dir_of_string s in
v := Some dir
in
let toggle name () =
toggles := List.map !toggles ~f:(fun (x, y) -> x, if x = name then `Enabled else y)
in
let args =
[ ( "--libdir"
, Arg.String set_libdir
Expand Down Expand Up @@ -78,17 +86,17 @@ let () =
, Arg.String (set_dir datadir)
, "DIR where files for the share_root section are installed for the default build \
context" )
; ( "--enable-toolchains"
, Arg.Unit (toggle "toolchains")
; ( "--toolchains"
, toggle "toolchains"
, " Enable the toolchains behaviour, allowing dune to install the compiler in a \
user-wide directory.\n\
\ This flag is experimental and shouldn't be relied on by packagers." )
; ( "--enable-pkg-build-progress"
, Arg.Unit (toggle "pkg_build_progress")
; ( "--pkg-build-progress"
, toggle "pkg_build_progress"
, " Enable the displaying of package build progress.\n\
\ This flag is experimental and shouldn't be relied on by packagers." )
; ( "--enable-lock-dev-tool"
, Arg.Unit (toggle "lock_dev_tool")
; ( "--lock-dev-tool"
, toggle "lock_dev_tool"
, " Enable ocamlformat dev-tool, allows 'dune fmt' to build ocamlformat and use \
it, independently from the project depenedencies .\n\
\ This flag is experimental and shouldn't be relied on by packagers." )
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
add-experimental-configure-flags = pkg: pkg.overrideAttrs {
configureFlags =
[
"--enable-toolchains"
"--enable-pkg-build-progress"
"--enable-lock-dev-tool"
"--toolchains" "enable"
"--pkg-build-progress" "enable"
"--lock-dev-tool" "enable"
];
};

Expand Down

0 comments on commit 3f31387

Please sign in to comment.