2834
|
1 This file is part of MXE. |
|
2 See index.html for further information. |
|
3 |
|
4 Contains ad hoc patches for cross building. |
|
5 |
|
6 From 71a88993df13ccaaab5957ad2a0aef3adf1d49ff Mon Sep 17 00:00:00 2001 |
|
7 From: MXE |
|
8 Date: Wed, 3 Oct 2012 09:25:11 +0200 |
|
9 Subject: [PATCH 1/5] findlib.ml |
|
10 |
|
11 |
|
12 diff --git a/ocamlbuild/findlib.ml b/ocamlbuild/findlib.ml |
|
13 index b5ef878..77454ed 100644 |
|
14 --- a/ocamlbuild/findlib.ml |
|
15 +++ b/ocamlbuild/findlib.ml |
|
16 @@ -44,7 +44,7 @@ let report_error e = |
|
17 prerr_endline (string_of_error e); |
|
18 exit 2 |
|
19 |
|
20 -let ocamlfind = "ocamlfind" |
|
21 +let ocamlfind = "@target@-ocamlfind" |
|
22 |
|
23 type package = { |
|
24 name: string; |
|
25 -- |
|
26 1.7.2.5 |
|
27 |
|
28 |
|
29 From a1a25210b44d5c7064d5c7a7002676a114b5f539 Mon Sep 17 00:00:00 2001 |
|
30 From: MXE |
|
31 Date: Wed, 3 Oct 2012 09:26:40 +0200 |
|
32 Subject: [PATCH 2/5] main.ml : warnings on use of option -use-ocamlfind |
|
33 |
|
34 |
|
35 diff --git a/ocamlbuild/main.ml b/ocamlbuild/main.ml |
|
36 index 3b9bd89..7045867 100644 |
|
37 --- a/ocamlbuild/main.ml |
|
38 +++ b/ocamlbuild/main.ml |
|
39 @@ -152,6 +152,14 @@ let proceed () = |
|
40 Ocaml_specific.init (); |
|
41 Hooks.call_hook Hooks.After_rules; |
|
42 |
|
43 + if not !Options.use_ocamlfind then begin |
|
44 + if !Param_tags.ocamlfind_tags_used <> StringSet.empty then |
|
45 + Log.eprintf "Warning: Tag(s) '%s' can only work with option -use-ocamlfind" |
|
46 + (String.concat "," (StringSet.elements !Param_tags.ocamlfind_tags_used)); |
|
47 + if !Options.ocaml_pkgs <> [] then |
|
48 + Log.eprintf "Warning: Options -pkg and -pkgs only work with -use-ocamlfind" |
|
49 + end; |
|
50 + |
|
51 Param_tags.init (); |
|
52 |
|
53 Sys.chdir newpwd; |
|
54 -- |
|
55 1.7.2.5 |
|
56 |
|
57 |
|
58 From aa7642e19ec9a81bcdda382d4682ab20df0013ba Mon Sep 17 00:00:00 2001 |
|
59 From: MXE |
|
60 Date: Wed, 3 Oct 2012 09:29:23 +0200 |
|
61 Subject: [PATCH 3/5] param_tags : use of special tags considering whether state of option -use-ocamlfind |
|
62 |
|
63 |
|
64 diff --git a/ocamlbuild/param_tags.ml b/ocamlbuild/param_tags.ml |
|
65 index 02001de..1aae306 100644 |
|
66 --- a/ocamlbuild/param_tags.ml |
|
67 +++ b/ocamlbuild/param_tags.ml |
|
68 @@ -12,15 +12,24 @@ |
|
69 |
|
70 (* Original author: Romain Bardou *) |
|
71 |
|
72 -module StringSet = Set.Make(String) |
|
73 +(* 1 : 'acknowledge' while reading user input; |
|
74 + 2 : 'declare ' to declare what tags are parameterised tags |
|
75 + 3 : 'init' to check acknowledged vs declared tags, |
|
76 + and perform declared actions *) |
|
77 + |
|
78 +module StringSet = My_std.StringSet |
|
79 module SSOSet = Set.Make(struct |
|
80 type t = string * string option |
|
81 let compare = Pervasives.compare |
|
82 end) |
|
83 |
|
84 -(* tag name -> tag action (string -> unit) *) |
|
85 +(* tag (string) -> action (string -> unit) *) |
|
86 +(* all parameterised tags must be declared here *) |
|
87 let declared_tags = Hashtbl.create 17 |
|
88 |
|
89 +(* set of tags that were read (see 'acknowledge'): |
|
90 + ("package",Some "lablgtk2") if "package(lablgtk2)" was read ; |
|
91 + ("foo",None) if "foo" was read *) |
|
92 let acknowledged_tags = ref SSOSet.empty |
|
93 |
|
94 let only_once f = |
|
95 @@ -32,25 +41,32 @@ let only_once f = |
|
96 f param |
|
97 end |
|
98 |
|
99 -let declare name action = |
|
100 - Hashtbl.add declared_tags name (only_once action) |
|
101 +let declare tag action = |
|
102 + Hashtbl.add declared_tags tag (only_once action) |
|
103 |
|
104 -let acknowledge tag = |
|
105 - let tag = Lexers.tag_gen (Lexing.from_string tag) in |
|
106 - acknowledged_tags := SSOSet.add tag !acknowledged_tags |
|
107 +let ocamlfind_tags_used = ref StringSet.empty |
|
108 |
|
109 -let really_acknowledge (name, param) = |
|
110 - match param with |
|
111 - | None -> |
|
112 - if Hashtbl.mem declared_tags name then |
|
113 - Log.eprintf "Warning: tag %S expects a parameter" name |
|
114 - | Some param -> |
|
115 - let actions = List.rev (Hashtbl.find_all declared_tags name) in |
|
116 - if actions = [] then |
|
117 - Log.eprintf "Warning: tag %S does not expect a parameter, but is used with parameter %S" name param; |
|
118 - List.iter (fun f -> f param) actions |
|
119 +let acknowledge tag_string = |
|
120 + let sso = Lexers.tag_gen (Lexing.from_string tag_string) in |
|
121 + let tag = fst sso in |
|
122 + (match tag with |
|
123 + | "package" | "predicate" | "syntax" -> |
|
124 + ocamlfind_tags_used := StringSet.add tag !ocamlfind_tags_used |
|
125 + | _ -> () |
|
126 + ); |
|
127 + acknowledged_tags := SSOSet.add sso !acknowledged_tags |
|
128 |
|
129 let init () = |
|
130 - SSOSet.iter really_acknowledge !acknowledged_tags |
|
131 + SSOSet.iter (fun (tag,param) -> |
|
132 + match param with |
|
133 + | None -> |
|
134 + if Hashtbl.mem declared_tags tag then |
|
135 + Log.eprintf "Warning: tag %S expects a parameter" tag |
|
136 + | Some param -> |
|
137 + let actions = List.rev (Hashtbl.find_all declared_tags tag) in |
|
138 + if actions = [] then |
|
139 + Log.eprintf "Warning: tag %S does not expect a parameter, but is used with parameter %S" tag param; |
|
140 + List.iter (fun f -> f param) actions |
|
141 + ) !acknowledged_tags |
|
142 |
|
143 let make = Printf.sprintf "%s(%s)" |
|
144 -- |
|
145 1.7.2.5 |
|
146 |
|
147 |
|
148 From e1f2adad03b52d5b71dea7fd6e2169d361366d60 Mon Sep 17 00:00:00 2001 |
|
149 From: MXE |
|
150 Date: Wed, 3 Oct 2012 09:30:21 +0200 |
|
151 Subject: [PATCH 4/5] param_tags : use of special tags considering whether state of option -use-ocamlfind (mli) |
|
152 |
|
153 |
|
154 diff --git a/ocamlbuild/param_tags.mli b/ocamlbuild/param_tags.mli |
|
155 index a0047af..0839534 100644 |
|
156 --- a/ocamlbuild/param_tags.mli |
|
157 +++ b/ocamlbuild/param_tags.mli |
|
158 @@ -12,29 +12,38 @@ |
|
159 |
|
160 (* Original author: Romain Bardou *) |
|
161 |
|
162 +(** just a check for use of tag "package" that implies ocamlfind use *) |
|
163 +val ocamlfind_tags_used : My_std.StringSet.t ref |
|
164 + |
|
165 val declare: string -> (string -> unit) -> unit |
|
166 (** Declare a parameterized tag. |
|
167 |
|
168 -[declare "name" action]: [action "param"] will be executed (once) by [init] |
|
169 -if a tag of the form [name(param)] is [acknowledge]d. |
|
170 - |
|
171 -A given tag may be declared several times with different actions. All actions |
|
172 -will be executed, in the order they were declared. *) |
|
173 +[declare tag action] declares [tag] as a parameterized tag. |
|
174 +A given tag may be declared several times with different actions. |
|
175 +[init] will execute all actions in the order they were declared. |
|
176 +Example : [declare "package" action] *) |
|
177 |
|
178 val acknowledge: string -> unit |
|
179 (** Acknowledge a tag. |
|
180 |
|
181 -If the tag is of the form [X(Y)], and have been declared using [declare], |
|
182 -then the actions given using [declare] will be executed with [Y] as parameter |
|
183 -when [init] is executed. The action will only be called once per |
|
184 -acknowledged parameter. *) |
|
185 +[acknowledge "package(lablgtk2)"] will store the tag "package" with |
|
186 +parameter [Some "lablgtk2"]. |
|
187 +[acknowledge "annot"] will store the tag "annot" with |
|
188 +parameter [None] *) |
|
189 |
|
190 val init: unit -> unit |
|
191 (** Initialize parameterized tags. |
|
192 |
|
193 -Call this function once all tags have been [declare]d and [acknowledge]d. |
|
194 +[init] checks in turn each acknowledged tag along with its parameter : |
|
195 +- if the tag is declared (e.g "package"), and parameter=Some "lablgtk2", |
|
196 +calls declared actions (only once) on "lablgtk2". |
|
197 +- if the tag is not declared (e.g "annot"), and parameter=None, nothing is done |
|
198 +- if the tag is not declared, but there is a parameter, raise a warning |
|
199 +- if the tag is declared, but there is no parameter, raise a warning |
|
200 If you [declare] or [acknowledge] a tag after having called [init], this will |
|
201 -have no effect. [init] should only be called once. *) |
|
202 +have no effect. |
|
203 +[init] must be called once all tags have been marked with [declare] and |
|
204 +[acknowledge]. It should only be called once. *) |
|
205 |
|
206 val make: Tags.elt -> string -> Tags.elt |
|
207 (** Make a parameterized tag instance. |
|
208 -- |
|
209 1.7.2.5 |
|
210 |
|
211 |
|
212 From 82118f5d8e0cb7a0193479d0e7459d265692551a Mon Sep 17 00:00:00 2001 |
|
213 From: MXE |
|
214 Date: Wed, 3 Oct 2012 09:31:13 +0200 |
|
215 Subject: [PATCH 5/5] options : support for prefixed ocaml-tools with ocamlfind |
|
216 |
|
217 |
|
218 diff --git a/ocamlbuild/options.ml b/ocamlbuild/options.ml |
|
219 index 1be4b63..48f6648 100644 |
|
220 --- a/ocamlbuild/options.ml |
|
221 +++ b/ocamlbuild/options.ml |
|
222 @@ -39,16 +39,17 @@ let use_menhir = ref false |
|
223 let catch_errors = ref true |
|
224 let use_ocamlfind = ref false |
|
225 |
|
226 -let mk_virtual_solvers = |
|
227 +let mk_virtual_solvers target = |
|
228 let dir = Ocamlbuild_where.bindir in |
|
229 List.iter begin fun cmd -> |
|
230 - let opt = cmd ^ ".opt" in |
|
231 + let target_cmd = target^cmd in |
|
232 + let opt = target_cmd ^ ".opt" in |
|
233 let a_opt = A opt in |
|
234 - let a_cmd = A cmd in |
|
235 + let a_cmd = A target_cmd in |
|
236 let search_in_path = memo Command.search_in_path in |
|
237 let solver () = |
|
238 if sys_file_exists !dir then |
|
239 - let long = filename_concat !dir cmd in |
|
240 + let long = filename_concat !dir target_cmd in |
|
241 let long_opt = long ^ ".opt" in |
|
242 if file_or_exe_exists long_opt then A long_opt |
|
243 else if file_or_exe_exists long then A long |
|
244 @@ -61,9 +62,9 @@ let mk_virtual_solvers = |
|
245 end |
|
246 |
|
247 let () = |
|
248 - mk_virtual_solvers |
|
249 - ["ocamlc"; "ocamlopt"; "ocamldep"; "ocamldoc"; |
|
250 - "ocamlyacc"; "menhir"; "ocamllex"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"] |
|
251 + mk_virtual_solvers "@target@-" |
|
252 + ["ocamlc"; "ocamlopt"; "ocamldep"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"]; |
|
253 + mk_virtual_solvers "" ["ocamldoc"; "ocamlyacc"; "menhir"; "ocamllex"; "ocamlfind"] |
|
254 let ocamlc = ref (V"OCAMLC") |
|
255 let ocamlopt = ref (V"OCAMLOPT") |
|
256 let ocamldep = ref (V"OCAMLDEP") |
|
257 @@ -73,7 +74,7 @@ let ocamllex = ref (V"OCAMLLEX") |
|
258 let ocamlmklib = ref (V"OCAMLMKLIB") |
|
259 let ocamlmktop = ref (V"OCAMLMKTOP") |
|
260 let ocamlrun = ref N |
|
261 -let ocamlfind x = S[V"OCAMLFIND"; x] |
|
262 +let ocamlfind = (V"OCAMLFIND") |
|
263 let program_to_execute = ref false |
|
264 let must_clean = ref false |
|
265 let show_documentation = ref false |
|
266 @@ -261,11 +262,19 @@ let init () = |
|
267 (* TODO: warning message when using an option such as -ocamlc *) |
|
268 (* Note that plugins can still modify these variables After_options. |
|
269 This design decision can easily be changed. *) |
|
270 - ocamlc := ocamlfind & A"ocamlc"; |
|
271 - ocamlopt := ocamlfind & A"ocamlopt"; |
|
272 - ocamldep := ocamlfind & A"ocamldep"; |
|
273 - ocamldoc := ocamlfind & A"ocamldoc"; |
|
274 - ocamlmktop := ocamlfind & A"ocamlmktop"; |
|
275 + List.iter (fun (option,string) -> |
|
276 + (match !option with |
|
277 + | Sh s |
|
278 + | A s -> |
|
279 + Log.eprintf "Warning : Command '-%s %s' overidden by option -use-ocamlfind" string s |
|
280 + | _ -> () |
|
281 + ); |
|
282 + option := S[ocamlfind; A string] |
|
283 + ) [(ocamlc,"ocamlc"); |
|
284 + (ocamlopt,"ocamlopt"); |
|
285 + (ocamldep,"ocamldep"); |
|
286 + (ocamldoc,"ocamldoc"); |
|
287 + (ocamlmktop,"ocamlmktop")] |
|
288 end; |
|
289 |
|
290 let reorder x y = x := !x @ (List.concat (List.rev !y)) in |
|
291 -- |
|
292 1.7.2.5 |
|
293 |