package opam-solver

  1. Overview
  2. Docs

Source file opamBuiltinMccs.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 1 "src/solver/opamBuiltinMccs.ml.real"
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2017 OCamlPro                                             *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

open OpamCudfSolverSig

let name solver_backend = "builtin-"^Mccs.get_solver_id ~solver:solver_backend ()

let default_criteria = {
  crit_default = "-removed,\
                  -count[version-lag,request],\
                  -count[version-lag,changed],\
                  -changed";
  crit_upgrade = "-removed,\
                  -count[version-lag,solution],\
                  -new";
  crit_fixup = "-changed,-count[version-lag:,false]";
  crit_best_effort_prefix = Some "+count[opam-query:,false],";
}

let call solver_backend ext ~criteria ?timeout cudf =
  let solver = match solver_backend, ext with
    | `LP _, Some ext -> `LP ext
    | _ -> solver_backend
  in
  match
    Mccs.resolve_cudf
      ~solver
      ~verbose:OpamCoreConfig.(!r.debug_level >= 2)
      ?timeout criteria cudf
  with
  | None -> raise Common.CudfSolver.Unsat
  | Some (preamble, univ) -> Some preamble, univ
  | exception Mccs.Timeout -> raise Timeout

let of_backend backend : (module OpamCudfSolverSig.S) =
  (module struct
    let name = name backend
    let ext = ref None
    let is_present () =
      match backend, !ext with
      | `LP "", None -> false
      | `LP cmd, None | `LP _, Some cmd ->
        OpamSystem.resolve_command cmd <> None
      | _ -> true
    let command_name = None
    let default_criteria = default_criteria
    let call = call backend !ext
  end)

let all_backends =
  List.map of_backend Mccs.supported_backends
OCaml

Innovation. Community. Security.