File: prepare.mli

package info (click to toggle)
ocaml-obuild 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,456 kB
  • sloc: ml: 14,491; sh: 211; ansic: 34; makefile: 11
file content (144 lines) | stat: -rw-r--r-- 5,106 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
(** Build preparation - dependency gathering and compilation state *)

(** Thread usage flag *)
type use_thread_flag = NoThread | WithThread

(** Thread implementation type *)
type thread_type = VMThread | PosixThread | DefaultThread | NoThreads

(** OCaml file type classification *)
type ocaml_file_type =
  | GeneratedModule  (** Auto-generated module *)
  | SimpleModule     (** Regular source module *)

(** Module description and dependency information *)
module Module : sig
  (** Exception raised when a module depends on itself *)
  exception DependsItself of Hier.t

  (** Exception raised when there are dependency problems *)
  exception DependenciesProblem of Hier.t list

  (** Exception raised when a dependency has no output *)
  exception DependencyNoOutput

  (** Exception raised when a module is not found *)
  exception NotFound of (Filepath.filepath list * Hier.t)

  (** Interface file descriptor *)
  module Intf : sig
    type t = {
      mtime : float;
      path : Filepath.filepath
    }
    val make : float -> Filepath.filepath -> t
  end

  (** Source file descriptor *)
  module File : sig
    type t = {
      use_threads  : use_thread_flag;
      path    : Filepath.filepath;
      mtime   : float;
      type_   : ocaml_file_type;
      intf_desc   : Intf.t option;
      use_pp      : Pp.t;
      oflags      : string list;
      dep_cwd_modules    : Hier.t list;
      dep_other_modules  : Modname.t list;
    }
    val make : use_thread_flag -> Filepath.filepath -> float -> ocaml_file_type ->
               Intf.t option -> Pp.t -> string list -> Hier.t list -> Modname.t list -> t
  end

  (** Directory descriptor *)
  module Dir : sig
    type t = {
      path    : Filepath.filepath;
      modules : Hier.t list
    }
    val make : Filepath.filepath -> Hier.t list -> t
  end

  (** Module descriptor - either file or directory *)
  type t = DescFile of File.t | DescDir of Dir.t

  val file_has_interface : File.t -> bool
  (** Check if file module has an interface file *)

  val has_interface : t -> bool
  (** Check if module has an interface file *)

  val make_dir : Filepath.filepath -> Hier.t list -> t
  (** Create directory module descriptor *)

  val make_file : use_thread_flag -> Filepath.filepath -> float -> ocaml_file_type ->
                  Intf.t option -> Pp.t -> string list -> Hier.t list -> Modname.t list -> t
  (** Create file module descriptor *)
end

(** Global build state persisting across all compilations *)
type build_state = { bstate_config : Analyze.project_config }

(** Directory specification for compilation *)
type dir_spec = {
  src_dir      : Filepath.filepath;
  dst_dir      : Filepath.filepath;
  include_dirs : Filepath.filepath list;
}

(** Compilation step types *)
type compile_step =
  | CompileModule    of Hier.t
  | CompileInterface of Hier.t
  | CompileDirectory of Hier.t
  | CompileC         of Filepath.filename
  | GenerateCstubsTypes     of Libname.t  (** Generate types_generated.ml *)
  | GenerateCstubsFunctions of Libname.t  (** Generate C.ml and stubs.c *)
  | CompileCstubsC          of Libname.t  (** Compile generated C stubs *)
  | RunGenerateBlock of Target.target_generate  (** Run explicit generate block *)
  | LinkTarget       of Target.target
  | CheckTarget      of Target.target

val string_of_compile_step : compile_step -> string
(** Convert compilation step to human-readable string *)

(** Compilation state for a single target *)
type compilation_state = {
  compilation_modules  : (Hier.t, Module.t) Hashtbl.t;
  compilation_csources : Filepath.filename list;
  compilation_dag      : compile_step Dag.t;
  compilation_pp       : Pp.t;
  compilation_filesdag : Filetype.id Dag.t;
  compilation_builddir_c  : Filepath.filepath;
  compilation_builddir_ml : Types.ocaml_compilation_option -> Filepath.filepath;
  compilation_include_paths : Types.ocaml_compilation_option -> Hier.t -> Filepath.filepath list;
  compilation_linking_paths : Filepath.filepath list;
  compilation_linking_paths_d : Filepath.filepath list;
  compilation_linking_paths_p : Filepath.filepath list;
  compilation_c_include_paths : Filepath.filepath list;
  compilation_c_linking_paths : Filepath.filepath list;
}

val init : Analyze.project_config -> build_state
(** [init project] initializes build state from analyzed project configuration *)

val prepare_target : build_state -> Filepath.filepath -> Target.target -> Hier.t list -> compilation_state
(** [prepare_target bstate build_dir target modules] prepares compilation for a target

    Creates compilation state including:
    - Module dependency DAG
    - File dependency DAG
    - Include and linking paths
    - C compilation paths

    @param bstate global build state
    @param build_dir target build directory
    @param target the target to prepare
    @param modules top-level modules for this target
    @return compilation state for this target *)

val get_compilation_order : compilation_state -> Hier.t list
(** [get_compilation_order cstate] returns modules in compilation order

    Returns top-level modules in dependency order *)