-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg: Use
filtered_formula
to represent dependencies (#10918)
* pkg: Pass-through `filtered_formula` from opam files to solver The `Dependency_set.t` representation can't deal with disjunctions but in most cases that is not even necessary as the set gets turned into a `filtered_formula` again. Thus it might be easier to keep the original representation and implement the necessary dependency set functionality on top of that. Signed-off-by: Marek Kubica <marek@tarides.com> * Remove unused `Dependency_set` Signed-off-by: Marek Kubica <marek@tarides.com> * Add a test showing that the disjunction in OPAM files is supported now Signed-off-by: Marek Kubica <marek@tarides.com> * Move `filtered_formula` into our own module Signed-off-by: Marek Kubica <marek@tarides.com> * Determine the hash from the Sexp Signed-off-by: Marek Kubica <marek@tarides.com> * Move reachability into the formula Signed-off-by: Marek Kubica <marek@tarides.com> * Add test for dependency formula changes Signed-off-by: Marek Kubica <marek@tarides.com> * Clean up the awkward API Signed-off-by: Marek Kubica <marek@tarides.com> * Promote expected hash changes Signed-off-by: Marek Kubica <marek@tarides.com> * Update the test wording and show the difference Signed-off-by: Marek Kubica <marek@tarides.com> * test(pkg): demonstrate unreachable packages being included Signed-off-by: Rudi Grinberg <me@rgrinberg.com> Signed-off-by: Marek Kubica <marek@tarides.com> * Do not include post dependencies in reachable packages Signed-off-by: Marek Kubica <marek@tarides.com> * Replace sexp by dyn Signed-off-by: Marek Kubica <marek@tarides.com> * Promote expected hash changes Signed-off-by: Marek Kubica <marek@tarides.com> * `post` deps are excluded now Signed-off-by: Marek Kubica <marek@tarides.com> * Simplify Signed-off-by: Marek Kubica <marek@tarides.com> * Use `Resolve_opam_formula` to determine dependencies Signed-off-by: Marek Kubica <marek@tarides.com>
- Loading branch information
1 parent
aff18a8
commit b409963
Showing
19 changed files
with
291 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
open Import | ||
|
||
type t = OpamTypes.filtered_formula | ||
|
||
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 | ||
;; | ||
|
||
exception Found of Package_name.t | ||
|
||
let any_package_name (v : OpamTypes.filtered_formula) = | ||
try | ||
OpamFormula.iter | ||
(fun (name, _condition) -> | ||
let name = Package_name.of_opam_package_name name in | ||
raise_notrace (Found name)) | ||
v; | ||
None | ||
with | ||
| Found name -> Some name | ||
;; | ||
|
||
let has_entries v = v |> any_package_name |> Option.is_some |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type t | ||
|
||
(** Create a dependency formula out of a [Package_dependency.t] list where | ||
all packages are dependencies *) | ||
val of_dependencies : Package_dependency.t list -> t | ||
|
||
(** Convert to the OPAM data type *) | ||
val to_filtered_formula : t -> OpamTypes.filtered_formula | ||
|
||
(** Convert from the OPAM data type to this *) | ||
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 | ||
|
||
(** Remove a package from the entire formula *) | ||
val remove_packages : t -> Package_name.Set.t -> t | ||
|
||
(** Determine whether the dependency formula has any dependencies *) | ||
val has_entries : t -> bool | ||
|
||
(** Returns the [Package_name.t] of a dependency from the formula, if it | ||
exists. *) | ||
val any_package_name : t -> Package_name.t option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.