Skip to content

Commit

Permalink
Revert "_"
Browse files Browse the repository at this point in the history
This reverts commit 440d328.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Nov 3, 2024
1 parent 440d328 commit 972e02d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
35 changes: 24 additions & 11 deletions src/dune_pkg/dependency_formula.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ let of_dependencies deps = Package_dependency.list_to_opam_filtered_formula deps
let to_filtered_formula v = v
let of_filtered_formula v = v
let to_dyn = Opam_dyn.filtered_formula
let ands = OpamFormula.ands

let remove_packages (v : OpamTypes.filtered_formula) pkgs =
OpamFormula.map_up_formula
(function
| Atom (name, _condition) as a ->
if let name = Package_name.of_opam_package_name name in
Package_name.Set.mem pkgs name
then Empty
else a
| x -> x)
v
let rec union = function
| [] -> OpamTypes.Empty
| x :: xs ->
let xs = union xs in
OpamTypes.And (x, xs)
;;

let rec remove_packages (v : OpamTypes.filtered_formula) pkgs =
match v with
| Empty -> OpamTypes.Empty
| Block b -> Block (remove_packages b pkgs)
| Atom (name, _condition) as a ->
let name = name |> OpamPackage.Name.to_string |> Package_name.of_string in
(match Package_name.Set.mem pkgs name with
| true -> Empty
| false -> a)
| And (l, r) ->
let l = remove_packages l pkgs in
let r = remove_packages r pkgs in
And (l, r)
| Or (l, r) ->
let l = remove_packages l pkgs in
let r = remove_packages r pkgs in
Or (l, r)
;;

exception Found of Package_name.t
Expand Down
5 changes: 3 additions & 2 deletions src/dune_pkg/dependency_formula.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ val of_filtered_formula : OpamTypes.filtered_formula -> t
(** Create a Dyn representation of the dependency formula *)
val to_dyn : t -> Dyn.t

(* Join all dependencies in the list to a single conjunction *)
val ands : t list -> t
(* Join two dependency formulas into one that represents a dependency on
both LHS and RHS *)
val union : t list -> t

(** Remove a package from the entire formula *)
val remove_packages : t -> Package_name.Set.t -> t
Expand Down
6 changes: 2 additions & 4 deletions src/dune_pkg/local_package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ module For_solver = struct

let non_local_dependencies local_deps =
let local_deps_names = Package_name.Set.of_list_map ~f:(fun d -> d.name) local_deps in
let formula =
List.map ~f:(fun { dependencies; _ } -> dependencies) local_deps
|> Dependency_formula.ands
in
let deps = List.map ~f:(fun { dependencies; _ } -> dependencies) local_deps in
let formula = Dependency_formula.union deps in
Dependency_formula.remove_packages formula local_deps_names
;;
end
Expand Down

0 comments on commit 972e02d

Please sign in to comment.