Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(pkg): trivial binding simplifications #10812

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions src/dune_pkg/opam_solver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,8 @@ let opam_package_to_lock_file_pkg
(Table.find_exn candidates_cache name).resolved
|> OpamPackage.Version.Map.find (Package_version.to_opam_package_version version)
in
let opam_file, loc =
let opam_file = Resolved_package.opam_file resolved_package in
let loc = Resolved_package.loc resolved_package in
opam_file, loc
in
let opam_file = Resolved_package.opam_file resolved_package in
let loc = Resolved_package.loc resolved_package in
let extra_sources =
OpamFile.OPAM.extra_sources opam_file
|> List.map ~f:(fun (opam_basename, opam_url) ->
Expand Down Expand Up @@ -632,27 +629,28 @@ let opam_package_to_lock_file_pkg
{ Lock_dir.Pkg_info.name; version; dev; source; extra_sources }
in
let depends =
match
Resolve_opam_formula.filtered_formula_to_package_names
~with_test:false
(add_self_to_filter_env opam_package (Solver_env.to_env solver_env))
version_by_package_name
opam_file.depends
with
| Ok { regular; _ } -> regular
| Error (`Formula_could_not_be_satisfied hints) ->
Code_error.raise
"Dependencies of package can't be satisfied from packages in solution"
[ "package", Dyn.string (OpamFile.OPAM.package opam_file |> OpamPackage.to_string)
; "hints", Dyn.list Resolve_opam_formula.Unsatisfied_formula_hint.to_dyn hints
]
in
let depopts =
available_depopts solver_env version_by_package_name opam_file
|> List.filter ~f:(fun package_name ->
not (List.mem depends package_name ~equal:Package_name.equal))
in
let depends =
let depends =
match
Resolve_opam_formula.filtered_formula_to_package_names
~with_test:false
(add_self_to_filter_env opam_package (Solver_env.to_env solver_env))
version_by_package_name
opam_file.depends
with
| Ok { regular; _ } -> regular
| Error (`Formula_could_not_be_satisfied hints) ->
Code_error.raise
"Dependencies of package can't be satisfied from packages in solution"
[ ( "package"
, Dyn.string (OpamFile.OPAM.package opam_file |> OpamPackage.to_string) )
; "hints", Dyn.list Resolve_opam_formula.Unsatisfied_formula_hint.to_dyn hints
]
in
let depopts =
available_depopts solver_env version_by_package_name opam_file
|> List.filter ~f:(fun package_name ->
not (List.mem depends package_name ~equal:Package_name.equal))
in
depends @ depopts |> List.map ~f:(fun package_name -> Loc.none, package_name)
in
let build_env action =
Expand Down
Loading