Skip to content

Commit

Permalink
refactor(pkg): remove old and unnecessary wrapper modules (#11320)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Jan 18, 2025
1 parent 56bef76 commit b06edfa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/dune_pkg/diagnostics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ module Make (Results : S.SOLVER_RESULT) = struct

type t = Component.t RoleMap.t

let find_component_ex role report =
let[@ocaml.warning "-32"] find_component_ex role report =
match RoleMap.find report role with
| Some c -> c
| None ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
(* Copyright (C) 2020, Thomas Leonard
See the README file for details, or visit http://0install.net. *)

module S = S

(** Select a compatible set of components to run a program.
See [Zeroinstall.Solver] for the instantiation of this functor on the
actual 0install types. *)
module Make (Input : S.SOLVER_INPUT) : sig
module Output : S.SOLVER_RESULT with module Input = Input

(** [do_solve model req] finds an implementation matching the given requirements, plus any other implementations needed
to satisfy its dependencies.
@param closest_match
adds a lowest-ranked (but valid) implementation ([Input.dummy_impl]) to
every interface, so we can always select something. Useful for diagnostics.
Note: always try without [closest_match] first, or it may miss a valid solution.
@return None if the solve fails (only happens if [closest_match] is false). *)
val do_solve : closest_match:bool -> Input.Role.t -> Output.t option Fiber.t
end

(** Explaining why a solve failed or gave an unexpected answer. *)
module Diagnostics (Result : S.SOLVER_RESULT) : sig
module Make (Result : S.SOLVER_RESULT) : sig
(** An item of information to display for a component. *)
module Note : sig
type t =
Expand Down
4 changes: 2 additions & 2 deletions src/dune_pkg/opam_solver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ module Solver = struct
Input.virtual_role [ impl ]
;;

module Solver = Zeroinstall_solver.Make (Input)
module Diagnostics = Zeroinstall_solver.Diagnostics (Solver.Output)
module Solver = Solver_core.Make (Input)
module Diagnostics = Diagnostics.Make (Solver.Output)

let solve context pkgs =
let req = requirements ~context pkgs in
Expand Down
4 changes: 3 additions & 1 deletion src/dune_pkg/solver_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ open Fiber.O
module Make (Model : S.SOLVER_INPUT) = struct
(** We attach this data to each SAT variable. *)
module SolverData = struct
[@@@ocaml.warning "-37"]

type t =
(* If the SAT variable is True then we selected this... *)
| ImplElem of Model.impl
Expand Down Expand Up @@ -38,7 +40,7 @@ module Make (Model : S.SOLVER_INPUT) = struct
; dummy_impl : Model.impl option
}

let is_dummy t impl =
let[@ocaml.warning "-32"] is_dummy t impl =
match t.dummy_impl with
| None -> false
| Some dummy_impl -> dummy_impl == impl
Expand Down
15 changes: 15 additions & 0 deletions src/dune_pkg/solver_core.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(** Select a compatible set of components to run a program.
See [Zeroinstall.Solver] for the instantiation of this functor on the
actual 0install types. *)
module Make (Input : S.SOLVER_INPUT) : sig
module Output : S.SOLVER_RESULT with module Input = Input

(** [do_solve model req] finds an implementation matching the given requirements, plus any other implementations needed
to satisfy its dependencies.
@param closest_match
adds a lowest-ranked (but valid) implementation ([Input.dummy_impl]) to
every interface, so we can always select something. Useful for diagnostics.
Note: always try without [closest_match] first, or it may miss a valid solution.
@return None if the solve fails (only happens if [closest_match] is false). *)
val do_solve : closest_match:bool -> Input.Role.t -> Output.t option Fiber.t
end
3 changes: 0 additions & 3 deletions src/dune_pkg/zeroinstall_solver.ml

This file was deleted.

0 comments on commit b06edfa

Please sign in to comment.