1
1
(* OASIS_START *)
2
- (* DO NOT EDIT (digest: e270c2e88368dd27093c3e0e7085db75 ) *)
2
+ (* DO NOT EDIT (digest: 7e1f2e1d53bf2952193c34fd943d0c23 ) *)
3
3
module OASISGettext = struct
4
4
(* # 22 "src/oasis/OASISGettext.ml" *)
5
5
@@ -39,10 +39,10 @@ module OASISExpr = struct
39
39
open OASISGettext
40
40
41
41
42
- type test = string
42
+ type test = string
43
43
44
44
45
- type flag = string
45
+ type flag = string
46
46
47
47
48
48
type t =
@@ -52,10 +52,10 @@ module OASISExpr = struct
52
52
| EOr of t * t
53
53
| EFlag of flag
54
54
| ETest of test * string
55
-
56
55
57
56
58
- type 'a choices = (t * 'a ) list
57
+
58
+ type 'a choices = (t * 'a ) list
59
59
60
60
61
61
let eval var_get t =
@@ -204,26 +204,27 @@ module BaseEnvLight = struct
204
204
end
205
205
206
206
207
- let var_get name env =
208
- let rec var_expand str =
209
- let buff =
210
- Buffer. create ((String. length str) * 2 )
211
- in
212
- Buffer. add_substitute
213
- buff
214
- (fun var ->
215
- try
216
- var_expand (MapString. find var env)
217
- with Not_found ->
218
- failwith
219
- (Printf. sprintf
220
- " No variable %s defined when trying to expand %S."
221
- var
222
- str))
223
- str;
224
- Buffer. contents buff
207
+ let rec var_expand str env =
208
+ let buff =
209
+ Buffer. create ((String. length str) * 2 )
225
210
in
226
- var_expand (MapString. find name env)
211
+ Buffer. add_substitute
212
+ buff
213
+ (fun var ->
214
+ try
215
+ var_expand (MapString. find var env) env
216
+ with Not_found ->
217
+ failwith
218
+ (Printf. sprintf
219
+ " No variable %s defined when trying to expand %S."
220
+ var
221
+ str))
222
+ str;
223
+ Buffer. contents buff
224
+
225
+
226
+ let var_get name env =
227
+ var_expand (MapString. find name env) env
227
228
228
229
229
230
let var_choose lst env =
@@ -233,7 +234,7 @@ module BaseEnvLight = struct
233
234
end
234
235
235
236
236
- # 236 " myocamlbuild.ml"
237
+ # 237 " myocamlbuild.ml"
237
238
module MyOCamlbuildFindlib = struct
238
239
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
239
240
@@ -258,6 +259,31 @@ module MyOCamlbuildFindlib = struct
258
259
Ocamlbuild_pack.Lexers. blank_sep_strings
259
260
260
261
262
+ let exec_from_conf exec =
263
+ let exec =
264
+ let env_filename = Pathname. basename BaseEnvLight. default_filename in
265
+ let env = BaseEnvLight. load ~filename: env_filename ~allow_empty: true () in
266
+ try
267
+ BaseEnvLight. var_get exec env
268
+ with Not_found ->
269
+ Printf. eprintf " W: Cannot get variable %s\n " exec;
270
+ exec
271
+ in
272
+ let fix_win32 str =
273
+ if Sys. os_type = " Win32" then begin
274
+ let buff = Buffer. create (String. length str) in
275
+ (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'.
276
+ *)
277
+ String. iter
278
+ (fun c -> Buffer. add_char buff (if c = '\\' then '/' else c))
279
+ str;
280
+ Buffer. contents buff
281
+ end else begin
282
+ str
283
+ end
284
+ in
285
+ fix_win32 exec
286
+
261
287
let split s ch =
262
288
let buf = Buffer. create 13 in
263
289
let x = ref [] in
@@ -285,17 +311,7 @@ module MyOCamlbuildFindlib = struct
285
311
with Not_found -> s
286
312
287
313
(* ocamlfind command *)
288
- let ocamlfind x =
289
- let ocamlfind_prog =
290
- let env_filename = Pathname. basename BaseEnvLight. default_filename in
291
- let env = BaseEnvLight. load ~filename: env_filename ~allow_empty: true () in
292
- try
293
- BaseEnvLight. var_get " ocamlfind" env
294
- with Not_found ->
295
- Printf. eprintf " W: Cannot get variable ocamlfind" ;
296
- " ocamlfind"
297
- in
298
- S [Sh ocamlfind_prog; x]
314
+ let ocamlfind x = S [Sh (exec_from_conf " ocamlfind" ); x]
299
315
300
316
(* This lists all supported packages. *)
301
317
let find_packages () =
@@ -306,9 +322,25 @@ module MyOCamlbuildFindlib = struct
306
322
let find_syntaxes () = [" camlp4o" ; " camlp4r" ]
307
323
308
324
325
+ let well_known_syntax = [
326
+ " camlp4.quotations.o" ;
327
+ " camlp4.quotations.r" ;
328
+ " camlp4.exceptiontracer" ;
329
+ " camlp4.extend" ;
330
+ " camlp4.foldgenerator" ;
331
+ " camlp4.listcomprehension" ;
332
+ " camlp4.locationstripper" ;
333
+ " camlp4.macro" ;
334
+ " camlp4.mapgenerator" ;
335
+ " camlp4.metagenerator" ;
336
+ " camlp4.profiler" ;
337
+ " camlp4.tracer"
338
+ ]
339
+
340
+
309
341
let dispatch =
310
342
function
311
- | Before_options ->
343
+ | After_options ->
312
344
(* By using Before_options one let command line options have an higher
313
345
* priority on the contrary using After_options will guarantee to have
314
346
* the higher priority override default commands by ocamlfind ones *)
@@ -331,13 +363,17 @@ module MyOCamlbuildFindlib = struct
331
363
List. iter
332
364
begin fun pkg ->
333
365
let base_args = [A " -package" ; A pkg] in
366
+ (* TODO: consider how to really choose camlp4o or camlp4r. *)
334
367
let syn_args = [A " -syntax" ; A " camlp4o" ] in
335
368
let args =
336
- (* Heuristic to identify syntax extensions: whether they end in
337
- * ".syntax"; some might not *)
338
- if Filename. check_suffix pkg " syntax"
339
- then syn_args @ base_args
340
- else base_args
369
+ (* Heuristic to identify syntax extensions: whether they end in
370
+ ".syntax"; some might not.
371
+ *)
372
+ if Filename. check_suffix pkg " syntax" ||
373
+ List. mem pkg well_known_syntax then
374
+ syn_args @ base_args
375
+ else
376
+ base_args
341
377
in
342
378
flag [" ocaml" ; " compile" ; " pkg_" ^ pkg] & S args;
343
379
flag [" ocaml" ; " ocamldep" ; " pkg_" ^ pkg] & S args;
@@ -394,10 +430,10 @@ module MyOCamlbuildBase = struct
394
430
module OC = Ocamlbuild_pack. Ocaml_compiler
395
431
396
432
397
- type dir = string
398
- type file = string
399
- type name = string
400
- type tag = string
433
+ type dir = string
434
+ type file = string
435
+ type name = string
436
+ type tag = string
401
437
402
438
403
439
(* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
@@ -412,7 +448,7 @@ module MyOCamlbuildBase = struct
412
448
* directory.
413
449
*)
414
450
includes : (dir * dir list ) list ;
415
- }
451
+ }
416
452
417
453
418
454
let env_filename =
@@ -455,7 +491,7 @@ module MyOCamlbuildBase = struct
455
491
try
456
492
opt := no_trailing_dot (BaseEnvLight. var_get var env)
457
493
with Not_found ->
458
- Printf. eprintf " W: Cannot get variable %s" var)
494
+ Printf. eprintf " W: Cannot get variable %s\n " var)
459
495
[
460
496
Options. ext_obj, " ext_obj" ;
461
497
Options. ext_lib, " ext_lib" ;
@@ -531,10 +567,14 @@ module MyOCamlbuildBase = struct
531
567
(* Add flags *)
532
568
List. iter
533
569
(fun (tags , cond_specs ) ->
534
- let spec =
535
- BaseEnvLight. var_choose cond_specs env
570
+ let spec = BaseEnvLight. var_choose cond_specs env in
571
+ let rec eval_specs =
572
+ function
573
+ | S lst -> S (List. map eval_specs lst)
574
+ | A str -> A (BaseEnvLight. var_expand str env)
575
+ | spec -> spec
536
576
in
537
- flag tags & spec)
577
+ flag tags & (eval_specs spec) )
538
578
t.flags
539
579
| _ ->
540
580
()
@@ -551,7 +591,7 @@ module MyOCamlbuildBase = struct
551
591
end
552
592
553
593
554
- # 554 " myocamlbuild.ml"
594
+ # 594 " myocamlbuild.ml"
555
595
open Ocamlbuild_plugin ;;
556
596
let package_default =
557
597
{
@@ -575,6 +615,6 @@ let package_default =
575
615
576
616
let dispatch_default = MyOCamlbuildBase. dispatch_default package_default;;
577
617
578
- # 579 " myocamlbuild.ml"
618
+ # 619 " myocamlbuild.ml"
579
619
(* OASIS_STOP *)
580
620
Ocamlbuild_plugin. dispatch dispatch_default;;
0 commit comments