-
Notifications
You must be signed in to change notification settings - Fork 76
/
ocaml_modifiers.ml
165 lines (139 loc) · 5.15 KB
/
ocaml_modifiers.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Sebastien Hinderer, projet Gallium, INRIA Paris *)
(* *)
(* Copyright 2016 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. *)
(* *)
(**************************************************************************)
(* Definition of a few OCaml-specific environment modifiers *)
open Ocamltest_stdlib
open Environments
let wrap sl = " " ^ String.concat " " sl ^ " "
let append var sl = Append (var, wrap sl)
let add var s = Add (var, s)
let principal =
[
append Ocaml_variables.flags ["-principal"];
add Ocaml_variables.compiler_directory_suffix ".principal";
add Ocaml_variables.compiler_reference_suffix ".principal";
]
let latex =
[
add Ocaml_variables.ocamldoc_backend "latex";
append Ocaml_variables.ocamldoc_flags ["-latex-type-prefix=TYP"];
append Ocaml_variables.ocamldoc_flags ["-latex-module-prefix="];
append Ocaml_variables.ocamldoc_flags ["-latex-value-prefix="];
append Ocaml_variables.ocamldoc_flags ["-latex-module-type-prefix="];
append Ocaml_variables.ocamldoc_flags ["-latextitle=1,subsection*"];
append Ocaml_variables.ocamldoc_flags ["-latextitle=2,subsubsection*"];
append Ocaml_variables.ocamldoc_flags ["-latextitle=6,subsection*"];
append Ocaml_variables.ocamldoc_flags ["-latextitle=7,subsubsection*"];
]
let html =
[
add Ocaml_variables.ocamldoc_backend "html";
append Ocaml_variables.ocamldoc_flags ["-colorize-code"];
]
let man =
[
add Ocaml_variables.ocamldoc_backend "man";
]
let make_library_modifier library directories =
[
append Ocaml_variables.directories directories;
append Ocaml_variables.libraries [library];
append Ocaml_variables.caml_ld_library_path directories;
]
let make_module_modifier unit_name directory =
[
append Ocaml_variables.directories [directory];
append Ocaml_variables.binary_modules [unit_name];
]
let compiler_subdir subdir =
(* CR mshinwell: upstream this change *)
Filename.make_path (Ocaml_directories.srcdir :: subdir)
let config =
[
append Ocaml_variables.directories [compiler_subdir ["utils"]];
]
let testing = make_library_modifier
"testing" [compiler_subdir ["testsuite"; "lib"]]
let tool_ocaml_lib = make_module_modifier
"lib" (compiler_subdir ["testsuite"; "lib"])
let unix = make_library_modifier
"unix" [compiler_subdir ["otherlibs"; "unix"]]
let dynlink =
make_library_modifier "dynlink"
[compiler_subdir ["otherlibs"; "dynlink"];
compiler_subdir ["otherlibs"; "dynlink"; "native"]]
let str = make_library_modifier
"str" [compiler_subdir ["otherlibs"; "str"]]
let systhreads =
unix @
(make_library_modifier
"threads" [compiler_subdir ["otherlibs"; Ocamltest_config.systhreads_path]])
let runtime_events =
make_library_modifier
"runtime_events" [compiler_subdir ["otherlibs"; "runtime_events"]]
let compilerlibs_subdirs =
[
"asmcomp";
"bytecomp";
"compilerlibs";
"driver";
"file_formats";
"lambda";
"middle_end";
"parsing";
"toplevel";
"typing";
"utils";
]
let add_compiler_subdir subdir =
append Ocaml_variables.directories [compiler_subdir [subdir]]
let compilerlibs_archive archive =
append Ocaml_variables.libraries [archive] ::
List.map add_compiler_subdir compilerlibs_subdirs
let runtime_suffix = if Config.runtime5 then "" else "4"
let debugger = [add_compiler_subdir ("debugger" ^ runtime_suffix)]
let extension_universe_lib name =
make_library_modifier name [compiler_subdir ["otherlibs"; name]]
let init () =
register_modifiers "principal" principal;
register_modifiers "config" config;
register_modifiers "testing" testing;
register_modifiers "unix" unix;
register_modifiers "dynlink" dynlink;
register_modifiers "str" str;
List.iter
(fun name -> register_modifiers name (extension_universe_lib name))
[
"stdlib_upstream_compatible";
"stdlib_stable";
"stdlib_beta";
"stdlib_alpha";
];
List.iter
(fun archive -> register_modifiers archive (compilerlibs_archive archive))
[
"ocamlcommon";
"ocamlbytecomp";
"ocamlmiddleend";
"ocamloptcomp";
"ocamltoplevel";
];
register_modifiers "runtime_events" runtime_events;
register_modifiers "systhreads" systhreads;
register_modifiers "latex" latex;
register_modifiers "html" html;
register_modifiers "man" man;
register_modifiers "tool-ocaml-lib" tool_ocaml_lib;
register_modifiers "debugger" debugger;
()