Skip to content

Commit

Permalink
refactor(pkg): simplify formula evaluation (#9448)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored Dec 11, 2023
1 parent 50c9813 commit 2245ee2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/dune_pkg/resolve_opam_formula.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ let substitute_variables_in_filter
(opam_filter : OpamTypes.filter)
: OpamTypes.filter
=
OpamFilter.map_up
(function
| FIdent ([], variable, None) as filter ->
let variable_name = Variable_name.of_opam variable in
OpamFilter.partial_eval
(fun variable ->
match OpamVariable.Full.scope variable with
| Self | Package _ -> None
| Global ->
let variable_name =
OpamVariable.Full.variable variable |> Variable_name.of_opam
in
Option.iter stats_updater ~f:(fun stats_updater ->
Solver_stats.Updater.expand_variable stats_updater variable_name);
(match Solver_env.get solver_env variable_name with
| None -> filter
| Some value -> Variable_value.to_opam_filter value)
| other -> other)
Solver_env.get solver_env variable_name
|> Option.map ~f:Variable_value.to_opam_variable_contents)
opam_filter
;;

Expand Down

0 comments on commit 2245ee2

Please sign in to comment.