Skip to content

Commit

Permalink
Add ocamllsp dev tool
Browse files Browse the repository at this point in the history
Adds metadata about ocamllsp and generalizes the dev-tool fetching
code to support all dev tools rather than specifically ocamlformat.

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
  • Loading branch information
gridbugs committed Sep 23, 2024
1 parent 12462ed commit d92b74e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dune_pkg/dev_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,47 @@ open! Import
type t =
| Ocamlformat
| Odoc
| Ocamllsp

let all = [ Ocamlformat; Odoc ]
let all = [ Ocamlformat; Odoc; Ocamllsp ]

let equal a b =
match a, b with
| Ocamlformat, Ocamlformat -> true
| Odoc, Odoc -> true
| Ocamllsp, Ocamllsp -> true
| _ -> false
;;

let package_name = function
| Ocamlformat -> Package_name.of_string "ocamlformat"
| Odoc -> Package_name.of_string "odoc"
| Ocamllsp -> Package_name.of_string "ocaml-lsp-server"
;;

let of_package_name package_name =
match Package_name.to_string package_name with
| "ocamlformat" -> Ocamlformat
| "odoc" -> Odoc
| "ocaml-lsp-server" -> Ocamllsp
| other -> User_error.raise [ Pp.textf "No such dev tool: %s" other ]
;;

let exe_name = function
| Ocamlformat -> "ocamlformat"
| Odoc -> "odoc"
| Ocamllsp -> "ocamllsp"
;;

let exe_path_components_within_package t =
match t with
| Ocamlformat -> [ "bin"; exe_name t ]
| Odoc -> [ "bin"; exe_name t ]
| Ocamllsp -> [ "bin"; exe_name t ]
;;

let needs_to_build_with_same_compiler_as_project = function
| Ocamlformat -> false
| Odoc -> true
| Ocamllsp -> true
;;
1 change: 1 addition & 0 deletions src/dune_pkg/dev_tool.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ open! Import
type t =
| Ocamlformat
| Odoc
| Ocamllsp

val all : t list
val equal : t -> t -> bool
Expand Down

0 comments on commit d92b74e

Please sign in to comment.