File: linkdeps.mli

package info (click to toggle)
ocaml 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,396; asm: 5,462; makefile: 3,679; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (64 lines) | stat: -rw-r--r-- 2,778 bytes parent folder | download | duplicates (8)
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
60
61
62
63
64
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*                              Hugo Heuzard                              *)
(*                                                                        *)
(*   Copyright 2020 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   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.          *)
(*                                                                        *)
(**************************************************************************)

type t
(** The state of the linking check.
    It keeps track of compilation units provided and required so far. *)

type compunit = string

type filename = string

val create : complete:bool -> t
(** [create ~complete] returns an empty state. If [complete] is
   [true], missing compilation units will be treated as errors.  *)

val add : t
  -> filename:filename -> compunit:compunit
  -> provides:compunit list -> requires:compunit list -> unit
(** [add t ~filename ~compunit ~provides ~requires] registers the
    compilation unit [compunit] found in [filename] to [t].
    - [provides] are units and sub-units provided by [compunit]
    - [requires] are units required by [compunit]

    [add] should be called in reverse topological order. *)

val required : t -> compunit -> bool
(** [required t compunit] returns [true] if [compunit] is a dependency of
    previously added compilation units. *)

type compunit_and_source = {
  compunit : compunit;
  filename : filename;
}

type error =
  | Missing_implementations of (compunit * compunit_and_source list) list
  | Wrong_link_order of (compunit_and_source * compunit_and_source list) list
  | Multiple_definitions of (compunit * filename list) list

val check : t -> error option
(** [check t] should be called once all the compilation units to be linked
    have been added.  It returns some error if:
    - There are some missing implementations
      and [complete] is [true]
    - Some implementation appear
      before their dependencies *)


val report_error :
  print_filename:string Format_doc.printer -> error Format_doc.format_printer
val report_error_doc :
  print_filename:string Format_doc.printer -> error Format_doc.printer