~ubuntu-branches/ubuntu/trusty/sexplib310/trusty

« back to all changes in this revision

Viewing changes to setup.ml

  • Committer: Package Import Robot
  • Author(s): Stéphane Glondu
  • Date: 2013-12-03 21:36:45 UTC
  • mfrom: (11.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20131203213645-h1if1c6hxual8p11
Tags: 109.20.00-2
* Team upload
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(* setup.ml generated for the first time by OASIS v0.2.0 *)
2
 
 
3
1
(* OASIS_START *)
4
 
(* DO NOT EDIT (digest: 45e10b84ce2d3eaf3fd842c91210e92a) *)
 
2
(* DO NOT EDIT (digest: 0f2d96e9ac0553c3e7c7ce1da1fa5979) *)
5
3
(*
6
 
   Regenerated by OASIS v0.3.0~rc2
 
4
   Regenerated by OASIS v0.3.0
7
5
   Visit http://oasis.forge.ocamlcore.org for more information and
8
6
   documentation about functions used in this file.
9
7
*)
10
8
module OASISGettext = struct
11
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISGettext.ml"
12
 
  
 
9
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISGettext.ml" *)
 
10
 
13
11
  let ns_ str =
14
12
    str
15
 
  
 
13
 
16
14
  let s_ str =
17
15
    str
18
 
  
 
16
 
19
17
  let f_ (str : ('a, 'b, 'c, 'd) format4) =
20
18
    str
21
 
  
 
19
 
22
20
  let fn_ fmt1 fmt2 n =
23
21
    if n = 1 then
24
22
      fmt1^^""
25
23
    else
26
24
      fmt2^^""
27
 
  
 
25
 
28
26
  let init =
29
27
    []
30
 
  
 
28
 
31
29
end
32
30
 
33
31
module OASISContext = struct
34
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISContext.ml"
35
 
  
 
32
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISContext.ml" *)
 
33
 
36
34
  open OASISGettext
37
 
  
 
35
 
38
36
  type level =
39
37
    [ `Debug
40
38
    | `Info
41
39
    | `Warning
42
40
    | `Error]
43
 
  
 
41
 
44
42
  type t =
45
43
    {
46
 
      verbose:               bool;
 
44
      quiet:                 bool;
 
45
      info:                  bool;
47
46
      debug:                 bool;
48
47
      ignore_plugins:        bool;
49
48
      ignore_unknown_fields: bool;
50
49
      printf:                level -> string -> unit;
51
50
    }
52
 
  
 
51
 
53
52
  let printf lvl str =
54
53
    let beg =
55
54
      match lvl with
59
58
        | `Debug -> s_ "D: "
60
59
    in
61
60
      prerr_endline (beg^str)
62
 
  
 
61
 
63
62
  let default =
64
63
    ref
65
64
      {
66
 
        verbose               = true;
 
65
        quiet                 = false;
 
66
        info                  = false;
67
67
        debug                 = false;
68
68
        ignore_plugins        = false;
69
69
        ignore_unknown_fields = false;
70
70
        printf                = printf;
71
71
      }
72
 
  
 
72
 
73
73
  let quiet =
74
 
    {!default with
75
 
         verbose = false;
76
 
         debug   = false;
77
 
    }
78
 
  
79
 
  
 
74
    {!default with quiet = true}
 
75
 
 
76
 
80
77
  let args () =
81
78
    ["-quiet",
82
 
     Arg.Unit (fun () -> default := {!default with verbose = false}),
 
79
     Arg.Unit (fun () -> default := {!default with quiet = true}),
83
80
     (s_ " Run quietly");
84
 
  
 
81
 
 
82
     "-info",
 
83
     Arg.Unit (fun () -> default := {!default with info = true}),
 
84
     (s_ " Display information message");
 
85
 
 
86
 
85
87
     "-debug",
86
88
     Arg.Unit (fun () -> default := {!default with debug = true}),
87
89
     (s_ " Output debug message")]
88
90
end
89
91
 
 
92
module OASISString = struct
 
93
(* # 1 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISString.ml" *)
 
94
 
 
95
 
 
96
 
 
97
  (** Various string utilities.
 
98
     
 
99
      Mostly inspired by extlib and batteries ExtString and BatString libraries.
 
100
 
 
101
      @author Sylvain Le Gall
 
102
    *)
 
103
 
 
104
  let nsplitf str f =
 
105
    if str = "" then
 
106
      []
 
107
    else
 
108
      let buf = Buffer.create 13 in
 
109
      let lst = ref [] in
 
110
      let push () =
 
111
        lst := Buffer.contents buf :: !lst;
 
112
        Buffer.clear buf
 
113
      in
 
114
      let str_len = String.length str in
 
115
        for i = 0 to str_len - 1 do
 
116
          if f str.[i] then
 
117
            push ()
 
118
          else
 
119
            Buffer.add_char buf str.[i]
 
120
        done;
 
121
        push ();
 
122
        List.rev !lst
 
123
 
 
124
  (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
 
125
      separator.
 
126
    *)
 
127
  let nsplit str c =
 
128
    nsplitf str ((=) c)
 
129
 
 
130
  let find ~what ?(offset=0) str =
 
131
    let what_idx = ref 0 in
 
132
    let str_idx = ref offset in 
 
133
      while !str_idx < String.length str && 
 
134
            !what_idx < String.length what do
 
135
        if str.[!str_idx] = what.[!what_idx] then
 
136
          incr what_idx
 
137
        else
 
138
          what_idx := 0;
 
139
        incr str_idx
 
140
      done;
 
141
      if !what_idx <> String.length what then
 
142
        raise Not_found
 
143
      else 
 
144
        !str_idx - !what_idx
 
145
 
 
146
  let sub_start str len = 
 
147
    let str_len = String.length str in
 
148
    if len >= str_len then
 
149
      ""
 
150
    else
 
151
      String.sub str len (str_len - len)
 
152
 
 
153
  let sub_end ?(offset=0) str len =
 
154
    let str_len = String.length str in
 
155
    if len >= str_len then
 
156
      ""
 
157
    else
 
158
      String.sub str 0 (str_len - len)
 
159
 
 
160
  let starts_with ~what ?(offset=0) str =
 
161
    let what_idx = ref 0 in
 
162
    let str_idx = ref offset in
 
163
    let ok = ref true in
 
164
      while !ok &&
 
165
            !str_idx < String.length str && 
 
166
            !what_idx < String.length what do
 
167
        if str.[!str_idx] = what.[!what_idx] then
 
168
          incr what_idx
 
169
        else
 
170
          ok := false;
 
171
        incr str_idx
 
172
      done;
 
173
      if !what_idx = String.length what then
 
174
        true
 
175
      else 
 
176
        false
 
177
 
 
178
  let strip_starts_with ~what str =
 
179
    if starts_with ~what str then
 
180
      sub_start str (String.length what)
 
181
    else
 
182
      raise Not_found
 
183
 
 
184
  let ends_with ~what ?(offset=0) str =
 
185
    let what_idx = ref ((String.length what) - 1) in
 
186
    let str_idx = ref ((String.length str) - 1) in
 
187
    let ok = ref true in
 
188
      while !ok &&
 
189
            offset <= !str_idx && 
 
190
            0 <= !what_idx do
 
191
        if str.[!str_idx] = what.[!what_idx] then
 
192
          decr what_idx
 
193
        else
 
194
          ok := false;
 
195
        decr str_idx
 
196
      done;
 
197
      if !what_idx = -1 then
 
198
        true
 
199
      else 
 
200
        false
 
201
 
 
202
  let strip_ends_with ~what str =
 
203
    if ends_with ~what str then
 
204
      sub_end str (String.length what)
 
205
    else
 
206
      raise Not_found
 
207
 
 
208
  let replace_chars f s =
 
209
    let buf = String.make (String.length s) 'X' in
 
210
      for i = 0 to String.length s - 1 do
 
211
        buf.[i] <- f s.[i]
 
212
      done;
 
213
      buf
 
214
 
 
215
end
 
216
 
90
217
module OASISUtils = struct
91
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISUtils.ml"
92
 
  
 
218
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISUtils.ml" *)
 
219
 
93
220
  open OASISGettext
94
 
  
 
221
 
95
222
  module MapString = Map.Make(String)
96
 
  
 
223
 
97
224
  let map_string_of_assoc assoc =
98
225
    List.fold_left
99
226
      (fun acc (k, v) -> MapString.add k v acc)
100
227
      MapString.empty
101
228
      assoc
102
 
  
 
229
 
103
230
  module SetString = Set.Make(String)
104
 
  
 
231
 
105
232
  let set_string_add_list st lst =
106
233
    List.fold_left
107
234
      (fun acc e -> SetString.add e acc)
108
235
      st
109
236
      lst
110
 
  
 
237
 
111
238
  let set_string_of_list =
112
239
    set_string_add_list
113
240
      SetString.empty
114
 
  
115
 
  
 
241
 
 
242
 
116
243
  let compare_csl s1 s2 =
117
244
    String.compare (String.lowercase s1) (String.lowercase s2)
118
 
  
 
245
 
119
246
  module HashStringCsl =
120
247
    Hashtbl.Make
121
248
      (struct
122
249
         type t = string
123
 
  
 
250
 
124
251
         let equal s1 s2 =
125
252
             (String.lowercase s1) = (String.lowercase s2)
126
 
  
 
253
 
127
254
         let hash s =
128
255
           Hashtbl.hash (String.lowercase s)
129
256
       end)
130
 
  
131
 
  let split sep str =
132
 
    let str_len =
133
 
      String.length str
134
 
    in
135
 
    let rec split_aux acc pos =
136
 
      if pos < str_len then
137
 
        (
138
 
          let pos_sep =
139
 
            try
140
 
              String.index_from str pos sep
141
 
            with Not_found ->
142
 
              str_len
143
 
          in
144
 
          let part =
145
 
            String.sub str pos (pos_sep - pos)
146
 
          in
147
 
          let acc =
148
 
            part :: acc
149
 
          in
150
 
            if pos_sep >= str_len then
151
 
              (
152
 
                (* Nothing more in the string *)
153
 
                List.rev acc
154
 
              )
155
 
            else if pos_sep = (str_len - 1) then
156
 
              (
157
 
                (* String end with a separator *)
158
 
                List.rev ("" :: acc)
159
 
              )
160
 
            else
161
 
              (
162
 
                split_aux acc (pos_sep + 1)
163
 
              )
164
 
        )
165
 
      else
166
 
        (
167
 
          List.rev acc
168
 
        )
169
 
    in
170
 
      split_aux [] 0
171
 
  
172
 
  
 
257
 
173
258
  let varname_of_string ?(hyphen='_') s =
174
259
    if String.length s = 0 then
175
260
      begin
177
262
      end
178
263
    else
179
264
      begin
180
 
        let buff =
181
 
          Buffer.create (String.length s)
182
 
        in
183
 
          (* Start with a _ if digit *)
184
 
          if '0' <= s.[0] && s.[0] <= '9' then
185
 
            Buffer.add_char buff hyphen;
186
 
  
187
 
          String.iter
 
265
        let buf =
 
266
          OASISString.replace_chars
188
267
            (fun c ->
189
268
               if ('a' <= c && c <= 'z')
190
269
                 ||
191
270
                  ('A' <= c && c <= 'Z')
192
271
                 ||
193
272
                  ('0' <= c && c <= '9') then
194
 
                 Buffer.add_char buff c
 
273
                 c
195
274
               else
196
 
                 Buffer.add_char buff hyphen)
 
275
                 hyphen)
197
276
            s;
198
 
  
199
 
          String.lowercase (Buffer.contents buff)
 
277
        in
 
278
        let buf =
 
279
          (* Start with a _ if digit *)
 
280
          if '0' <= s.[0] && s.[0] <= '9' then
 
281
            "_"^buf
 
282
          else
 
283
            buf
 
284
        in
 
285
          String.lowercase buf
200
286
      end
201
 
  
 
287
 
202
288
  let varname_concat ?(hyphen='_') p s =
 
289
    let what = String.make 1 hyphen in
203
290
    let p =
204
 
      let p_len =
205
 
        String.length p
206
 
      in
207
 
        if p_len > 0 && p.[p_len - 1] = hyphen then
208
 
          String.sub p 0 (p_len - 1)
209
 
        else
210
 
          p
 
291
      try
 
292
        OASISString.strip_ends_with ~what p
 
293
      with Not_found ->
 
294
        p
211
295
    in
212
296
    let s =
213
 
      let s_len =
214
 
        String.length s
215
 
      in
216
 
        if s_len > 0 && s.[0] = hyphen then
217
 
          String.sub s 1 (s_len - 1)
218
 
        else
219
 
          s
 
297
      try
 
298
        OASISString.strip_starts_with ~what s
 
299
      with Not_found ->
 
300
        s
220
301
    in
221
 
      Printf.sprintf "%s%c%s" p hyphen s
222
 
  
223
 
  
 
302
      p^what^s
 
303
 
 
304
 
224
305
  let is_varname str =
225
306
    str = varname_of_string str
226
 
  
 
307
 
227
308
  let failwithf fmt = Printf.ksprintf failwith fmt
228
 
  
 
309
 
229
310
end
230
311
 
231
312
module PropList = struct
232
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/PropList.ml"
233
 
  
 
313
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/PropList.ml" *)
 
314
 
234
315
  open OASISGettext
235
 
  
 
316
 
236
317
  type name = string
237
 
  
 
318
 
238
319
  exception Not_set of name * string option
239
320
  exception No_printer of name
240
321
  exception Unknown_field of name * name
241
 
  
 
322
 
242
323
  let () =
243
324
    Printexc.register_printer
244
325
      (function
256
337
               (Printf.sprintf (f_ "Field %s is not defined in schema %s") nm schm)
257
338
         | _ ->
258
339
             None)
259
 
  
 
340
 
260
341
  module Data =
261
342
  struct
262
 
  
 
343
 
263
344
    type t =
264
345
        (name, unit -> unit) Hashtbl.t
265
 
  
 
346
 
266
347
    let create () =
267
348
      Hashtbl.create 13
268
 
  
 
349
 
269
350
    let clear t =
270
351
      Hashtbl.clear t
271
 
  
272
 
# 71 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/PropList.ml"
 
352
 
 
353
(* # 71 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/PropList.ml" *)
273
354
  end
274
 
  
 
355
 
275
356
  module Schema =
276
357
  struct
277
 
  
 
358
 
278
359
    type ('ctxt, 'extra) value =
279
360
        {
280
361
          get:   Data.t -> string;
282
363
          help:  (unit -> string) option;
283
364
          extra: 'extra;
284
365
        }
285
 
  
 
366
 
286
367
    type ('ctxt, 'extra) t =
287
368
        {
288
369
          name:      name;
290
371
          order:     name Queue.t;
291
372
          name_norm: string -> string;
292
373
        }
293
 
  
 
374
 
294
375
    let create ?(case_insensitive=false) nm =
295
376
      {
296
377
        name      = nm;
302
383
           else
303
384
             fun s -> s);
304
385
      }
305
 
  
 
386
 
306
387
    let add t nm set get extra help =
307
388
      let key =
308
389
        t.name_norm nm
309
390
      in
310
 
  
 
391
 
311
392
        if Hashtbl.mem t.fields key then
312
393
          failwith
313
394
            (Printf.sprintf
323
404
            extra = extra;
324
405
          };
325
406
        Queue.add nm t.order
326
 
  
 
407
 
327
408
    let mem t nm =
328
409
      Hashtbl.mem t.fields nm
329
 
  
 
410
 
330
411
    let find t nm =
331
412
      try
332
413
        Hashtbl.find t.fields (t.name_norm nm)
333
414
      with Not_found ->
334
415
        raise (Unknown_field (nm, t.name))
335
 
  
 
416
 
336
417
    let get t data nm =
337
418
      (find t nm).get data
338
 
  
 
419
 
339
420
    let set t data nm ?context x =
340
421
      (find t nm).set
341
422
        data
342
423
        ?context
343
424
        x
344
 
  
 
425
 
345
426
    let fold f acc t =
346
427
      Queue.fold
347
428
        (fun acc k ->
351
432
             f acc k v.extra v.help)
352
433
        acc
353
434
        t.order
354
 
  
 
435
 
355
436
    let iter f t =
356
437
      fold
357
438
        (fun () -> f)
358
439
        ()
359
440
        t
360
 
  
 
441
 
361
442
    let name t =
362
443
      t.name
363
444
  end
364
 
  
 
445
 
365
446
  module Field =
366
447
  struct
367
 
  
 
448
 
368
449
    type ('ctxt, 'value, 'extra) t =
369
450
        {
370
451
          set:    Data.t -> ?context:'ctxt -> 'value -> unit;
374
455
          help:   (unit -> string) option;
375
456
          extra:  'extra;
376
457
        }
377
 
  
 
458
 
378
459
    let new_id =
379
460
      let last_id =
380
461
        ref 0
381
462
      in
382
463
        fun () -> incr last_id; !last_id
383
 
  
 
464
 
384
465
    let create ?schema ?name ?parse ?print ?default ?update ?help extra =
385
466
      (* Default value container *)
386
467
      let v =
387
468
        ref None
388
469
      in
389
 
  
 
470
 
390
471
      (* If name is not given, create unique one *)
391
472
      let nm =
392
473
        match name with
393
474
          | Some s -> s
394
475
          | None -> Printf.sprintf "_anon_%d" (new_id ())
395
476
      in
396
 
  
 
477
 
397
478
      (* Last chance to get a value: the default *)
398
479
      let default () =
399
480
        match default with
400
481
          | Some d -> d
401
482
          | None -> raise (Not_set (nm, Some (s_ "no default value")))
402
483
      in
403
 
  
 
484
 
404
485
      (* Get data *)
405
486
      let get data =
406
487
        (* Get value *)
412
493
        with Not_found ->
413
494
          default ()
414
495
      in
415
 
  
 
496
 
416
497
      (* Set data *)
417
498
      let set data ?context x =
418
499
        let x =
432
513
            nm
433
514
            (fun () -> v := Some x)
434
515
      in
435
 
  
 
516
 
436
517
      (* Parse string value, if possible *)
437
518
      let parse =
438
519
        match parse with
446
527
                     nm
447
528
                     s)
448
529
      in
449
 
  
 
530
 
450
531
      (* Set data, from string *)
451
532
      let sets data ?context s =
452
533
        set ?context data (parse ?context s)
453
534
      in
454
 
  
 
535
 
455
536
      (* Output value as string, if possible *)
456
537
      let print =
457
538
        match print with
460
541
          | None ->
461
542
              fun _ -> raise (No_printer nm)
462
543
      in
463
 
  
 
544
 
464
545
      (* Get data, as a string *)
465
546
      let gets data =
466
547
        print (get data)
467
548
      in
468
 
  
 
549
 
469
550
        begin
470
551
          match schema with
471
552
            | Some t ->
473
554
            | None ->
474
555
                ()
475
556
        end;
476
 
  
 
557
 
477
558
        {
478
559
          set   = set;
479
560
          get   = get;
482
563
          help  = help;
483
564
          extra = extra;
484
565
        }
485
 
  
 
566
 
486
567
    let fset data t ?context x =
487
568
      t.set data ?context x
488
 
  
 
569
 
489
570
    let fget data t =
490
571
      t.get data
491
 
  
 
572
 
492
573
    let fsets data t ?context s =
493
574
      t.sets data ?context s
494
 
  
 
575
 
495
576
    let fgets data t =
496
577
      t.gets data
497
 
  
 
578
 
498
579
  end
499
 
  
 
580
 
500
581
  module FieldRO =
501
582
  struct
502
 
  
 
583
 
503
584
    let create ?schema ?name ?parse ?print ?default ?update ?help extra =
504
585
      let fld =
505
586
        Field.create ?schema ?name ?parse ?print ?default ?update ?help extra
506
587
      in
507
588
        fun data -> Field.fget data fld
508
 
  
 
589
 
509
590
  end
510
591
end
511
592
 
512
593
module OASISMessage = struct
513
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISMessage.ml"
514
 
  
515
 
  
 
594
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISMessage.ml" *)
 
595
 
 
596
 
516
597
  open OASISGettext
517
598
  open OASISContext
518
 
  
 
599
 
519
600
  let generic_message ~ctxt lvl fmt =
520
601
    let cond =
521
 
      match lvl with
522
 
        | `Debug -> ctxt.debug
523
 
        | _ -> ctxt.verbose
 
602
      if ctxt.quiet then
 
603
        false
 
604
      else
 
605
        match lvl with
 
606
          | `Debug -> ctxt.debug
 
607
          | `Info  -> ctxt.info
 
608
          | _ -> true
524
609
    in
525
610
      Printf.ksprintf
526
611
        (fun str ->
529
614
               ctxt.printf lvl str
530
615
             end)
531
616
        fmt
532
 
  
 
617
 
533
618
  let debug ~ctxt fmt =
534
619
    generic_message ~ctxt `Debug fmt
535
 
  
 
620
 
536
621
  let info ~ctxt fmt =
537
622
    generic_message ~ctxt `Info fmt
538
 
  
 
623
 
539
624
  let warning ~ctxt fmt =
540
625
    generic_message ~ctxt `Warning fmt
541
 
  
 
626
 
542
627
  let error ~ctxt fmt =
543
628
    generic_message ~ctxt `Error fmt
544
 
  
 
629
 
545
630
end
546
631
 
547
632
module OASISVersion = struct
548
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISVersion.ml"
549
 
  
 
633
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISVersion.ml" *)
 
634
 
550
635
  open OASISGettext
551
 
  
552
 
  
553
 
  
 
636
 
 
637
 
 
638
 
554
639
  type s = string
555
 
  
 
640
 
556
641
  type t = string 
557
 
  
 
642
 
558
643
  type comparator =
559
644
    | VGreater of t
560
645
    | VGreaterEqual of t
564
649
    | VOr of  comparator * comparator
565
650
    | VAnd of comparator * comparator
566
651
    
567
 
  
 
652
 
568
653
  (* Range of allowed characters *)
569
654
  let is_digit c =
570
655
    '0' <= c && c <= '9'
571
 
  
 
656
 
572
657
  let is_alpha c =
573
658
    ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
574
 
  
 
659
 
575
660
  let is_special =
576
661
    function
577
662
      | '.' | '+' | '-' | '~' -> true
578
663
      | _ -> false
579
 
  
 
664
 
580
665
  let rec version_compare v1 v2 =
581
666
    if v1 <> "" || v2 <> "" then
582
667
      begin
590
675
          else if is_alpha c then Char.code c
591
676
          else (Char.code c) + 256
592
677
        in
593
 
  
 
678
 
594
679
        let len1 = String.length v1 in
595
680
        let len2 = String.length v2 in
596
 
  
 
681
 
597
682
        let p = ref 0 in
598
 
  
 
683
 
599
684
        (** Compare ascii part *)
600
685
        let compare_vascii () =
601
686
          let cmp = ref 0 in
612
697
          else
613
698
            !cmp
614
699
        in
615
 
  
 
700
 
616
701
        (** Compare digit part *)
617
702
        let compare_digit () =
618
703
          let extract_int v p =
634
719
          let i2, tl2 = extract_int v2 (ref !p) in
635
720
            i1 - i2, tl1, tl2
636
721
        in
637
 
  
 
722
 
638
723
          match compare_vascii () with
639
724
            | 0 ->
640
725
                begin
656
741
      begin
657
742
        0
658
743
      end
659
 
  
660
 
  
661
 
  let version_of_string str =
662
 
    String.iter
663
 
      (fun c ->
664
 
         if is_alpha c || is_digit c || is_special c then
665
 
           ()
666
 
         else
667
 
           failwith
668
 
             (Printf.sprintf
669
 
                (f_ "Char %C is not allowed in version '%s'")
670
 
                c str))
671
 
      str;
672
 
    str
673
 
  
674
 
  let string_of_version t =
675
 
    t
676
 
  
 
744
 
 
745
 
 
746
  let version_of_string str = str
 
747
 
 
748
  let string_of_version t = t
 
749
 
677
750
  let chop t =
678
751
    try
679
752
      let pos =
682
755
        String.sub t 0 pos
683
756
    with Not_found ->
684
757
      t
685
 
  
 
758
 
686
759
  let rec comparator_apply v op =
687
760
    match op with
688
761
      | VGreater cv ->
699
772
          (comparator_apply v op1) || (comparator_apply v op2)
700
773
      | VAnd (op1, op2) ->
701
774
          (comparator_apply v op1) && (comparator_apply v op2)
702
 
  
 
775
 
703
776
  let rec string_of_comparator =
704
777
    function
705
778
      | VGreater v  -> "> "^(string_of_version v)
711
784
          (string_of_comparator c1)^" || "^(string_of_comparator c2)
712
785
      | VAnd (c1, c2) ->
713
786
          (string_of_comparator c1)^" && "^(string_of_comparator c2)
714
 
  
 
787
 
715
788
  let rec varname_of_comparator =
716
789
    let concat p v =
717
790
      OASISUtils.varname_concat
729
802
            (varname_of_comparator c1)^"_or_"^(varname_of_comparator c2)
730
803
        | VAnd (c1, c2) ->
731
804
            (varname_of_comparator c1)^"_and_"^(varname_of_comparator c2)
732
 
  
 
805
 
 
806
  let version_0_3_or_after t =
 
807
    comparator_apply t (VGreaterEqual (string_of_version "0.3"))
 
808
 
733
809
end
734
810
 
735
811
module OASISLicense = struct
736
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISLicense.ml"
737
 
  
 
812
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISLicense.ml" *)
 
813
 
738
814
  (** License for _oasis fields
739
815
      @author Sylvain Le Gall
740
816
    *)
741
 
  
742
 
  
743
 
  
 
817
 
 
818
 
 
819
 
744
820
  type license = string 
745
 
  
 
821
 
746
822
  type license_exception = string 
747
 
  
 
823
 
748
824
  type license_version =
749
825
    | Version of OASISVersion.t
750
826
    | VersionOrLater of OASISVersion.t
751
827
    | NoVersion
752
828
    
753
 
  
 
829
 
 
830
  type license_dep_5_unit =
 
831
    {
 
832
      license:   license;
 
833
      excption:  license_exception option;
 
834
      version:   license_version;
 
835
    }
 
836
    
 
837
 
754
838
  type license_dep_5 =
755
 
      {
756
 
        license:    license;
757
 
        exceptions: license_exception list;
758
 
        version:    license_version;
759
 
      } 
760
 
  
 
839
    | DEP5Unit of license_dep_5_unit
 
840
    | DEP5Or of license_dep_5 list
 
841
    | DEP5And of license_dep_5 list
 
842
    
 
843
 
761
844
  type t =
762
845
    | DEP5License of license_dep_5
763
846
    | OtherLicense of string (* URL *)
764
847
    
765
 
  
 
848
 
766
849
end
767
850
 
768
851
module OASISExpr = struct
769
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISExpr.ml"
770
 
  
771
 
  
772
 
  
 
852
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISExpr.ml" *)
 
853
 
 
854
 
 
855
 
773
856
  open OASISGettext
774
 
  
 
857
 
775
858
  type test = string 
776
 
  
 
859
 
777
860
  type flag = string 
778
 
  
 
861
 
779
862
  type t =
780
863
    | EBool of bool
781
864
    | ENot of t
784
867
    | EFlag of flag
785
868
    | ETest of test * string
786
869
    
787
 
  
 
870
 
788
871
  type 'a choices = (t * 'a) list 
789
 
  
 
872
 
790
873
  let eval var_get t =
791
874
    let rec eval' =
792
875
      function
793
876
        | EBool b ->
794
877
            b
795
 
  
 
878
 
796
879
        | ENot e ->
797
880
            not (eval' e)
798
 
  
 
881
 
799
882
        | EAnd (e1, e2) ->
800
883
            (eval' e1) && (eval' e2)
801
 
  
 
884
 
802
885
        | EOr (e1, e2) ->
803
886
            (eval' e1) || (eval' e2)
804
 
  
 
887
 
805
888
        | EFlag nm ->
806
889
            let v =
807
890
              var_get nm
808
891
            in
809
892
              assert(v = "true" || v = "false");
810
893
              (v = "true")
811
 
  
 
894
 
812
895
        | ETest (nm, vl) ->
813
896
            let v =
814
897
              var_get nm
816
899
              (v = vl)
817
900
    in
818
901
      eval' t
819
 
  
 
902
 
820
903
  let choose ?printer ?name var_get lst =
821
904
    let rec choose_aux =
822
905
      function
852
935
                         str_lst)
853
936
    in
854
937
      choose_aux (List.rev lst)
855
 
  
 
938
 
856
939
end
857
940
 
858
941
module OASISTypes = struct
859
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISTypes.ml"
860
 
  
861
 
  
862
 
  
863
 
  
 
942
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *)
 
943
 
 
944
 
 
945
 
 
946
 
864
947
  type name          = string 
865
948
  type package_name  = string 
866
949
  type url           = string 
872
955
  type arg           = string 
873
956
  type args          = string list 
874
957
  type command_line  = (prog * arg list) 
875
 
  
 
958
 
876
959
  type findlib_name = string 
877
960
  type findlib_full = string 
878
 
  
 
961
 
879
962
  type compiled_object =
880
963
    | Byte
881
964
    | Native
882
965
    | Best
883
966
    
884
 
  
 
967
 
885
968
  type dependency =
886
969
    | FindlibPackage of findlib_full * OASISVersion.comparator option
887
970
    | InternalLibrary of name
888
971
    
889
 
  
 
972
 
890
973
  type tool =
891
974
    | ExternalTool of name
892
975
    | InternalExecutable of name
893
976
    
894
 
  
 
977
 
895
978
  type vcs =
896
979
    | Darcs
897
980
    | Git
903
986
    | Monotone
904
987
    | OtherVCS of url
905
988
    
906
 
  
 
989
 
907
990
  type plugin_kind =
908
991
      [  `Configure
909
992
       | `Build
912
995
       | `Install
913
996
       | `Extra
914
997
      ]
915
 
  
 
998
 
916
999
  type plugin_data_purpose =
917
1000
      [  `Configure
918
1001
       | `Build
926
1009
       | `Extra
927
1010
       | `Other of string
928
1011
      ]
929
 
  
 
1012
 
930
1013
  type 'a plugin = 'a * name * OASISVersion.t option 
931
 
  
 
1014
 
932
1015
  type all_plugin = plugin_kind plugin
933
 
  
 
1016
 
934
1017
  type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list
935
 
  
936
 
# 102 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISTypes.ml"
937
 
  
 
1018
 
 
1019
(* # 102 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *)
 
1020
 
938
1021
  type 'a conditional = 'a OASISExpr.choices 
939
 
  
 
1022
 
940
1023
  type custom =
941
1024
      {
942
1025
        pre_command:  (command_line option) conditional;
943
1026
        post_command: (command_line option) conditional;
944
1027
      }
945
1028
      
946
 
  
 
1029
 
947
1030
  type common_section =
948
1031
      {
949
1032
        cs_name: name;
951
1034
        cs_plugin_data: plugin_data;
952
1035
      }
953
1036
      
954
 
  
 
1037
 
955
1038
  type build_section =
956
1039
      {
957
1040
        bs_build:           bool conditional;
970
1053
        bs_nativeopt:       args conditional;
971
1054
      }
972
1055
      
973
 
  
 
1056
 
974
1057
  type library =
975
1058
      {
976
1059
        lib_modules:            string list;
980
1063
        lib_findlib_name:       findlib_name option;
981
1064
        lib_findlib_containers: findlib_name list;
982
1065
      } 
983
 
  
 
1066
 
984
1067
  type executable =
985
1068
      {
986
1069
        exec_custom:          bool;
987
1070
        exec_main_is:         unix_filename;
988
1071
      } 
989
 
  
 
1072
 
990
1073
  type flag =
991
1074
      {
992
1075
        flag_description:  string option;
993
1076
        flag_default:      bool conditional;
994
1077
      } 
995
 
  
 
1078
 
996
1079
  type source_repository =
997
1080
      {
998
1081
        src_repo_type:        vcs;
1003
1086
        src_repo_tag:         string option;
1004
1087
        src_repo_subdir:      unix_filename option;
1005
1088
      } 
1006
 
  
 
1089
 
1007
1090
  type test =
1008
1091
      {
1009
1092
        test_type:               [`Test] plugin;
1013
1096
        test_run:                bool conditional;
1014
1097
        test_tools:              tool list;
1015
1098
      } 
1016
 
  
 
1099
 
1017
1100
  type doc_format =
1018
1101
    | HTML of unix_filename
1019
1102
    | DocText
1023
1106
    | DVI
1024
1107
    | OtherDoc
1025
1108
    
1026
 
  
 
1109
 
1027
1110
  type doc =
1028
1111
      {
1029
1112
        doc_type:        [`Doc] plugin;
1038
1121
        doc_data_files:  (unix_filename * unix_filename option) list;
1039
1122
        doc_build_tools: tool list;
1040
1123
      } 
1041
 
  
 
1124
 
1042
1125
  type section =
1043
1126
    | Library    of common_section * build_section * library
1044
1127
    | Executable of common_section * build_section * executable
1047
1130
    | Test       of common_section * test
1048
1131
    | Doc        of common_section * doc
1049
1132
    
1050
 
  
 
1133
 
1051
1134
  type section_kind =
1052
1135
      [ `Library | `Executable | `Flag | `SrcRepo | `Test | `Doc ]
1053
 
  
 
1136
 
1054
1137
  type package = 
1055
1138
      {
1056
1139
        oasis_version:    OASISVersion.t;
1067
1150
        synopsis:         string;
1068
1151
        description:      string option;
1069
1152
        categories:       url list;
1070
 
  
 
1153
 
1071
1154
        conf_type:        [`Configure] plugin;
1072
1155
        conf_custom:      custom;
1073
 
  
 
1156
 
1074
1157
        build_type:       [`Build] plugin;
1075
1158
        build_custom:     custom;
1076
 
  
 
1159
 
1077
1160
        install_type:     [`Install] plugin;
1078
1161
        install_custom:   custom;
1079
1162
        uninstall_custom: custom;
1080
 
  
 
1163
 
1081
1164
        clean_custom:     custom;
1082
1165
        distclean_custom: custom;
1083
 
  
 
1166
 
1084
1167
        files_ab:         unix_filename list;
1085
1168
        sections:         section list;
1086
1169
        plugins:          [`Extra] plugin list;
1087
1170
        schema_data:      PropList.Data.t;
1088
1171
        plugin_data:      plugin_data;
1089
1172
      } 
1090
 
  
 
1173
 
1091
1174
end
1092
1175
 
1093
1176
module OASISUnixPath = struct
1094
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISUnixPath.ml"
1095
 
  
 
1177
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISUnixPath.ml" *)
 
1178
 
1096
1179
  type unix_filename = string
1097
1180
  type unix_dirname = string
1098
 
  
 
1181
 
1099
1182
  type host_filename = string
1100
1183
  type host_dirname = string
1101
 
  
 
1184
 
1102
1185
  let current_dir_name = "."
1103
 
  
 
1186
 
1104
1187
  let parent_dir_name = ".."
1105
 
  
 
1188
 
 
1189
  let is_current_dir fn =
 
1190
    fn = current_dir_name || fn = ""
 
1191
 
1106
1192
  let concat f1 f2 =
1107
 
    if f1 = current_dir_name then
 
1193
    if is_current_dir f1 then
1108
1194
      f2
1109
 
    else if f2 = current_dir_name then
1110
 
      f1
1111
1195
    else
1112
 
      f1^"/"^f2
1113
 
  
 
1196
      let f1' =
 
1197
        try OASISString.strip_ends_with ~what:"/" f1 with Not_found -> f1
 
1198
      in
 
1199
        f1'^"/"^f2
 
1200
 
1114
1201
  let make =
1115
1202
    function
1116
1203
      | hd :: tl ->
1120
1207
            tl
1121
1208
      | [] ->
1122
1209
          invalid_arg "OASISUnixPath.make"
1123
 
  
 
1210
 
1124
1211
  let dirname f =
1125
1212
    try
1126
1213
      String.sub f 0 (String.rindex f '/')
1127
1214
    with Not_found ->
1128
1215
      current_dir_name
1129
 
  
 
1216
 
1130
1217
  let basename f =
1131
1218
    try
1132
1219
      let pos_start =
1135
1222
        String.sub f pos_start ((String.length f) - pos_start)
1136
1223
    with Not_found ->
1137
1224
      f
1138
 
  
 
1225
 
1139
1226
  let chop_extension f =
1140
1227
    try
1141
1228
      let last_dot =
1154
1241
              f
1155
1242
        with Not_found ->
1156
1243
          sub
1157
 
  
 
1244
 
1158
1245
    with Not_found ->
1159
1246
      f
1160
 
  
 
1247
 
1161
1248
  let capitalize_file f =
1162
1249
    let dir = dirname f in
1163
1250
    let base = basename f in
1164
1251
    concat dir (String.capitalize base)
1165
 
  
 
1252
 
1166
1253
  let uncapitalize_file f =
1167
1254
    let dir = dirname f in
1168
1255
    let base = basename f in
1169
1256
    concat dir (String.uncapitalize base)
 
1257
 
 
1258
end
 
1259
 
 
1260
module OASISHostPath = struct
 
1261
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISHostPath.ml" *)
 
1262
 
 
1263
 
 
1264
  open Filename
 
1265
 
 
1266
  module Unix = OASISUnixPath
 
1267
 
 
1268
  let make =
 
1269
    function
 
1270
      | [] ->
 
1271
          invalid_arg "OASISHostPath.make"
 
1272
      | hd :: tl ->
 
1273
          List.fold_left Filename.concat hd tl
 
1274
 
 
1275
  let of_unix ufn =
 
1276
    if Sys.os_type = "Unix" then
 
1277
      ufn
 
1278
    else
 
1279
      make
 
1280
        (List.map
 
1281
           (fun p ->
 
1282
              if p = Unix.current_dir_name then
 
1283
                current_dir_name
 
1284
              else if p = Unix.parent_dir_name then
 
1285
                parent_dir_name
 
1286
              else
 
1287
                p)
 
1288
           (OASISString.nsplit ufn '/'))
 
1289
 
 
1290
 
1170
1291
end
1171
1292
 
1172
1293
module OASISSection = struct
1173
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISSection.ml"
1174
 
  
 
1294
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISSection.ml" *)
 
1295
 
1175
1296
  open OASISTypes
1176
 
  
 
1297
 
1177
1298
  let section_kind_common = 
1178
1299
    function
1179
1300
      | Library (cs, _, _) -> 
1188
1309
          `Test, cs
1189
1310
      | Doc (cs, _) ->
1190
1311
          `Doc, cs
1191
 
  
 
1312
 
1192
1313
  let section_common sct =
1193
1314
    snd (section_kind_common sct)
1194
 
  
 
1315
 
1195
1316
  let section_common_set cs =
1196
1317
    function
1197
1318
      | Library (_, bs, lib)     -> Library (cs, bs, lib)
1200
1321
      | SrcRepo (_, src_repo)    -> SrcRepo (cs, src_repo)
1201
1322
      | Test (_, tst)            -> Test (cs, tst)
1202
1323
      | Doc (_, doc)             -> Doc (cs, doc)
1203
 
  
 
1324
 
1204
1325
  (** Key used to identify section
1205
1326
    *)
1206
1327
  let section_id sct = 
1208
1329
      section_kind_common sct
1209
1330
    in
1210
1331
      k, cs.cs_name
1211
 
  
 
1332
 
1212
1333
  let string_of_section sct =
1213
1334
    let k, nm =
1214
1335
      section_id sct
1221
1342
         | `Test       -> "test"
1222
1343
         | `Doc        -> "doc")
1223
1344
      ^" "^nm
1224
 
  
 
1345
 
 
1346
  let section_find id scts =
 
1347
    List.find
 
1348
      (fun sct -> id = section_id sct)
 
1349
      scts
 
1350
 
 
1351
  module CSection =
 
1352
  struct
 
1353
    type t = section
 
1354
 
 
1355
    let id = section_id
 
1356
 
 
1357
    let compare t1 t2 = 
 
1358
      compare (id t1) (id t2)
 
1359
      
 
1360
    let equal t1 t2 =
 
1361
      (id t1) = (id t2)
 
1362
 
 
1363
    let hash t =
 
1364
      Hashtbl.hash (id t)
 
1365
  end
 
1366
 
 
1367
  module MapSection = Map.Make(CSection)
 
1368
  module SetSection = Set.Make(CSection)
 
1369
 
1225
1370
end
1226
1371
 
1227
1372
module OASISBuildSection = struct
1228
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISBuildSection.ml"
1229
 
  
 
1373
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISBuildSection.ml" *)
 
1374
 
1230
1375
end
1231
1376
 
1232
1377
module OASISExecutable = struct
1233
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISExecutable.ml"
1234
 
  
 
1378
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISExecutable.ml" *)
 
1379
 
1235
1380
  open OASISTypes
1236
 
  
 
1381
 
1237
1382
  let unix_exec_is (cs, bs, exec) is_native ext_dll suffix_program = 
1238
1383
    let dir = 
1239
1384
      OASISUnixPath.concat
1246
1391
        | Best -> is_native ()
1247
1392
        | Byte -> false
1248
1393
    in
1249
 
  
 
1394
 
1250
1395
      OASISUnixPath.concat
1251
1396
        dir
1252
1397
        (cs.cs_name^(suffix_program ())),
1253
 
  
 
1398
 
1254
1399
      if not is_native_exec && 
1255
1400
         not exec.exec_custom && 
1256
1401
         bs.bs_c_sources <> [] then
1257
 
        Some (dir^"/dll"^cs.cs_name^(ext_dll ()))
 
1402
        Some (dir^"/dll"^cs.cs_name^"_stubs"^(ext_dll ()))
1258
1403
      else
1259
1404
        None
1260
 
  
 
1405
 
1261
1406
end
1262
1407
 
1263
1408
module OASISLibrary = struct
1264
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISLibrary.ml"
1265
 
  
 
1409
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISLibrary.ml" *)
 
1410
 
1266
1411
  open OASISTypes
1267
1412
  open OASISUtils
1268
1413
  open OASISGettext
1269
 
  
 
1414
  open OASISSection
 
1415
 
1270
1416
  type library_name = name
1271
 
  
 
1417
  type findlib_part_name = name
 
1418
  type 'a map_of_findlib_part_name = 'a OASISUtils.MapString.t
 
1419
 
 
1420
  exception InternalLibraryNotFound of library_name
 
1421
  exception FindlibPackageNotFound of findlib_name
 
1422
 
 
1423
  type group_t =
 
1424
    | Container of findlib_name * group_t list
 
1425
    | Package of (findlib_name *
 
1426
                  common_section *
 
1427
                  build_section *
 
1428
                  library *
 
1429
                  group_t list)
 
1430
 
1272
1431
  (* Look for a module file, considering capitalization or not. *)
1273
1432
  let find_module source_file_exists (cs, bs, lib) modul =
1274
1433
    let possible_base_fn =
1307
1466
                 acc)
1308
1467
        (`No_sources possible_base_fn)
1309
1468
        possible_base_fn
1310
 
  
 
1469
 
1311
1470
  let source_unix_files ~ctxt (cs, bs, lib) source_file_exists =
1312
1471
    List.fold_left
1313
1472
      (fun acc modul ->
1323
1482
               acc)
1324
1483
      []
1325
1484
      (lib.lib_modules @ lib.lib_internal_modules)
1326
 
  
1327
 
  let generated_unix_files ~ctxt (cs, bs, lib)
1328
 
        source_file_exists is_native ext_lib ext_dll =
1329
 
  
 
1485
 
 
1486
  let generated_unix_files
 
1487
        ~ctxt
 
1488
        ~is_native
 
1489
        ~has_native_dynlink
 
1490
        ~ext_lib
 
1491
        ~ext_dll
 
1492
        ~source_file_exists
 
1493
        (cs, bs, lib) =
 
1494
 
1330
1495
    let find_modules lst ext = 
1331
1496
      let find_module modul =
1332
1497
        match find_module source_file_exists (cs, bs, lib) modul with
1347
1512
             (find_module nm))
1348
1513
        lst
1349
1514
    in
1350
 
  
 
1515
 
1351
1516
    (* The headers that should be compiled along *)
1352
1517
    let headers =
1353
1518
      if lib.lib_pack then
1357
1522
          lib.lib_modules
1358
1523
          "cmi"
1359
1524
    in
1360
 
  
 
1525
 
1361
1526
    (* The .cmx that be compiled along *)
1362
1527
    let cmxs =
1363
1528
      let should_be_built =
1364
1529
        (not lib.lib_pack) && (* Do not install .cmx packed submodules *)
1365
1530
        match bs.bs_compiled_object with
1366
1531
          | Native -> true
1367
 
          | Best -> is_native ()
 
1532
          | Best -> is_native
1368
1533
          | Byte -> false
1369
1534
      in
1370
1535
        if should_be_built then
1374
1539
        else
1375
1540
          []
1376
1541
    in
1377
 
  
 
1542
 
1378
1543
    let acc_nopath =
1379
1544
      []
1380
1545
    in
1381
 
  
 
1546
 
1382
1547
    (* Compute what libraries should be built *)
1383
1548
    let acc_nopath =
1384
1549
      (* Add the packed header file if required *)
1392
1557
        add_pack_header ([cs.cs_name^".cma"] :: acc)
1393
1558
      in
1394
1559
      let native acc =
1395
 
        add_pack_header ([cs.cs_name^".cmxa"] :: [cs.cs_name^(ext_lib ())] :: acc)
 
1560
        let acc = 
 
1561
          add_pack_header
 
1562
            (if has_native_dynlink then
 
1563
               [cs.cs_name^".cmxs"] :: acc
 
1564
             else acc)
 
1565
        in
 
1566
          [cs.cs_name^".cmxa"] :: [cs.cs_name^ext_lib] :: acc
1396
1567
      in
1397
1568
        match bs.bs_compiled_object with
1398
1569
          | Native ->
1399
1570
              byte (native acc_nopath)
1400
 
          | Best when is_native () ->
 
1571
          | Best when is_native ->
1401
1572
              byte (native acc_nopath)
1402
1573
          | Byte | Best ->
1403
1574
              byte acc_nopath
1404
1575
    in
1405
 
  
 
1576
 
1406
1577
    (* Add C library to be built *)
1407
1578
    let acc_nopath =
1408
1579
      if bs.bs_c_sources <> [] then
1409
1580
        begin
1410
 
          ["lib"^cs.cs_name^(ext_lib ())]
 
1581
          ["lib"^cs.cs_name^"_stubs"^ext_lib]
1411
1582
          ::
1412
 
          ["dll"^cs.cs_name^(ext_dll ())]
 
1583
          ["dll"^cs.cs_name^"_stubs"^ext_dll]
1413
1584
          ::
1414
1585
          acc_nopath
1415
1586
        end
1416
1587
      else
1417
1588
        acc_nopath
1418
1589
    in
1419
 
  
 
1590
 
1420
1591
      (* All the files generated *)
1421
1592
      List.rev_append
1422
1593
        (List.rev_map
1424
1595
              (OASISUnixPath.concat bs.bs_path))
1425
1596
           acc_nopath)
1426
1597
        (headers @ cmxs)
1427
 
  
1428
 
  
1429
 
  type group_t =
1430
 
    | Container of findlib_name * (group_t list)
1431
 
    | Package of (findlib_name *
1432
 
                  common_section *
1433
 
                  build_section *
1434
 
                  library *
1435
 
                  (group_t list))
1436
 
  
1437
 
  let group_libs pkg =
1438
 
    (** Associate a name with its children *)
1439
 
    let children =
 
1598
 
 
1599
  type data = common_section * build_section * library
 
1600
  type tree =
 
1601
    | Node of (data option) * (tree MapString.t)
 
1602
    | Leaf of data
 
1603
 
 
1604
  let findlib_mapping pkg =
 
1605
    (* Map from library name to either full findlib name or parts + parent. *)
 
1606
    let fndlb_parts_of_lib_name =
 
1607
      let fndlb_parts cs lib =
 
1608
        let name =
 
1609
          match lib.lib_findlib_name with
 
1610
            | Some nm -> nm
 
1611
            | None -> cs.cs_name
 
1612
        in
 
1613
        let name =
 
1614
          String.concat "." (lib.lib_findlib_containers @ [name])
 
1615
        in
 
1616
          name
 
1617
      in
 
1618
        List.fold_left
 
1619
          (fun mp ->
 
1620
             function
 
1621
               | Library (cs, _, lib) ->
 
1622
                   begin
 
1623
                     let lib_name = cs.cs_name in
 
1624
                     let fndlb_parts = fndlb_parts cs lib in
 
1625
                       if MapString.mem lib_name mp then
 
1626
                         failwithf
 
1627
                           (f_ "The library name '%s' is used more than once.")
 
1628
                           lib_name;
 
1629
                       match lib.lib_findlib_parent with
 
1630
                         | Some lib_name_parent ->
 
1631
                             MapString.add
 
1632
                               lib_name
 
1633
                               (`Unsolved (lib_name_parent, fndlb_parts))
 
1634
                               mp
 
1635
                         | None ->
 
1636
                             MapString.add
 
1637
                               lib_name
 
1638
                               (`Solved fndlb_parts)
 
1639
                               mp
 
1640
                   end
 
1641
 
 
1642
               | Executable _ | Test _ | Flag _ | SrcRepo _ | Doc _ ->
 
1643
                   mp)
 
1644
          MapString.empty
 
1645
          pkg.sections
 
1646
    in
 
1647
 
 
1648
    (* Solve the above graph to be only library name to full findlib name. *)
 
1649
    let fndlb_name_of_lib_name =
 
1650
      let rec solve visited mp lib_name lib_name_child =
 
1651
        if SetString.mem lib_name visited then
 
1652
          failwithf
 
1653
            (f_ "Library '%s' is involved in a cycle \
 
1654
                 with regard to findlib naming.")
 
1655
            lib_name;
 
1656
        let visited = SetString.add lib_name visited in
 
1657
          try
 
1658
            match MapString.find lib_name mp with
 
1659
              | `Solved fndlb_nm ->
 
1660
                  fndlb_nm, mp
 
1661
              | `Unsolved (lib_nm_parent, post_fndlb_nm) ->
 
1662
                  let pre_fndlb_nm, mp =
 
1663
                    solve visited mp lib_nm_parent lib_name
 
1664
                  in
 
1665
                  let fndlb_nm = pre_fndlb_nm^"."^post_fndlb_nm in
 
1666
                    fndlb_nm, MapString.add lib_name (`Solved fndlb_nm) mp
 
1667
          with Not_found ->
 
1668
            failwithf
 
1669
              (f_ "Library '%s', which is defined as the findlib parent of \
 
1670
                   library '%s', doesn't exist.")
 
1671
              lib_name lib_name_child
 
1672
      in
 
1673
      let mp =
 
1674
        MapString.fold
 
1675
          (fun lib_name status mp ->
 
1676
             match status with
 
1677
               | `Solved _ ->
 
1678
                   (* Solved initialy, no need to go further *)
 
1679
                   mp
 
1680
               | `Unsolved _ ->
 
1681
                   let _, mp = solve SetString.empty mp lib_name "<none>" in
 
1682
                     mp)
 
1683
          fndlb_parts_of_lib_name
 
1684
          fndlb_parts_of_lib_name
 
1685
      in
 
1686
        MapString.map
 
1687
          (function
 
1688
             | `Solved fndlb_nm -> fndlb_nm
 
1689
             | `Unsolved _ -> assert false)
 
1690
          mp
 
1691
    in
 
1692
 
 
1693
    (* Convert an internal library name to a findlib name. *)
 
1694
    let findlib_name_of_library_name lib_nm =
 
1695
      try
 
1696
        MapString.find lib_nm fndlb_name_of_lib_name
 
1697
      with Not_found ->
 
1698
        raise (InternalLibraryNotFound lib_nm)
 
1699
    in
 
1700
 
 
1701
    (* Add a library to the tree.
 
1702
     *)
 
1703
    let add sct mp =
 
1704
      let fndlb_fullname =
 
1705
        let cs, _, _ = sct in
 
1706
        let lib_name = cs.cs_name in
 
1707
          findlib_name_of_library_name lib_name
 
1708
      in
 
1709
      let rec add_children nm_lst (children : tree MapString.t) =
 
1710
        match nm_lst with
 
1711
          | (hd :: tl) ->
 
1712
              begin
 
1713
                let node =
 
1714
                  try
 
1715
                    add_node tl (MapString.find hd children)
 
1716
                  with Not_found ->
 
1717
                    (* New node *)
 
1718
                    new_node tl
 
1719
                in
 
1720
                  MapString.add hd node children
 
1721
              end
 
1722
          | [] ->
 
1723
              (* Should not have a nameless library. *)
 
1724
              assert false
 
1725
      and add_node tl node =
 
1726
        if tl = [] then
 
1727
          begin
 
1728
            match node with
 
1729
              | Node (None, children) ->
 
1730
                  Node (Some sct, children)
 
1731
              | Leaf (cs', _, _) | Node (Some (cs', _, _), _) ->
 
1732
                  (* TODO: allow to merge Package, i.e.
 
1733
                   * archive(byte) = "foo.cma foo_init.cmo"
 
1734
                   *)
 
1735
                  let cs, _, _ = sct in
 
1736
                    failwithf
 
1737
                      (f_ "Library '%s' and '%s' have the same findlib name '%s'")
 
1738
                      cs.cs_name cs'.cs_name fndlb_fullname
 
1739
          end
 
1740
        else
 
1741
          begin
 
1742
            match node with
 
1743
              | Leaf data ->
 
1744
                  Node (Some data, add_children tl MapString.empty)
 
1745
              | Node (data_opt, children) ->
 
1746
                  Node (data_opt, add_children tl children)
 
1747
          end
 
1748
      and new_node =
 
1749
        function
 
1750
          | [] ->
 
1751
              Leaf sct
 
1752
          | hd :: tl ->
 
1753
              Node (None, MapString.add hd (new_node tl) MapString.empty)
 
1754
      in
 
1755
        add_children (OASISString.nsplit fndlb_fullname '.') mp
 
1756
    in
 
1757
 
 
1758
    let rec group_of_tree mp =
 
1759
      MapString.fold
 
1760
        (fun nm node acc ->
 
1761
           let cur =
 
1762
             match node with
 
1763
               | Node (Some (cs, bs, lib), children) ->
 
1764
                   Package (nm, cs, bs, lib, group_of_tree children)
 
1765
               | Node (None, children) ->
 
1766
                   Container (nm, group_of_tree children)
 
1767
               | Leaf (cs, bs, lib) ->
 
1768
                   Package (nm, cs, bs, lib, [])
 
1769
           in
 
1770
             cur :: acc)
 
1771
        mp []
 
1772
    in
 
1773
 
 
1774
    let group_mp =
1440
1775
      List.fold_left
1441
1776
        (fun mp ->
1442
1777
           function
1443
1778
             | Library (cs, bs, lib) ->
1444
 
                 begin
1445
 
                   match lib.lib_findlib_parent with
1446
 
                     | Some p_nm ->
1447
 
                         begin
1448
 
                           let children =
1449
 
                             try
1450
 
                               MapString.find p_nm mp
1451
 
                             with Not_found ->
1452
 
                               []
1453
 
                           in
1454
 
                             MapString.add p_nm ((cs, bs, lib) :: children) mp
1455
 
                         end
1456
 
                     | None ->
1457
 
                         mp
1458
 
                 end
 
1779
                 add (cs, bs, lib) mp
1459
1780
             | _ ->
1460
1781
                 mp)
1461
1782
        MapString.empty
1462
1783
        pkg.sections
1463
1784
    in
1464
 
  
1465
 
    (* Compute findlib name of a single node *)
1466
 
    let findlib_name (cs, _, lib) =
1467
 
      match lib.lib_findlib_name with
1468
 
        | Some nm -> nm
1469
 
        | None -> cs.cs_name
1470
 
    in
1471
 
  
1472
 
    (** Build a package tree *)
1473
 
    let rec tree_of_library containers ((cs, bs, lib) as acc) =
1474
 
      match containers with
1475
 
        | hd :: tl ->
1476
 
            Container (hd, [tree_of_library tl acc])
1477
 
        | [] ->
1478
 
            Package 
1479
 
              (findlib_name acc, cs, bs, lib,
1480
 
               (try
1481
 
                  List.rev_map
1482
 
                    (fun ((_, _, child_lib) as child_acc) ->
1483
 
                       tree_of_library
1484
 
                         child_lib.lib_findlib_containers
1485
 
                         child_acc)
1486
 
                    (MapString.find cs.cs_name children)
1487
 
                with Not_found ->
1488
 
                  []))
1489
 
    in
1490
 
  
1491
 
    (** Merge containers with the same name *)
1492
 
    let rec merge_containers groups =
1493
 
      (* Collect packages and create the map "container name -> merged children" *)
1494
 
      let packages, containers =
1495
 
        List.fold_left
1496
 
          (fun (packages, containers) group ->
1497
 
             match group with
1498
 
               | Container(name, children) ->
1499
 
                   let children' =
1500
 
                     try
1501
 
                       MapString.find name containers
1502
 
                     with Not_found ->
1503
 
                       []
1504
 
                   in
1505
 
                   (packages,
1506
 
                    MapString.add name (children' @ children) containers)
1507
 
               | Package(name, cs, bs, lib, children) ->
1508
 
                   (Package(name, cs, bs, lib, merge_containers children) :: packages,
1509
 
                    containers))
1510
 
          ([], MapString.empty)
1511
 
          groups
1512
 
      in
1513
 
      (* Recreate the list of groups *)
1514
 
      packages @
1515
 
        (MapString.fold
1516
 
           (fun name children acc ->
1517
 
              Container(name, merge_containers children) :: acc)
1518
 
           containers [])
1519
 
    in
1520
 
  
1521
 
      (* TODO: check that libraries are unique *)
1522
 
      merge_containers
1523
 
        (List.fold_left
1524
 
           (fun acc ->
1525
 
              function
1526
 
                | Library (cs, bs, lib) when lib.lib_findlib_parent = None -> 
1527
 
                    (tree_of_library lib.lib_findlib_containers (cs, bs, lib)) :: acc
1528
 
                | _ ->
1529
 
                    acc)
1530
 
           []
1531
 
           pkg.sections)
1532
 
  
1533
 
  (** Compute internal to findlib library matchings, including subpackage
1534
 
      and return a map of it.
1535
 
    *)
1536
 
  let findlib_name_map pkg =
1537
 
  
1538
 
    (* Compute names in a tree *)
1539
 
    let rec findlib_names_aux path mp grp =
1540
 
      let fndlb_nm, children, mp =
1541
 
        match grp with
1542
 
          | Container (fndlb_nm, children) ->
1543
 
              fndlb_nm, children, mp
1544
 
  
1545
 
          | Package (fndlb_nm, {cs_name = nm}, _, _, children) ->
1546
 
              fndlb_nm, children, (MapString.add nm (path, fndlb_nm) mp)
1547
 
      in
1548
 
      let fndlb_nm_full =
1549
 
        (match path with
1550
 
           | Some pth -> pth^"."
1551
 
           | None -> "")^
1552
 
        fndlb_nm
1553
 
      in
1554
 
        List.fold_left
1555
 
          (findlib_names_aux (Some fndlb_nm_full))
1556
 
          mp
1557
 
          children
1558
 
    in
1559
 
  
1560
 
      List.fold_left
1561
 
        (findlib_names_aux None)
1562
 
        MapString.empty
1563
 
        (group_libs pkg)
1564
 
  
1565
 
  
1566
 
  let findlib_of_name ?(recurse=false) map nm =
1567
 
    try
1568
 
      let (path, fndlb_nm) =
1569
 
        MapString.find nm map
1570
 
      in
1571
 
        match path with
1572
 
          | Some pth when recurse -> pth^"."^fndlb_nm
1573
 
          | _ -> fndlb_nm
1574
 
  
1575
 
    with Not_found ->
1576
 
      failwithf
1577
 
        (f_ "Unable to translate internal library '%s' to findlib name")
1578
 
        nm
1579
 
  
1580
 
  let name_findlib_map pkg =
1581
 
    let mp =
1582
 
      findlib_name_map pkg
1583
 
    in
1584
 
      MapString.fold
1585
 
        (fun nm _ acc ->
1586
 
           let fndlb_nm_full =
1587
 
             findlib_of_name
1588
 
               ~recurse:true
1589
 
               mp
1590
 
               nm
1591
 
           in
1592
 
             MapString.add fndlb_nm_full nm acc)
1593
 
        mp
1594
 
        MapString.empty
1595
 
  
 
1785
 
 
1786
    let groups =
 
1787
      group_of_tree group_mp
 
1788
    in
 
1789
 
 
1790
    let library_name_of_findlib_name =
 
1791
      Lazy.lazy_from_fun
 
1792
        (fun () ->
 
1793
           (* Revert findlib_name_of_library_name. *)
 
1794
           MapString.fold
 
1795
             (fun k v mp -> MapString.add v k mp)
 
1796
             fndlb_name_of_lib_name
 
1797
             MapString.empty)
 
1798
    in
 
1799
    let library_name_of_findlib_name fndlb_nm =
 
1800
      try
 
1801
        MapString.find fndlb_nm (Lazy.force library_name_of_findlib_name)
 
1802
      with Not_found ->
 
1803
        raise (FindlibPackageNotFound fndlb_nm)
 
1804
    in
 
1805
 
 
1806
      groups,
 
1807
      findlib_name_of_library_name,
 
1808
      library_name_of_findlib_name
 
1809
 
1596
1810
  let findlib_of_group =
1597
1811
    function
1598
1812
      | Container (fndlb_nm, _)
1599
1813
      | Package (fndlb_nm, _, _, _, _) -> fndlb_nm
1600
 
  
 
1814
 
1601
1815
  let root_of_group grp =
1602
1816
    let rec root_lib_aux =
 
1817
      (* We do a DFS in the group. *)
1603
1818
      function
1604
1819
        | Container (_, children) ->
1605
 
            root_lib_lst children
1606
 
        | Package (_, cs, bs, lib, children) ->
1607
 
            if lib.lib_findlib_parent = None then
1608
 
              cs, bs, lib
1609
 
            else
1610
 
              root_lib_lst children
1611
 
    and root_lib_lst =
1612
 
      function
1613
 
        | [] ->
1614
 
            raise Not_found
1615
 
        | hd :: tl ->
1616
 
            try
1617
 
              root_lib_aux hd
1618
 
            with Not_found ->
1619
 
              root_lib_lst tl
 
1820
            List.fold_left
 
1821
              (fun res grp ->
 
1822
                 if res = None then
 
1823
                   root_lib_aux grp
 
1824
                 else
 
1825
                   res)
 
1826
              None
 
1827
              children
 
1828
        | Package (_, cs, bs, lib, _) ->
 
1829
            Some (cs, bs, lib)
1620
1830
    in
1621
 
      try
1622
 
        root_lib_aux grp
1623
 
      with Not_found ->
1624
 
        failwithf
1625
 
          (f_ "Unable to determine root library of findlib library '%s'")
1626
 
          (findlib_of_group grp)
1627
 
  
1628
 
  
 
1831
      match root_lib_aux grp with
 
1832
        | Some res ->
 
1833
            res
 
1834
        | None ->
 
1835
            failwithf
 
1836
              (f_ "Unable to determine root library of findlib library '%s'")
 
1837
              (findlib_of_group grp)
 
1838
 
1629
1839
end
1630
1840
 
1631
1841
module OASISFlag = struct
1632
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISFlag.ml"
1633
 
  
 
1842
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISFlag.ml" *)
 
1843
 
1634
1844
end
1635
1845
 
1636
1846
module OASISPackage = struct
1637
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISPackage.ml"
1638
 
  
 
1847
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISPackage.ml" *)
 
1848
 
1639
1849
end
1640
1850
 
1641
1851
module OASISSourceRepository = struct
1642
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISSourceRepository.ml"
1643
 
  
 
1852
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISSourceRepository.ml" *)
 
1853
 
1644
1854
end
1645
1855
 
1646
1856
module OASISTest = struct
1647
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISTest.ml"
1648
 
  
 
1857
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISTest.ml" *)
 
1858
 
1649
1859
end
1650
1860
 
1651
1861
module OASISDocument = struct
1652
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/oasis/OASISDocument.ml"
1653
 
  
1654
 
end
1655
 
 
1656
 
 
 
1862
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISDocument.ml" *)
 
1863
 
 
1864
end
 
1865
 
 
1866
module OASISExec = struct
 
1867
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISExec.ml" *)
 
1868
 
 
1869
  open OASISGettext
 
1870
  open OASISUtils
 
1871
  open OASISMessage
 
1872
 
 
1873
  (* TODO: I don't like this quote, it is there because $(rm) foo expands to
 
1874
   * 'rm -f' foo...
 
1875
   *)
 
1876
  let run ~ctxt ?f_exit_code ?(quote=true) cmd args =
 
1877
    let cmd =
 
1878
      if quote then
 
1879
        if Sys.os_type = "Win32" then
 
1880
          if String.contains cmd ' ' then
 
1881
            (* Double the 1st double quote... win32... sigh *)
 
1882
            "\""^(Filename.quote cmd)
 
1883
          else
 
1884
            cmd
 
1885
        else
 
1886
          Filename.quote cmd
 
1887
      else
 
1888
        cmd
 
1889
    in
 
1890
    let cmdline =
 
1891
      String.concat " " (cmd :: args)
 
1892
    in
 
1893
      info ~ctxt (f_ "Running command '%s'") cmdline;
 
1894
      match f_exit_code, Sys.command cmdline with
 
1895
        | None, 0 -> ()
 
1896
        | None, i ->
 
1897
            failwithf
 
1898
              (f_ "Command '%s' terminated with error code %d")
 
1899
              cmdline i
 
1900
        | Some f, i ->
 
1901
            f i
 
1902
 
 
1903
  let run_read_output ~ctxt ?f_exit_code cmd args =
 
1904
    let fn =
 
1905
      Filename.temp_file "oasis-" ".txt"
 
1906
    in
 
1907
      try
 
1908
        begin
 
1909
          let () =
 
1910
            run ~ctxt ?f_exit_code cmd (args @ [">"; Filename.quote fn])
 
1911
          in
 
1912
          let chn =
 
1913
            open_in fn
 
1914
          in
 
1915
          let routput =
 
1916
            ref []
 
1917
          in
 
1918
            begin
 
1919
              try
 
1920
                while true do
 
1921
                  routput := (input_line chn) :: !routput
 
1922
                done
 
1923
              with End_of_file ->
 
1924
                ()
 
1925
            end;
 
1926
            close_in chn;
 
1927
            Sys.remove fn;
 
1928
            List.rev !routput
 
1929
        end
 
1930
      with e ->
 
1931
        (try Sys.remove fn with _ -> ());
 
1932
        raise e
 
1933
 
 
1934
  let run_read_one_line ~ctxt ?f_exit_code cmd args =
 
1935
    match run_read_output ~ctxt ?f_exit_code cmd args with
 
1936
      | [fst] ->
 
1937
          fst
 
1938
      | lst ->
 
1939
          failwithf
 
1940
            (f_ "Command return unexpected output %S")
 
1941
            (String.concat "\n" lst)
 
1942
end
 
1943
 
 
1944
module OASISFileUtil = struct
 
1945
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/oasis/OASISFileUtil.ml" *)
 
1946
 
 
1947
  open OASISGettext
 
1948
 
 
1949
  let file_exists_case fn =
 
1950
    let dirname = Filename.dirname fn in
 
1951
    let basename = Filename.basename fn in
 
1952
      if Sys.file_exists dirname then
 
1953
        if basename = Filename.current_dir_name then
 
1954
          true
 
1955
        else
 
1956
          List.mem
 
1957
            basename
 
1958
            (Array.to_list (Sys.readdir dirname))
 
1959
      else
 
1960
        false
 
1961
 
 
1962
  let find_file ?(case_sensitive=true) paths exts =
 
1963
 
 
1964
    (* Cardinal product of two list *)
 
1965
    let ( * ) lst1 lst2 =
 
1966
      List.flatten
 
1967
        (List.map
 
1968
           (fun a ->
 
1969
              List.map
 
1970
                (fun b -> a,b)
 
1971
                lst2)
 
1972
           lst1)
 
1973
    in
 
1974
 
 
1975
    let rec combined_paths lst =
 
1976
      match lst with
 
1977
        | p1 :: p2 :: tl ->
 
1978
            let acc =
 
1979
              (List.map
 
1980
                 (fun (a,b) -> Filename.concat a b)
 
1981
                 (p1 * p2))
 
1982
            in
 
1983
              combined_paths (acc :: tl)
 
1984
        | [e] ->
 
1985
            e
 
1986
        | [] ->
 
1987
            []
 
1988
    in
 
1989
 
 
1990
    let alternatives =
 
1991
      List.map
 
1992
        (fun (p,e) ->
 
1993
           if String.length e > 0 && e.[0] <> '.' then
 
1994
             p ^ "." ^ e
 
1995
           else
 
1996
             p ^ e)
 
1997
        ((combined_paths paths) * exts)
 
1998
    in
 
1999
      List.find
 
2000
        (if case_sensitive then
 
2001
           file_exists_case
 
2002
         else
 
2003
           Sys.file_exists)
 
2004
        alternatives
 
2005
 
 
2006
  let which ~ctxt prg =
 
2007
    let path_sep =
 
2008
      match Sys.os_type with
 
2009
        | "Win32" ->
 
2010
            ';'
 
2011
        | _ ->
 
2012
            ':'
 
2013
    in
 
2014
    let path_lst = OASISString.nsplit (Sys.getenv "PATH") path_sep in
 
2015
    let exec_ext =
 
2016
      match Sys.os_type with
 
2017
        | "Win32" ->
 
2018
            "" :: (OASISString.nsplit (Sys.getenv "PATHEXT") path_sep)
 
2019
        | _ ->
 
2020
            [""]
 
2021
    in
 
2022
      find_file ~case_sensitive:false [path_lst; [prg]] exec_ext
 
2023
 
 
2024
  (**/**)
 
2025
  let rec fix_dir dn =
 
2026
    (* Windows hack because Sys.file_exists "src\\" = false when
 
2027
     * Sys.file_exists "src" = true
 
2028
     *)
 
2029
    let ln =
 
2030
      String.length dn
 
2031
    in
 
2032
      if Sys.os_type = "Win32" && ln > 0 && dn.[ln - 1] = '\\' then
 
2033
        fix_dir (String.sub dn 0 (ln - 1))
 
2034
      else
 
2035
        dn
 
2036
 
 
2037
  let q = Filename.quote
 
2038
  (**/**)
 
2039
 
 
2040
  let cp ~ctxt ?(recurse=false) src tgt =
 
2041
    if recurse then
 
2042
      match Sys.os_type with
 
2043
        | "Win32" ->
 
2044
            OASISExec.run ~ctxt
 
2045
              "xcopy" [q src; q tgt; "/E"]
 
2046
        | _ ->
 
2047
            OASISExec.run ~ctxt
 
2048
              "cp" ["-r"; q src; q tgt]
 
2049
    else
 
2050
      OASISExec.run ~ctxt
 
2051
        (match Sys.os_type with
 
2052
         | "Win32" -> "copy"
 
2053
         | _ -> "cp")
 
2054
        [q src; q tgt]
 
2055
 
 
2056
  let mkdir ~ctxt tgt =
 
2057
    OASISExec.run ~ctxt
 
2058
      (match Sys.os_type with
 
2059
         | "Win32" -> "md"
 
2060
         | _ -> "mkdir")
 
2061
      [q tgt]
 
2062
 
 
2063
  let rec mkdir_parent ~ctxt f tgt =
 
2064
    let tgt =
 
2065
      fix_dir tgt
 
2066
    in
 
2067
      if Sys.file_exists tgt then
 
2068
        begin
 
2069
          if not (Sys.is_directory tgt) then
 
2070
            OASISUtils.failwithf
 
2071
              (f_ "Cannot create directory '%s', a file of the same name already \
 
2072
                   exists")
 
2073
              tgt
 
2074
        end
 
2075
      else
 
2076
        begin
 
2077
          mkdir_parent ~ctxt f (Filename.dirname tgt);
 
2078
          if not (Sys.file_exists tgt) then
 
2079
            begin
 
2080
              f tgt;
 
2081
              mkdir ~ctxt tgt
 
2082
            end
 
2083
        end
 
2084
 
 
2085
  let rmdir ~ctxt tgt =
 
2086
    if Sys.readdir tgt = [||] then
 
2087
      begin
 
2088
        match Sys.os_type with
 
2089
          | "Win32" ->
 
2090
              OASISExec.run ~ctxt "rd" [q tgt]
 
2091
          | _ ->
 
2092
              OASISExec.run ~ctxt "rm" ["-r"; q tgt]
 
2093
      end
 
2094
 
 
2095
  let glob ~ctxt fn =
 
2096
   let basename =
 
2097
     Filename.basename fn
 
2098
   in
 
2099
     if String.length basename >= 2 &&
 
2100
        basename.[0] = '*' &&
 
2101
        basename.[1] = '.' then
 
2102
       begin
 
2103
         let ext_len =
 
2104
           (String.length basename) - 2
 
2105
         in
 
2106
         let ext =
 
2107
           String.sub basename 2 ext_len
 
2108
         in
 
2109
         let dirname =
 
2110
           Filename.dirname fn
 
2111
         in
 
2112
           Array.fold_left
 
2113
             (fun acc fn ->
 
2114
                try
 
2115
                  let fn_ext =
 
2116
                    String.sub
 
2117
                      fn
 
2118
                      ((String.length fn) - ext_len)
 
2119
                      ext_len
 
2120
                  in
 
2121
                    if fn_ext = ext then
 
2122
                      (Filename.concat dirname fn) :: acc
 
2123
                    else
 
2124
                      acc
 
2125
                with Invalid_argument _ ->
 
2126
                  acc)
 
2127
             []
 
2128
             (Sys.readdir dirname)
 
2129
       end
 
2130
     else
 
2131
       begin
 
2132
         if file_exists_case fn then
 
2133
           [fn]
 
2134
         else
 
2135
           []
 
2136
       end
 
2137
end
 
2138
 
 
2139
 
 
2140
# 2142 "setup.ml"
1657
2141
module BaseEnvLight = struct
1658
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseEnvLight.ml"
1659
 
  
 
2142
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseEnvLight.ml" *)
 
2143
 
1660
2144
  module MapString = Map.Make(String)
1661
 
  
 
2145
 
1662
2146
  type t = string MapString.t
1663
 
  
 
2147
 
1664
2148
  let default_filename =
1665
2149
    Filename.concat
1666
2150
      (Sys.getcwd ())
1667
2151
      "setup.data"
1668
 
  
 
2152
 
1669
2153
  let load ?(allow_empty=false) ?(filename=default_filename) () =
1670
2154
    if Sys.file_exists filename then
1671
2155
      begin
1722
2206
             "Unable to load environment, the file '%s' doesn't exist."
1723
2207
             filename)
1724
2208
      end
1725
 
  
 
2209
 
1726
2210
  let var_get name env =
1727
2211
    let rec var_expand str =
1728
2212
      let buff =
1743
2227
        Buffer.contents buff
1744
2228
    in
1745
2229
      var_expand (MapString.find name env)
1746
 
  
 
2230
 
1747
2231
  let var_choose lst env =
1748
2232
    OASISExpr.choose
1749
2233
      (fun nm -> var_get nm env)
1751
2235
end
1752
2236
 
1753
2237
 
 
2238
# 2240 "setup.ml"
1754
2239
module BaseContext = struct
1755
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseContext.ml"
1756
 
  
 
2240
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseContext.ml" *)
 
2241
 
1757
2242
  open OASISContext
1758
 
  
 
2243
 
1759
2244
  let args = args
1760
 
  
 
2245
 
1761
2246
  let default = default
1762
 
  
 
2247
 
1763
2248
end
1764
2249
 
1765
2250
module BaseMessage = struct
1766
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseMessage.ml"
1767
 
  
 
2251
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseMessage.ml" *)
 
2252
 
1768
2253
  (** Message to user, overrid for Base
1769
2254
      @author Sylvain Le Gall
1770
2255
    *)
1771
2256
  open OASISMessage
1772
2257
  open BaseContext
1773
 
  
 
2258
 
1774
2259
  let debug fmt   = debug ~ctxt:!default fmt
1775
 
  
 
2260
 
1776
2261
  let info fmt    = info ~ctxt:!default fmt
1777
 
  
 
2262
 
1778
2263
  let warning fmt = warning ~ctxt:!default fmt
1779
 
  
 
2264
 
1780
2265
  let error fmt = error ~ctxt:!default fmt
1781
 
  
1782
 
end
1783
2266
 
1784
 
module BaseFilePath = struct
1785
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseFilePath.ml"
1786
 
  
1787
 
  
1788
 
  open Filename
1789
 
  
1790
 
  module Unix = OASISUnixPath
1791
 
  
1792
 
  let make =
1793
 
    function
1794
 
      | [] ->
1795
 
          invalid_arg "BaseFilename.make"
1796
 
      | hd :: tl ->
1797
 
          List.fold_left Filename.concat hd tl
1798
 
  
1799
 
  let of_unix ufn =
1800
 
    if Sys.os_type = "Unix" then
1801
 
      ufn
1802
 
    else
1803
 
      make
1804
 
        (List.map
1805
 
           (fun p ->
1806
 
              if p = Unix.current_dir_name then
1807
 
                current_dir_name
1808
 
              else if p = Unix.parent_dir_name then
1809
 
                parent_dir_name
1810
 
              else
1811
 
                p)
1812
 
           (OASISUtils.split '/' ufn))
1813
 
  
1814
2267
end
1815
2268
 
1816
2269
module BaseEnv = struct
1817
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseEnv.ml"
1818
 
  
 
2270
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseEnv.ml" *)
 
2271
 
1819
2272
  open OASISGettext
1820
2273
  open OASISUtils
1821
2274
  open PropList
1822
 
  
 
2275
 
1823
2276
  module MapString = BaseEnvLight.MapString
1824
 
  
 
2277
 
1825
2278
  type origin_t =
1826
2279
    | ODefault
1827
2280
    | OGetEnv
1828
2281
    | OFileLoad
1829
2282
    | OCommandLine
1830
 
  
 
2283
 
1831
2284
  type cli_handle_t =
1832
2285
    | CLINone
1833
2286
    | CLIAuto
1834
2287
    | CLIWith
1835
2288
    | CLIEnable
1836
2289
    | CLIUser of (Arg.key * Arg.spec * Arg.doc) list
1837
 
  
 
2290
 
1838
2291
  type definition_t =
1839
2292
      {
1840
2293
        hide:       bool;
1843
2296
        arg_help:   string option;
1844
2297
        group:      string option;
1845
2298
      }
1846
 
  
 
2299
 
1847
2300
  let schema =
1848
2301
    Schema.create "environment"
1849
 
  
 
2302
 
1850
2303
  (* Environment data *)
1851
2304
  let env =
1852
2305
    Data.create ()
1853
 
  
 
2306
 
1854
2307
  (* Environment data from file *)
1855
2308
  let env_from_file =
1856
2309
    ref MapString.empty
1857
 
  
 
2310
 
1858
2311
  (* Lexer for var *)
1859
2312
  let var_lxr =
1860
2313
    Genlex.make_lexer []
1861
 
  
 
2314
 
1862
2315
  let rec var_expand str =
1863
2316
    let buff =
1864
2317
      Buffer.create ((String.length str) * 2)
1879
2332
             in
1880
2333
               match Stream.npeek 3 st with
1881
2334
                 | [Genlex.Ident "utoh"; Genlex.Ident nm] ->
1882
 
                     BaseFilePath.of_unix (var_get nm)
 
2335
                     OASISHostPath.of_unix (var_get nm)
1883
2336
                 | [Genlex.Ident "utoh"; Genlex.String s] ->
1884
 
                     BaseFilePath.of_unix s
 
2337
                     OASISHostPath.of_unix s
1885
2338
                 | [Genlex.Ident "ocaml_escaped"; Genlex.Ident nm] ->
1886
2339
                     String.escaped (var_get nm)
1887
2340
                 | [Genlex.Ident "ocaml_escaped"; Genlex.String s] ->
1908
2361
                   e)
1909
2362
        str;
1910
2363
      Buffer.contents buff
1911
 
  
 
2364
 
1912
2365
  and var_get name =
1913
2366
    let vl =
1914
2367
      try
1922
2375
        end
1923
2376
    in
1924
2377
      var_expand vl
1925
 
  
 
2378
 
1926
2379
  let var_choose ?printer ?name lst =
1927
2380
    OASISExpr.choose
1928
2381
      ?printer
1929
2382
      ?name
1930
2383
      var_get
1931
2384
      lst
1932
 
  
 
2385
 
1933
2386
  let var_protect vl =
1934
2387
    let buff =
1935
2388
      Buffer.create (String.length vl)
1940
2393
           | c   -> Buffer.add_char   buff c)
1941
2394
        vl;
1942
2395
      Buffer.contents buff
1943
 
  
 
2396
 
1944
2397
  let var_define
1945
2398
        ?(hide=false)
1946
2399
        ?(dump=true)
1951
2404
        name (* TODO: type constraint on the fact that name must be a valid OCaml
1952
2405
                  id *)
1953
2406
        dflt =
1954
 
  
 
2407
 
1955
2408
    let default =
1956
2409
      [
1957
2410
        OFileLoad, (fun () -> MapString.find name !env_from_file);
1959
2412
        OGetEnv,   (fun () -> Sys.getenv name);
1960
2413
      ]
1961
2414
    in
1962
 
  
 
2415
 
1963
2416
    let extra =
1964
2417
      {
1965
2418
        hide     = hide;
1969
2422
        group    = group;
1970
2423
      }
1971
2424
    in
1972
 
  
 
2425
 
1973
2426
    (* Try to find a value that can be defined
1974
2427
     *)
1975
2428
    let var_get_low lst =
2004
2457
          | None, lst ->
2005
2458
              raise (Not_set (name, Some (String.concat (s_ ", ") lst)))
2006
2459
    in
2007
 
  
 
2460
 
2008
2461
    let help =
2009
2462
      match short_desc with
2010
2463
        | Some fs -> Some fs
2011
2464
        | None -> None
2012
2465
    in
2013
 
  
 
2466
 
2014
2467
    let var_get_lst =
2015
2468
      FieldRO.create
2016
2469
        ~schema
2022
2475
        ?help
2023
2476
        extra
2024
2477
    in
2025
 
  
 
2478
 
2026
2479
      fun () ->
2027
2480
        var_expand (var_get_low (var_get_lst env))
2028
 
  
 
2481
 
2029
2482
  let var_redefine
2030
2483
        ?hide
2031
2484
        ?dump
2053
2506
          name
2054
2507
          dflt
2055
2508
      end
2056
 
  
 
2509
 
2057
2510
  let var_ignore (e : unit -> string) =
2058
2511
    ()
2059
 
  
 
2512
 
2060
2513
  let print_hidden =
2061
2514
    var_define
2062
2515
      ~hide:true
2065
2518
      ~arg_help:"Print even non-printable variable. (debug)"
2066
2519
      "print_hidden"
2067
2520
      (fun () -> "false")
2068
 
  
 
2521
 
2069
2522
  let var_all () =
2070
2523
    List.rev
2071
2524
      (Schema.fold
2076
2529
              acc)
2077
2530
         []
2078
2531
         schema)
2079
 
  
 
2532
 
2080
2533
  let default_filename =
2081
2534
    BaseEnvLight.default_filename
2082
 
  
 
2535
 
2083
2536
  let load ?allow_empty ?filename () =
2084
2537
    env_from_file := BaseEnvLight.load ?allow_empty ?filename ()
2085
 
  
 
2538
 
2086
2539
  let unload () =
2087
2540
    env_from_file := MapString.empty;
2088
2541
    Data.clear env
2089
 
  
 
2542
 
2090
2543
  let dump ?(filename=default_filename) () =
2091
2544
    let chn =
2092
2545
      open_out_bin filename
2117
2570
    in
2118
2571
      (* Dump data defined outside of schema *)
2119
2572
      MapString.iter output mp_todo;
2120
 
  
 
2573
 
2121
2574
      (* End of the dump *)
2122
2575
      close_out chn
2123
 
  
 
2576
 
2124
2577
  let print () =
2125
2578
    let printable_vars =
2126
2579
      Schema.fold
2156
2609
    let dot_pad str =
2157
2610
      String.make ((max_length - (String.length str)) + 3) '.'
2158
2611
    in
2159
 
  
 
2612
 
2160
2613
    Printf.printf "\nConfiguration: \n";
2161
2614
    List.iter
2162
2615
      (fun (name,value) ->
2163
2616
        Printf.printf "%s: %s %s\n" name (dot_pad name) value)
2164
2617
      (List.rev printable_vars);
2165
2618
    Printf.printf "\n%!"
2166
 
  
 
2619
 
2167
2620
  let args () =
2168
2621
    let arg_concat =
2169
2622
      OASISUtils.varname_concat ~hyphen:'-'
2190
2643
               ]
2191
2644
           ),
2192
2645
        "var+val  Override any configuration variable.";
2193
 
  
 
2646
 
2194
2647
      ]
2195
2648
      @
2196
2649
      List.flatten
2204
2657
                 name
2205
2658
                 s
2206
2659
             in
2207
 
  
 
2660
 
2208
2661
             let arg_name =
2209
2662
               OASISUtils.varname_of_string ~hyphen:'-' name
2210
2663
             in
2211
 
  
 
2664
 
2212
2665
             let hlp =
2213
2666
               match short_descr_opt with
2214
2667
                 | Some txt -> txt ()
2215
2668
                 | None -> ""
2216
2669
             in
2217
 
  
 
2670
 
2218
2671
             let arg_hlp =
2219
2672
               match def.arg_help with
2220
2673
                 | Some s -> s
2221
2674
                 | None   -> "str"
2222
2675
             in
2223
 
  
 
2676
 
2224
2677
             let default_value =
2225
2678
               try
2226
2679
                 Printf.sprintf
2232
2685
               with Not_set _ ->
2233
2686
                 ""
2234
2687
             in
2235
 
  
 
2688
 
2236
2689
             let args =
2237
2690
               match def.cli with
2238
2691
                 | CLINone ->
2260
2713
                         arg_concat "--enable-" arg_name,
2261
2714
                         Arg.Unit (fun () -> var_set "true"),
2262
2715
                         Printf.sprintf (f_ " %s%s") hlp dflt;
2263
 
  
 
2716
 
2264
2717
                         arg_concat "--disable-" arg_name,
2265
2718
                         Arg.Unit (fun () -> var_set "false"),
2266
2719
                         Printf.sprintf (f_ " %s%s") hlp dflt
2273
2726
           schema)
2274
2727
end
2275
2728
 
2276
 
module BaseExec = struct
2277
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseExec.ml"
2278
 
  
2279
 
  open OASISGettext
2280
 
  open OASISUtils
2281
 
  open BaseMessage
2282
 
  
2283
 
  let run ?f_exit_code cmd args =
2284
 
    let cmdline =
2285
 
      String.concat " " (cmd :: args)
2286
 
    in
2287
 
      info (f_ "Running command '%s'") cmdline;
2288
 
      match f_exit_code, Sys.command cmdline with
2289
 
        | None, 0 -> ()
2290
 
        | None, i ->
2291
 
            failwithf
2292
 
              (f_ "Command '%s' terminated with error code %d")
2293
 
              cmdline i
2294
 
        | Some f, i ->
2295
 
            f i
2296
 
  
2297
 
  let run_read_output ?f_exit_code cmd args =
2298
 
    let fn =
2299
 
      Filename.temp_file "oasis-" ".txt"
2300
 
    in
2301
 
    let () =
2302
 
      try
2303
 
        run ?f_exit_code cmd (args @ [">"; Filename.quote fn])
2304
 
      with e ->
2305
 
        Sys.remove fn;
2306
 
        raise e
2307
 
    in
2308
 
    let chn =
2309
 
      open_in fn
2310
 
    in
2311
 
    let routput =
2312
 
      ref []
2313
 
    in
2314
 
      (
2315
 
        try
2316
 
          while true do
2317
 
            routput := (input_line chn) :: !routput
2318
 
          done
2319
 
        with End_of_file ->
2320
 
          ()
2321
 
      );
2322
 
      close_in chn;
2323
 
      Sys.remove fn;
2324
 
      List.rev !routput
2325
 
  
2326
 
  let run_read_one_line ?f_exit_code cmd args =
2327
 
    match run_read_output ?f_exit_code cmd args with
2328
 
      | [fst] ->
2329
 
          fst
2330
 
      | lst ->
2331
 
          failwithf
2332
 
            (f_ "Command return unexpected output %S")
2333
 
            (String.concat "\n" lst)
2334
 
end
2335
 
 
2336
 
module BaseFileUtil = struct
2337
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseFileUtil.ml"
2338
 
  
2339
 
  open OASISGettext
2340
 
  
2341
 
  let find_file paths exts =
2342
 
  
2343
 
    (* Cardinal product of two list *)
2344
 
    let ( * ) lst1 lst2 =
2345
 
      List.flatten
2346
 
        (List.map
2347
 
           (fun a ->
2348
 
              List.map
2349
 
                (fun b -> a,b)
2350
 
                lst2)
2351
 
           lst1)
2352
 
    in
2353
 
  
2354
 
    let rec combined_paths lst =
2355
 
      match lst with
2356
 
        | p1 :: p2 :: tl ->
2357
 
            let acc =
2358
 
              (List.map
2359
 
                 (fun (a,b) -> Filename.concat a b)
2360
 
                 (p1 * p2))
2361
 
            in
2362
 
              combined_paths (acc :: tl)
2363
 
        | [e] ->
2364
 
            e
2365
 
        | [] ->
2366
 
            []
2367
 
    in
2368
 
  
2369
 
    let alternatives =
2370
 
      List.map
2371
 
        (fun (p,e) ->
2372
 
           if String.length e > 0 && e.[0] <> '.' then
2373
 
             p ^ "." ^ e
2374
 
           else
2375
 
             p ^ e)
2376
 
        ((combined_paths paths) * exts)
2377
 
    in
2378
 
      List.find
2379
 
        Sys.file_exists
2380
 
        alternatives
2381
 
  
2382
 
  let which prg =
2383
 
    let path_sep =
2384
 
      match Sys.os_type with
2385
 
        | "Win32" ->
2386
 
            ';'
2387
 
        | _ ->
2388
 
            ':'
2389
 
    in
2390
 
    let path_lst =
2391
 
      OASISUtils.split
2392
 
        path_sep
2393
 
        (Sys.getenv "PATH")
2394
 
    in
2395
 
    let exec_ext =
2396
 
      match Sys.os_type with
2397
 
        | "Win32" ->
2398
 
            ""
2399
 
            ::
2400
 
            (OASISUtils.split
2401
 
               path_sep
2402
 
               (Sys.getenv "PATHEXT"))
2403
 
        | _ ->
2404
 
            [""]
2405
 
    in
2406
 
      find_file [path_lst; [prg]] exec_ext
2407
 
  
2408
 
  (**/**)
2409
 
  let rec fix_dir dn =
2410
 
    (* Windows hack because Sys.file_exists "src\\" = false when
2411
 
     * Sys.file_exists "src" = true
2412
 
     *)
2413
 
    let ln =
2414
 
      String.length dn
2415
 
    in
2416
 
      if Sys.os_type = "Win32" && ln > 0 && dn.[ln - 1] = '\\' then
2417
 
        fix_dir (String.sub dn 0 (ln - 1))
2418
 
      else
2419
 
        dn
2420
 
  
2421
 
  let q = Filename.quote
2422
 
  (**/**)
2423
 
  
2424
 
  let cp src tgt =
2425
 
    BaseExec.run
2426
 
      (match Sys.os_type with
2427
 
       | "Win32" -> "copy"
2428
 
       | _ -> "cp")
2429
 
      [q src; q tgt]
2430
 
  
2431
 
  let mkdir tgt =
2432
 
    BaseExec.run
2433
 
      (match Sys.os_type with
2434
 
         | "Win32" -> "md"
2435
 
         | _ -> "mkdir")
2436
 
      [q tgt]
2437
 
  
2438
 
  let rec mkdir_parent f tgt =
2439
 
    let tgt =
2440
 
      fix_dir tgt
2441
 
    in
2442
 
      if Sys.file_exists tgt then
2443
 
        begin
2444
 
          if not (Sys.is_directory tgt) then
2445
 
            OASISUtils.failwithf
2446
 
              (f_ "Cannot create directory '%s', a file of the same name already \
2447
 
                   exists")
2448
 
              tgt
2449
 
        end
2450
 
      else
2451
 
        begin
2452
 
          mkdir_parent f (Filename.dirname tgt);
2453
 
          if not (Sys.file_exists tgt) then
2454
 
            begin
2455
 
              f tgt;
2456
 
              mkdir tgt
2457
 
            end
2458
 
        end
2459
 
  
2460
 
  let rmdir tgt =
2461
 
    if Sys.readdir tgt = [||] then
2462
 
      begin
2463
 
        match Sys.os_type with
2464
 
          | "Win32" ->
2465
 
              BaseExec.run "rd" [q tgt]
2466
 
          | _ ->
2467
 
              BaseExec.run "rm" ["-r"; q tgt]
2468
 
      end
2469
 
  
2470
 
  let glob fn =
2471
 
   let basename =
2472
 
     Filename.basename fn
2473
 
   in
2474
 
     if String.length basename >= 2 &&
2475
 
        basename.[0] = '*' &&
2476
 
        basename.[1] = '.' then
2477
 
       begin
2478
 
         let ext_len =
2479
 
           (String.length basename) - 2
2480
 
         in
2481
 
         let ext =
2482
 
           String.sub basename 2 ext_len
2483
 
         in
2484
 
         let dirname =
2485
 
           Filename.dirname fn
2486
 
         in
2487
 
           Array.fold_left
2488
 
             (fun acc fn ->
2489
 
                try
2490
 
                  let fn_ext =
2491
 
                    String.sub
2492
 
                      fn
2493
 
                      ((String.length fn) - ext_len)
2494
 
                      ext_len
2495
 
                  in
2496
 
                    if fn_ext = ext then
2497
 
                      (Filename.concat dirname fn) :: acc
2498
 
                    else
2499
 
                      acc
2500
 
                with Invalid_argument _ ->
2501
 
                  acc)
2502
 
             []
2503
 
             (Sys.readdir dirname)
2504
 
       end
2505
 
     else
2506
 
       begin
2507
 
         if Sys.file_exists fn then
2508
 
           [fn]
2509
 
         else
2510
 
           []
2511
 
       end
2512
 
end
2513
 
 
2514
2729
module BaseArgExt = struct
2515
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseArgExt.ml"
2516
 
  
 
2730
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseArgExt.ml" *)
 
2731
 
2517
2732
  open OASISUtils
2518
2733
  open OASISGettext
2519
 
  
 
2734
 
2520
2735
  let parse argv args =
2521
2736
      (* Simulate command line for Arg *)
2522
2737
      let current =
2523
2738
        ref 0
2524
2739
      in
2525
 
  
 
2740
 
2526
2741
        try
2527
2742
          Arg.parse_argv
2528
2743
            ~current:current
2540
2755
end
2541
2756
 
2542
2757
module BaseCheck = struct
2543
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseCheck.ml"
2544
 
  
 
2758
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseCheck.ml" *)
 
2759
 
2545
2760
  open BaseEnv
2546
2761
  open BaseMessage
2547
2762
  open OASISUtils
2548
2763
  open OASISGettext
2549
 
  
 
2764
 
2550
2765
  let prog_best prg prg_lst =
2551
2766
    var_redefine
2552
2767
      prg
2559
2774
                      res
2560
2775
                  | None ->
2561
2776
                      try
2562
 
                        Some (BaseFileUtil.which e)
 
2777
                        Some (OASISFileUtil.which ~ctxt:!BaseContext.default e)
2563
2778
                      with Not_found ->
2564
2779
                        None)
2565
2780
             None
2568
2783
           match alternate with
2569
2784
             | Some prg -> prg
2570
2785
             | None -> raise Not_found)
2571
 
  
 
2786
 
2572
2787
  let prog prg =
2573
2788
    prog_best prg [prg]
2574
 
  
 
2789
 
2575
2790
  let prog_opt prg =
2576
2791
    prog_best prg [prg^".opt"; prg]
2577
 
  
 
2792
 
2578
2793
  let ocamlfind =
2579
2794
    prog "ocamlfind"
2580
 
  
 
2795
 
2581
2796
  let version
2582
2797
        var_prefix
2583
2798
        cmp
2618
2833
                 (OASISVersion.string_of_comparator cmp)
2619
2834
                 version_str)
2620
2835
        ()
2621
 
  
 
2836
 
2622
2837
  let package_version pkg =
2623
 
    BaseExec.run_read_one_line
 
2838
    OASISExec.run_read_one_line ~ctxt:!BaseContext.default
2624
2839
      (ocamlfind ())
2625
2840
      ["query"; "-format"; "%v"; pkg]
2626
 
  
 
2841
 
2627
2842
  let package ?version_comparator pkg () =
2628
2843
    let var =
2629
2844
      OASISUtils.varname_concat
2632
2847
    in
2633
2848
    let findlib_dir pkg =
2634
2849
      let dir =
2635
 
        BaseExec.run_read_one_line
 
2850
        OASISExec.run_read_one_line ~ctxt:!BaseContext.default
2636
2851
          (ocamlfind ())
2637
2852
          ["query"; "-format"; "%d"; pkg]
2638
2853
      in
2666
2881
end
2667
2882
 
2668
2883
module BaseOCamlcConfig = struct
2669
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseOCamlcConfig.ml"
2670
 
  
2671
 
  
 
2884
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseOCamlcConfig.ml" *)
 
2885
 
 
2886
 
2672
2887
  open BaseEnv
2673
2888
  open OASISUtils
2674
2889
  open OASISGettext
2675
 
  
 
2890
 
2676
2891
  module SMap = Map.Make(String)
2677
 
  
 
2892
 
2678
2893
  let ocamlc =
2679
2894
    BaseCheck.prog_opt "ocamlc"
2680
 
  
 
2895
 
2681
2896
  let ocamlc_config_map =
2682
2897
    (* Map name to value for ocamlc -config output
2683
2898
       (name ^": "^value)
2722
2937
        | [] ->
2723
2938
            mp
2724
2939
    in
2725
 
  
 
2940
 
2726
2941
    let cache = 
2727
2942
      lazy
2728
2943
        (var_protect
2729
2944
           (Marshal.to_string
2730
2945
              (split_field
2731
2946
                 SMap.empty
2732
 
                 (BaseExec.run_read_output
 
2947
                 (OASISExec.run_read_output
 
2948
                    ~ctxt:!BaseContext.default
2733
2949
                    (ocamlc ()) ["-config"]))
2734
2950
              []))
2735
2951
    in
2740
2956
        (fun () ->
2741
2957
           (* TODO: update if ocamlc change !!! *)
2742
2958
           Lazy.force cache)
2743
 
  
 
2959
 
2744
2960
  let var_define nm =
2745
2961
    (* Extract data from ocamlc -config *)
2746
2962
    let avlbl_config_get () =
2754
2970
      with _ -> 
2755
2971
        s
2756
2972
     in
2757
 
  
 
2973
 
2758
2974
    let nm_config, value_config =
2759
2975
      match nm with
2760
2976
        | "ocaml_version" -> 
2777
2993
               (f_ "Cannot find field '%s' in '%s -config' output")
2778
2994
               nm
2779
2995
               (ocamlc ()))
2780
 
  
 
2996
 
2781
2997
end
2782
2998
 
2783
2999
module BaseStandardVar = struct
2784
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseStandardVar.ml"
2785
 
  
2786
 
  
 
3000
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseStandardVar.ml" *)
 
3001
 
 
3002
 
2787
3003
  open OASISGettext
2788
3004
  open OASISTypes
2789
3005
  open OASISExpr
2790
3006
  open BaseCheck
2791
3007
  open BaseEnv
2792
 
  
 
3008
 
2793
3009
  let ocamlfind  = BaseCheck.ocamlfind
2794
3010
  let ocamlc     = BaseOCamlcConfig.ocamlc
2795
3011
  let ocamlopt   = prog_opt "ocamlopt"
2796
3012
  let ocamlbuild = prog "ocamlbuild"
2797
 
  
2798
 
  
 
3013
 
 
3014
 
2799
3015
  (**/**)
2800
3016
  let rpkg =
2801
3017
    ref None
2802
 
  
 
3018
 
2803
3019
  let pkg_get () =
2804
3020
    match !rpkg with
2805
3021
      | Some pkg -> pkg
2806
3022
      | None -> failwith (s_ "OASIS Package is not set")
 
3023
 
 
3024
  let var_cond = ref []
 
3025
 
 
3026
  let var_define_cond ~since_version f dflt =
 
3027
    let holder = ref (fun () -> dflt) in
 
3028
    let since_version =
 
3029
      OASISVersion.VGreaterEqual (OASISVersion.version_of_string since_version)
 
3030
    in
 
3031
      var_cond :=
 
3032
      (fun ver ->
 
3033
         if OASISVersion.comparator_apply ver since_version then
 
3034
           holder := f ()) :: !var_cond;
 
3035
      fun () -> !holder ()
 
3036
 
2807
3037
  (**/**)
2808
 
  
 
3038
 
2809
3039
  let pkg_name =
2810
3040
    var_define
2811
3041
      ~short_desc:(fun () -> s_ "Package name")
2812
3042
      "pkg_name"
2813
3043
      (fun () -> (pkg_get ()).name)
2814
 
  
 
3044
 
2815
3045
  let pkg_version =
2816
3046
    var_define
2817
3047
      ~short_desc:(fun () -> s_ "Package version")
2818
3048
      "pkg_version"
2819
3049
      (fun () ->
2820
3050
         (OASISVersion.string_of_version (pkg_get ()).version))
2821
 
  
 
3051
 
2822
3052
  let c = BaseOCamlcConfig.var_define
2823
 
  
 
3053
 
2824
3054
  let os_type        = c "os_type"
2825
3055
  let system         = c "system"
2826
3056
  let architecture   = c "architecture"
2827
3057
  let ccomp_type     = c "ccomp_type"
2828
3058
  let ocaml_version  = c "ocaml_version"
2829
 
  
 
3059
 
2830
3060
  (* TODO: Check standard variable presence at runtime *)
2831
 
  
 
3061
 
2832
3062
  let standard_library_default = c "standard_library_default"
2833
3063
  let standard_library         = c "standard_library"
2834
3064
  let standard_runtime         = c "standard_runtime"
2841
3071
  let ext_dll                  = c "ext_dll"
2842
3072
  let default_executable_name  = c "default_executable_name"
2843
3073
  let systhread_supported      = c "systhread_supported"
2844
 
  
2845
 
  
 
3074
 
 
3075
  let flexlink = 
 
3076
    BaseCheck.prog "flexlink"
 
3077
 
 
3078
  let flexdll_version =
 
3079
    var_define
 
3080
      ~short_desc:(fun () -> "FlexDLL version (Win32)")
 
3081
      "flexdll_version"
 
3082
      (fun () ->
 
3083
         let lst = 
 
3084
           OASISExec.run_read_output ~ctxt:!BaseContext.default
 
3085
             (flexlink ()) ["-help"]
 
3086
         in
 
3087
           match lst with 
 
3088
             | line :: _ ->
 
3089
                 Scanf.sscanf line "FlexDLL version %s" (fun ver -> ver)
 
3090
             | [] ->
 
3091
                 raise Not_found)
 
3092
 
2846
3093
  (**/**)
2847
3094
  let p name hlp dflt =
2848
3095
    var_define
2851
3098
      ~arg_help:"dir"
2852
3099
      name
2853
3100
      dflt
2854
 
  
 
3101
 
2855
3102
  let (/) a b =
2856
3103
    if os_type () = Sys.os_type then
2857
3104
      Filename.concat a b
2858
3105
    else if os_type () = "Unix" then
2859
 
      BaseFilePath.Unix.concat a b
 
3106
      OASISUnixPath.concat a b
2860
3107
    else
2861
3108
      OASISUtils.failwithf (f_ "Cannot handle os_type %s filename concat")
2862
3109
        (os_type ())
2863
3110
  (**/**)
2864
 
  
 
3111
 
2865
3112
  let prefix =
2866
3113
    p "prefix"
2867
3114
      (fun () -> s_ "Install architecture-independent files dir")
2874
3121
                 program_files/(pkg_name ())
2875
3122
           | _ ->
2876
3123
               "/usr/local")
2877
 
  
 
3124
 
2878
3125
  let exec_prefix =
2879
3126
    p "exec_prefix"
2880
3127
      (fun () -> s_ "Install architecture-dependent files in dir")
2881
3128
      (fun () -> "$prefix")
2882
 
  
 
3129
 
2883
3130
  let bindir =
2884
3131
    p "bindir"
2885
3132
      (fun () -> s_ "User executables")
2886
3133
      (fun () -> "$exec_prefix"/"bin")
2887
 
  
 
3134
 
2888
3135
  let sbindir =
2889
3136
    p "sbindir"
2890
3137
      (fun () -> s_ "System admin executables")
2891
3138
      (fun () -> "$exec_prefix"/"sbin")
2892
 
  
 
3139
 
2893
3140
  let libexecdir =
2894
3141
    p "libexecdir"
2895
3142
      (fun () -> s_ "Program executables")
2896
3143
      (fun () -> "$exec_prefix"/"libexec")
2897
 
  
 
3144
 
2898
3145
  let sysconfdir =
2899
3146
    p "sysconfdir"
2900
3147
      (fun () -> s_ "Read-only single-machine data")
2901
3148
      (fun () -> "$prefix"/"etc")
2902
 
  
 
3149
 
2903
3150
  let sharedstatedir =
2904
3151
    p "sharedstatedir"
2905
3152
      (fun () -> s_ "Modifiable architecture-independent data")
2906
3153
      (fun () -> "$prefix"/"com")
2907
 
  
 
3154
 
2908
3155
  let localstatedir =
2909
3156
    p "localstatedir"
2910
3157
      (fun () -> s_ "Modifiable single-machine data")
2911
3158
      (fun () -> "$prefix"/"var")
2912
 
  
 
3159
 
2913
3160
  let libdir =
2914
3161
    p "libdir"
2915
3162
      (fun () -> s_ "Object code libraries")
2916
3163
      (fun () -> "$exec_prefix"/"lib")
2917
 
  
 
3164
 
2918
3165
  let datarootdir =
2919
3166
    p "datarootdir"
2920
3167
      (fun () -> s_ "Read-only arch-independent data root")
2921
3168
      (fun () -> "$prefix"/"share")
2922
 
  
 
3169
 
2923
3170
  let datadir =
2924
3171
    p "datadir"
2925
3172
      (fun () -> s_ "Read-only architecture-independent data")
2926
3173
      (fun () -> "$datarootdir")
2927
 
  
 
3174
 
2928
3175
  let infodir =
2929
3176
    p "infodir"
2930
3177
      (fun () -> s_ "Info documentation")
2931
3178
      (fun () -> "$datarootdir"/"info")
2932
 
  
 
3179
 
2933
3180
  let localedir =
2934
3181
    p "localedir"
2935
3182
      (fun () -> s_ "Locale-dependent data")
2936
3183
      (fun () -> "$datarootdir"/"locale")
2937
 
  
 
3184
 
2938
3185
  let mandir =
2939
3186
    p "mandir"
2940
3187
      (fun () -> s_ "Man documentation")
2941
3188
      (fun () -> "$datarootdir"/"man")
2942
 
  
 
3189
 
2943
3190
  let docdir =
2944
3191
    p "docdir"
2945
3192
      (fun () -> s_ "Documentation root")
2946
3193
      (fun () -> "$datarootdir"/"doc"/"$pkg_name")
2947
 
  
 
3194
 
2948
3195
  let htmldir =
2949
3196
    p "htmldir"
2950
3197
      (fun () -> s_ "HTML documentation")
2951
3198
      (fun () -> "$docdir")
2952
 
  
 
3199
 
2953
3200
  let dvidir =
2954
3201
    p "dvidir"
2955
3202
      (fun () -> s_ "DVI documentation")
2956
3203
      (fun () -> "$docdir")
2957
 
  
 
3204
 
2958
3205
  let pdfdir =
2959
3206
    p "pdfdir"
2960
3207
      (fun () -> s_ "PDF documentation")
2961
3208
      (fun () -> "$docdir")
2962
 
  
 
3209
 
2963
3210
  let psdir =
2964
3211
    p "psdir"
2965
3212
      (fun () -> s_ "PS documentation")
2966
3213
      (fun () -> "$docdir")
2967
 
  
 
3214
 
2968
3215
  let destdir =
2969
3216
    p "destdir"
2970
3217
      (fun () -> s_ "Prepend a path when installing package")
2973
3220
           (PropList.Not_set
2974
3221
              ("destdir",
2975
3222
               Some (s_ "undefined by construct"))))
2976
 
  
 
3223
 
2977
3224
  let findlib_version =
2978
3225
    var_define
2979
3226
      "findlib_version"
2980
3227
      (fun () ->
2981
3228
         BaseCheck.package_version "findlib")
2982
 
  
 
3229
 
2983
3230
  let is_native =
2984
3231
    var_define
2985
3232
      "is_native"
2994
3241
             ocamlc ()
2995
3242
           in
2996
3243
             "false")
2997
 
  
 
3244
 
2998
3245
  let ext_program =
2999
3246
    var_define
3000
3247
      "suffix_program"
3002
3249
         match os_type () with
3003
3250
           | "Win32" -> ".exe"
3004
3251
           | _ -> "")
3005
 
  
 
3252
 
3006
3253
  let rm =
3007
3254
    var_define
3008
3255
      ~short_desc:(fun () -> s_ "Remove a file.")
3011
3258
         match os_type () with
3012
3259
           | "Win32" -> "del"
3013
3260
           | _ -> "rm -f")
3014
 
  
 
3261
 
3015
3262
  let rmdir =
3016
3263
    var_define
3017
3264
      ~short_desc:(fun () -> s_ "Remove a directory.")
3020
3267
         match os_type () with
3021
3268
           | "Win32" -> "rd"
3022
3269
           | _ -> "rm -rf")
3023
 
  
 
3270
 
3024
3271
  let debug =
3025
3272
    var_define
3026
3273
      ~short_desc:(fun () -> s_ "Turn ocaml debug flag on")
3027
3274
      ~cli:CLIEnable
3028
3275
      "debug"
3029
3276
      (fun () -> "true")
3030
 
  
 
3277
 
3031
3278
  let profile =
3032
3279
    var_define
3033
3280
      ~short_desc:(fun () -> s_ "Turn ocaml profile flag on")
3034
3281
      ~cli:CLIEnable
3035
3282
      "profile"
3036
3283
      (fun () -> "false")
3037
 
  
 
3284
 
3038
3285
  let tests =
3039
 
    var_define
3040
 
      ~short_desc:(fun () ->
3041
 
                     s_ "Compile tests executable and library and run them")
3042
 
      ~cli:CLIEnable
3043
 
      "tests"
3044
 
      (fun () -> "false")
3045
 
  
 
3286
    var_define_cond ~since_version:"0.3"
 
3287
      (fun () ->
 
3288
         var_define
 
3289
           ~short_desc:(fun () ->
 
3290
                          s_ "Compile tests executable and library and run them")
 
3291
           ~cli:CLIEnable
 
3292
           "tests"
 
3293
           (fun () -> "false"))
 
3294
      "true"
 
3295
 
3046
3296
  let docs =
 
3297
    var_define_cond ~since_version:"0.3"
 
3298
      (fun () ->
 
3299
         var_define
 
3300
           ~short_desc:(fun () -> s_ "Create documentations")
 
3301
           ~cli:CLIEnable
 
3302
           "docs"
 
3303
           (fun () -> "true"))
 
3304
      "true"
 
3305
 
 
3306
  let native_dynlink =
3047
3307
    var_define
3048
 
      ~short_desc:(fun () -> s_ "Create documentations")
3049
 
      ~cli:CLIEnable
3050
 
      "docs"
3051
 
      (fun () -> "true")
3052
 
  
 
3308
      ~short_desc:(fun () -> s_ "Compiler support generation of .cmxs.")
 
3309
      ~cli:CLINone
 
3310
      "native_dynlink"
 
3311
      (fun () ->
 
3312
         let res =
 
3313
           let ocaml_lt_312 () = 
 
3314
             OASISVersion.comparator_apply
 
3315
               (OASISVersion.version_of_string (ocaml_version ()))
 
3316
               (OASISVersion.VLesser
 
3317
                  (OASISVersion.version_of_string "3.12.0"))
 
3318
           in
 
3319
           let flexdll_lt_030 () =
 
3320
             OASISVersion.comparator_apply
 
3321
               (OASISVersion.version_of_string (flexdll_version ()))
 
3322
               (OASISVersion.VLesser
 
3323
                  (OASISVersion.version_of_string "0.30"))
 
3324
           in
 
3325
           let has_native_dynlink = 
 
3326
             let ocamlfind = ocamlfind () in
 
3327
               try
 
3328
                 let fn =
 
3329
                   OASISExec.run_read_one_line
 
3330
                     ~ctxt:!BaseContext.default
 
3331
                     ocamlfind
 
3332
                     ["query"; "-predicates"; "native"; "dynlink";
 
3333
                      "-format"; "%d/%a"]
 
3334
                 in
 
3335
                   Sys.file_exists fn
 
3336
               with _ ->
 
3337
                 false
 
3338
           in
 
3339
             if not has_native_dynlink then
 
3340
               false
 
3341
             else if ocaml_lt_312 () then
 
3342
               false
 
3343
             else if (os_type () = "Win32" || os_type () = "Cygwin") 
 
3344
                     && flexdll_lt_030 () then
 
3345
               begin
 
3346
                 BaseMessage.warning 
 
3347
                   (f_ ".cmxs generation disabled because FlexDLL needs to be \
 
3348
                        at least 0.30. Please upgrade FlexDLL from %s to 0.30.")
 
3349
                   (flexdll_version ());
 
3350
                 false
 
3351
               end
 
3352
             else
 
3353
               true
 
3354
         in
 
3355
           string_of_bool res)
 
3356
 
3053
3357
  let init pkg =
3054
 
    rpkg := Some pkg
3055
 
  
 
3358
    rpkg := Some pkg;
 
3359
    List.iter (fun f -> f pkg.oasis_version) !var_cond
 
3360
 
3056
3361
end
3057
3362
 
3058
3363
module BaseFileAB = struct
3059
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseFileAB.ml"
3060
 
  
 
3364
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseFileAB.ml" *)
 
3365
 
3061
3366
  open BaseEnv
3062
3367
  open OASISGettext
3063
3368
  open BaseMessage
3064
 
  
 
3369
 
3065
3370
  let to_filename fn =
3066
3371
    let fn =
3067
 
      BaseFilePath.of_unix fn
 
3372
      OASISHostPath.of_unix fn
3068
3373
    in
3069
3374
      if not (Filename.check_suffix fn ".ab") then
3070
3375
        warning
3071
3376
          (f_ "File '%s' doesn't have '.ab' extension")
3072
3377
          fn;
3073
3378
      Filename.chop_extension fn
3074
 
  
 
3379
 
3075
3380
  let replace fn_lst =
3076
3381
    let buff =
3077
3382
      Buffer.create 13
3079
3384
      List.iter
3080
3385
        (fun fn ->
3081
3386
           let fn =
3082
 
             BaseFilePath.of_unix fn
 
3387
             OASISHostPath.of_unix fn
3083
3388
           in
3084
3389
           let chn_in =
3085
3390
             open_in fn
3104
3409
end
3105
3410
 
3106
3411
module BaseLog = struct
3107
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseLog.ml"
3108
 
  
 
3412
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseLog.ml" *)
 
3413
 
3109
3414
  open OASISUtils
3110
 
  
 
3415
 
3111
3416
  let default_filename =
3112
3417
    Filename.concat
3113
3418
      (Filename.dirname BaseEnv.default_filename)
3114
3419
      "setup.log"
3115
 
  
 
3420
 
3116
3421
  module SetTupleString =
3117
3422
    Set.Make
3118
3423
      (struct
3122
3427
             | 0 -> String.compare s12 s22
3123
3428
             | n -> n
3124
3429
       end)
3125
 
  
 
3430
 
3126
3431
  let load () =
3127
3432
    if Sys.file_exists default_filename then
3128
3433
      begin
3171
3476
      begin
3172
3477
        []
3173
3478
      end
3174
 
  
 
3479
 
3175
3480
  let register event data =
3176
3481
    let chn_out =
3177
3482
      open_out_gen [Open_append; Open_creat; Open_text] 0o644 default_filename
3178
3483
    in
3179
3484
      Printf.fprintf chn_out "%S %S\n" event data;
3180
3485
      close_out chn_out
3181
 
  
 
3486
 
3182
3487
  let unregister event data =
3183
3488
    if Sys.file_exists default_filename then
3184
3489
      begin
3203
3508
          if not !write_something then
3204
3509
            Sys.remove default_filename
3205
3510
      end
3206
 
  
 
3511
 
3207
3512
  let filter events =
3208
3513
    let st_events =
3209
3514
      List.fold_left
3215
3520
      List.filter
3216
3521
        (fun (e, _) -> SetString.mem e st_events)
3217
3522
        (load ())
3218
 
  
 
3523
 
3219
3524
  let exists event data =
3220
3525
    List.exists
3221
3526
      (fun v -> (event, data) = v)
3223
3528
end
3224
3529
 
3225
3530
module BaseBuilt = struct
3226
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseBuilt.ml"
3227
 
  
 
3531
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseBuilt.ml" *)
 
3532
 
3228
3533
  open OASISTypes
3229
3534
  open OASISGettext
3230
3535
  open BaseStandardVar
3231
3536
  open BaseMessage
3232
 
  
 
3537
 
3233
3538
  type t =
3234
3539
    | BExec    (* Executable *)
3235
3540
    | BExecLib (* Library coming with executable *)
3236
3541
    | BLib     (* Library *)
3237
3542
    | BDoc     (* Document *)
3238
 
  
 
3543
 
3239
3544
  let to_log_event_file t nm =
3240
3545
    "built_"^
3241
3546
    (match t with
3244
3549
       | BLib -> "lib"
3245
3550
       | BDoc -> "doc")^
3246
3551
    "_"^nm
3247
 
  
 
3552
 
3248
3553
  let to_log_event_done t nm =
3249
3554
    "is_"^(to_log_event_file t nm)
3250
 
  
 
3555
 
3251
3556
  let register t nm lst =
3252
3557
    BaseLog.register
3253
3558
      (to_log_event_done t nm)
3257
3562
         let registered =
3258
3563
           List.fold_left
3259
3564
             (fun registered fn ->
3260
 
                if Sys.file_exists fn then
 
3565
                if OASISFileUtil.file_exists_case fn then
3261
3566
                  begin
3262
3567
                    BaseLog.register
3263
3568
                      (to_log_event_file t nm)
3277
3582
               (f_ "Cannot find an existing alternative files among: %s")
3278
3583
               (String.concat (s_ ", ") alt))
3279
3584
      lst
3280
 
  
 
3585
 
3281
3586
  let unregister t nm =
3282
3587
    List.iter
3283
3588
      (fun (e, d) ->
3285
3590
      (BaseLog.filter
3286
3591
         [to_log_event_file t nm;
3287
3592
          to_log_event_done t nm])
3288
 
  
 
3593
 
3289
3594
  let fold t nm f acc =
3290
3595
    List.fold_left
3291
3596
      (fun acc (_, fn) ->
3292
 
         if Sys.file_exists fn then
 
3597
         if OASISFileUtil.file_exists_case fn then
3293
3598
           begin
3294
3599
             f acc fn
3295
3600
           end
3313
3618
      acc
3314
3619
      (BaseLog.filter
3315
3620
         [to_log_event_file t nm])
3316
 
  
 
3621
 
3317
3622
  let is_built t nm =
3318
3623
    List.fold_left
3319
3624
      (fun is_built (_, d) ->
3324
3629
      false
3325
3630
      (BaseLog.filter
3326
3631
         [to_log_event_done t nm])
3327
 
  
 
3632
 
3328
3633
  let of_executable ffn (cs, bs, exec) =
3329
3634
    let unix_exec_is, unix_dll_opt =
3330
3635
      OASISExecutable.unix_exec_is
3347
3652
      evs,
3348
3653
      unix_exec_is,
3349
3654
      unix_dll_opt
3350
 
  
 
3655
 
3351
3656
  let of_library ffn (cs, bs, lib) =
3352
3657
    let unix_lst =
3353
3658
      OASISLibrary.generated_unix_files
3354
3659
        ~ctxt:!BaseContext.default
 
3660
        ~source_file_exists:(fun fn ->
 
3661
           OASISFileUtil.file_exists_case (OASISHostPath.of_unix fn))
 
3662
        ~is_native:(bool_of_string (is_native ()))
 
3663
        ~has_native_dynlink:(bool_of_string (native_dynlink ()))
 
3664
        ~ext_lib:(ext_lib ())
 
3665
        ~ext_dll:(ext_dll ())
3355
3666
        (cs, bs, lib)
3356
 
        (fun fn ->
3357
 
           Sys.file_exists (BaseFilePath.of_unix fn))
3358
 
        (fun () ->
3359
 
           bool_of_string (is_native ()))
3360
 
        ext_lib
3361
 
        ext_dll
3362
3667
    in
3363
3668
    let evs =
3364
3669
      [BLib,
3366
3671
       List.map (List.map ffn) unix_lst]
3367
3672
    in
3368
3673
      evs, unix_lst
3369
 
  
 
3674
 
3370
3675
end
3371
3676
 
3372
3677
module BaseCustom = struct
3373
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseCustom.ml"
3374
 
  
 
3678
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseCustom.ml" *)
 
3679
 
3375
3680
  open BaseEnv
3376
3681
  open BaseMessage
3377
3682
  open OASISTypes
3378
3683
  open OASISGettext
3379
 
  
 
3684
 
3380
3685
  let run cmd args extra_args =
3381
 
    BaseExec.run
 
3686
    OASISExec.run ~ctxt:!BaseContext.default ~quote:false
3382
3687
      (var_expand cmd)
3383
3688
      (List.map
3384
3689
         var_expand
3385
3690
         (args @ (Array.to_list extra_args)))
3386
 
  
 
3691
 
3387
3692
  let hook ?(failsafe=false) cstm f e =
3388
3693
    let optional_command lst =
3389
3694
      let printer =
3420
3725
end
3421
3726
 
3422
3727
module BaseDynVar = struct
3423
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseDynVar.ml"
3424
 
  
3425
 
  
 
3728
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseDynVar.ml" *)
 
3729
 
 
3730
 
3426
3731
  open OASISTypes
3427
3732
  open OASISGettext
3428
3733
  open BaseEnv
3429
3734
  open BaseBuilt
3430
 
  
 
3735
 
3431
3736
  let init pkg =
 
3737
    (* TODO: disambiguate exec vs other variable by adding exec_VARNAME. *)
 
3738
    (* TODO: provide compile option for library libary_byte_args_VARNAME... *)
3432
3739
    List.iter
3433
3740
      (function
3434
3741
         | Executable (cs, bs, exec) ->
3441
3748
                                   Printf.sprintf
3442
3749
                                     (f_ "Filename of executable '%s'")
3443
3750
                                     cs.cs_name)
3444
 
                    cs.cs_name
 
3751
                    (OASISUtils.varname_of_string cs.cs_name)
3445
3752
                    (fun () ->
3446
3753
                       let fn_opt =
3447
3754
                         fold
3458
3765
                                     Some (Printf.sprintf
3459
3766
                                             (f_ "Executable '%s' not yet built.")
3460
3767
                                             cs.cs_name)))))
3461
 
  
 
3768
 
3462
3769
         | Library _ | Flag _ | Test _ | SrcRepo _ | Doc _ ->
3463
3770
             ())
3464
3771
      pkg.sections
3465
3772
end
3466
3773
 
3467
3774
module BaseTest = struct
3468
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseTest.ml"
3469
 
  
 
3775
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseTest.ml" *)
 
3776
 
3470
3777
  open BaseEnv
3471
3778
  open BaseMessage
3472
3779
  open OASISTypes
3473
3780
  open OASISExpr
3474
3781
  open OASISGettext
3475
 
  
 
3782
 
3476
3783
  let test lst pkg extra_args =
3477
 
  
 
3784
 
3478
3785
    let one_test (failure, n) (test_plugin, cs, test) =
3479
3786
      if var_choose
3480
3787
           ~name:(Printf.sprintf
3498
3805
                  in
3499
3806
                    chdir dir;
3500
3807
                    fun () -> chdir cwd
3501
 
  
 
3808
 
3502
3809
              | None ->
3503
3810
                  fun () -> ()
3504
3811
          in
3543
3850
      if failure_percent > 0.0 then
3544
3851
        failwith msg
3545
3852
      else
3546
 
        info "%s" msg
 
3853
        info "%s" msg;
 
3854
 
 
3855
      (* Possible explanation why the tests where not run. *)
 
3856
      if OASISVersion.version_0_3_or_after pkg.oasis_version &&
 
3857
         not (bool_of_string (BaseStandardVar.tests ())) &&
 
3858
         lst <> [] then
 
3859
        BaseMessage.warning
 
3860
          "Tests are turned off, consider enabling with \
 
3861
           'ocaml setup.ml -configure --enable-tests'"
3547
3862
end
3548
3863
 
3549
3864
module BaseDoc = struct
3550
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseDoc.ml"
3551
 
  
 
3865
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseDoc.ml" *)
 
3866
 
3552
3867
  open BaseEnv
3553
3868
  open BaseMessage
3554
3869
  open OASISTypes
3555
3870
  open OASISGettext
3556
 
  
 
3871
 
3557
3872
  let doc lst pkg extra_args =
3558
 
  
 
3873
 
3559
3874
    let one_doc (doc_plugin, cs, doc) =
3560
3875
      if var_choose
3561
3876
           ~name:(Printf.sprintf
3571
3886
            extra_args
3572
3887
        end
3573
3888
    in
3574
 
      List.iter
3575
 
        one_doc
3576
 
        lst
 
3889
      List.iter one_doc lst;
 
3890
 
 
3891
      if OASISVersion.version_0_3_or_after pkg.oasis_version &&
 
3892
         not (bool_of_string (BaseStandardVar.docs ())) &&
 
3893
         lst <> [] then
 
3894
        BaseMessage.warning
 
3895
          "Docs are turned off, consider enabling with \
 
3896
           'ocaml setup.ml -configure --enable-docs'"
3577
3897
end
3578
3898
 
3579
3899
module BaseSetup = struct
3580
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseSetup.ml"
3581
 
  
 
3900
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/base/BaseSetup.ml" *)
 
3901
 
3582
3902
  open BaseEnv
3583
3903
  open BaseMessage
3584
3904
  open OASISTypes
3585
3905
  open OASISSection
3586
3906
  open OASISGettext
3587
3907
  open OASISUtils
3588
 
  
 
3908
 
3589
3909
  type std_args_fun =
3590
3910
      package -> string array -> unit
3591
 
  
 
3911
 
3592
3912
  type ('a, 'b) section_args_fun =
3593
3913
      name * (package -> (common_section * 'a) -> string array -> 'b)
3594
 
  
 
3914
 
3595
3915
  type t =
3596
3916
      {
3597
 
        configure:       std_args_fun;
3598
 
        build:           std_args_fun;
3599
 
        doc:             ((doc, unit)  section_args_fun) list;
3600
 
        test:            ((test, float) section_args_fun) list;
3601
 
        install:         std_args_fun;
3602
 
        uninstall:       std_args_fun;
3603
 
        clean:           std_args_fun list;
3604
 
        clean_doc:       (doc, unit) section_args_fun list;
3605
 
        clean_test:      (test, unit) section_args_fun list;
3606
 
        distclean:       std_args_fun list;
3607
 
        distclean_doc:   (doc, unit) section_args_fun list;
3608
 
        distclean_test:  (test, unit) section_args_fun list;
3609
 
        package:         package;
3610
 
        version:         string;
 
3917
        configure:        std_args_fun;
 
3918
        build:            std_args_fun;
 
3919
        doc:              ((doc, unit)  section_args_fun) list;
 
3920
        test:             ((test, float) section_args_fun) list;
 
3921
        install:          std_args_fun;
 
3922
        uninstall:        std_args_fun;
 
3923
        clean:            std_args_fun list;
 
3924
        clean_doc:        (doc, unit) section_args_fun list;
 
3925
        clean_test:       (test, unit) section_args_fun list;
 
3926
        distclean:        std_args_fun list;
 
3927
        distclean_doc:    (doc, unit) section_args_fun list;
 
3928
        distclean_test:   (test, unit) section_args_fun list;
 
3929
        package:          package;
 
3930
        oasis_fn:         string option;
 
3931
        oasis_version:    string;
 
3932
        oasis_digest:     Digest.t option;
 
3933
        oasis_exec:       string option;
 
3934
        oasis_setup_args: string list;
 
3935
        setup_update:     bool;
3611
3936
      }
3612
 
  
 
3937
 
3613
3938
  (* Associate a plugin function with data from package *)
3614
3939
  let join_plugin_sections filter_map lst =
3615
3940
    List.rev
3622
3947
                  acc)
3623
3948
         []
3624
3949
         lst)
3625
 
  
 
3950
 
3626
3951
  (* Search for plugin data associated with a section name *)
3627
3952
  let lookup_plugin_section plugin action nm lst =
3628
3953
    try
3633
3958
        plugin
3634
3959
        nm
3635
3960
        action
3636
 
  
 
3961
 
3637
3962
  let configure t args =
3638
3963
    (* Run configure *)
3639
3964
    BaseCustom.hook
3647
3972
           with _ ->
3648
3973
             ()
3649
3974
         end;
3650
 
  
 
3975
 
3651
3976
         (* Run plugin's configure *)
3652
3977
         t.configure t.package args;
3653
 
  
 
3978
 
3654
3979
         (* Dump to allow postconf to change it *)
3655
3980
         dump ())
3656
3981
      ();
3657
 
  
 
3982
 
3658
3983
    (* Reload environment *)
3659
3984
    unload ();
3660
3985
    load ();
3661
 
  
 
3986
 
3662
3987
    (* Save environment *)
3663
3988
    print ();
3664
 
  
 
3989
 
3665
3990
    (* Replace data in file *)
3666
3991
    BaseFileAB.replace t.package.files_ab
3667
 
  
 
3992
 
3668
3993
  let build t args =
3669
3994
    BaseCustom.hook
3670
3995
      t.package.build_custom
3671
3996
      (t.build t.package)
3672
3997
      args
3673
 
  
 
3998
 
3674
3999
  let doc t args =
3675
 
    if bool_of_string (BaseStandardVar.docs ()) then
3676
 
      BaseDoc.doc
3677
 
        (join_plugin_sections
3678
 
           (function
3679
 
              | Doc (cs, e) ->
3680
 
                  Some
3681
 
                    (lookup_plugin_section
3682
 
                       "documentation"
3683
 
                       (s_ "build")
3684
 
                       cs.cs_name
3685
 
                       t.doc,
3686
 
                     cs,
3687
 
                     e)
3688
 
              | _ ->
3689
 
                  None)
3690
 
           t.package.sections)
3691
 
        t.package
3692
 
        args
3693
 
    else
3694
 
      BaseMessage.warning
3695
 
        "Docs are turned off, consider enabling with \
3696
 
         'ocaml setup.ml -configure --enable-docs'"
3697
 
  
 
4000
    BaseDoc.doc
 
4001
      (join_plugin_sections
 
4002
         (function
 
4003
            | Doc (cs, e) ->
 
4004
                Some
 
4005
                  (lookup_plugin_section
 
4006
                     "documentation"
 
4007
                     (s_ "build")
 
4008
                     cs.cs_name
 
4009
                     t.doc,
 
4010
                   cs,
 
4011
                   e)
 
4012
            | _ ->
 
4013
                None)
 
4014
         t.package.sections)
 
4015
      t.package
 
4016
      args
 
4017
 
3698
4018
  let test t args =
3699
 
    if bool_of_string (BaseStandardVar.tests ()) then
3700
 
      BaseTest.test
3701
 
        (join_plugin_sections
3702
 
           (function
3703
 
              | Test (cs, e) ->
3704
 
                  Some
3705
 
                    (lookup_plugin_section
3706
 
                       "test"
3707
 
                       (s_ "run")
3708
 
                       cs.cs_name
3709
 
                       t.test,
3710
 
                     cs,
3711
 
                     e)
3712
 
              | _ ->
3713
 
                  None)
3714
 
           t.package.sections)
3715
 
        t.package
3716
 
        args
3717
 
    else
3718
 
      BaseMessage.warning
3719
 
        "Tests are turned off, consider enabling with \
3720
 
         'ocaml setup.ml -configure --enable-tests'"
3721
 
  
 
4019
    BaseTest.test
 
4020
      (join_plugin_sections
 
4021
         (function
 
4022
            | Test (cs, e) ->
 
4023
                Some
 
4024
                  (lookup_plugin_section
 
4025
                     "test"
 
4026
                     (s_ "run")
 
4027
                     cs.cs_name
 
4028
                     t.test,
 
4029
                   cs,
 
4030
                   e)
 
4031
            | _ ->
 
4032
                None)
 
4033
         t.package.sections)
 
4034
      t.package
 
4035
      args
 
4036
 
3722
4037
  let all t args =
3723
4038
    let rno_doc =
3724
4039
      ref false
3735
4050
          "-no-doc",
3736
4051
          Arg.Set rno_doc,
3737
4052
          s_ "Don't run doc target";
3738
 
  
 
4053
 
3739
4054
          "-no-test",
3740
4055
          Arg.Set rno_test,
3741
4056
          s_ "Don't run test target";
3742
4057
        ]
3743
4058
        (failwithf (f_ "Don't know what to do with '%s'"))
3744
4059
        "";
3745
 
  
 
4060
 
3746
4061
      info "Running configure step";
3747
4062
      configure t [||];
3748
 
  
 
4063
 
3749
4064
      info "Running build step";
3750
4065
      build     t [||];
3751
 
  
 
4066
 
3752
4067
      (* Load setup.log dynamic variables *)
3753
4068
      BaseDynVar.init t.package;
3754
 
  
 
4069
 
3755
4070
      if not !rno_doc then
3756
4071
        begin
3757
4072
          info "Running doc step";
3761
4076
        begin
3762
4077
          info "Skipping doc step"
3763
4078
        end;
3764
 
  
 
4079
 
3765
4080
      if not !rno_test then
3766
4081
        begin
3767
4082
          info "Running test step";
3771
4086
        begin
3772
4087
          info "Skipping test step"
3773
4088
        end
3774
 
  
 
4089
 
3775
4090
  let install t args =
3776
4091
    BaseCustom.hook
3777
4092
      t.package.install_custom
3778
4093
      (t.install t.package)
3779
4094
      args
3780
 
  
 
4095
 
3781
4096
  let uninstall t args =
3782
4097
    BaseCustom.hook
3783
4098
      t.package.uninstall_custom
3784
4099
      (t.uninstall t.package)
3785
4100
      args
3786
 
  
 
4101
 
3787
4102
  let reinstall t args =
3788
4103
    uninstall t args;
3789
4104
    install t args
3790
 
  
 
4105
 
3791
4106
  let clean, distclean =
3792
4107
    let failsafe f a =
3793
4108
      try
3799
4114
             | Failure msg -> msg
3800
4115
             | e -> Printexc.to_string e)
3801
4116
    in
3802
 
  
 
4117
 
3803
4118
    let generic_clean t cstm mains docs tests args =
3804
4119
      BaseCustom.hook
3805
4120
        ~failsafe:true
3843
4158
             mains)
3844
4159
        ()
3845
4160
    in
3846
 
  
 
4161
 
3847
4162
    let clean t args =
3848
4163
      generic_clean
3849
4164
        t
3853
4168
        t.clean_test
3854
4169
        args
3855
4170
    in
3856
 
  
 
4171
 
3857
4172
    let distclean t args =
3858
4173
      (* Call clean *)
3859
4174
      clean t args;
3860
 
  
 
4175
 
 
4176
      (* Call distclean code *)
 
4177
      generic_clean
 
4178
        t
 
4179
        t.package.distclean_custom
 
4180
        t.distclean
 
4181
        t.distclean_doc
 
4182
        t.distclean_test
 
4183
        args;
 
4184
 
3861
4185
      (* Remove generated file *)
3862
4186
      List.iter
3863
4187
        (fun fn ->
3870
4194
         ::
3871
4195
         BaseLog.default_filename
3872
4196
         ::
3873
 
         (List.rev_map BaseFileAB.to_filename t.package.files_ab));
3874
 
  
3875
 
      (* Call distclean code *)
3876
 
      generic_clean
3877
 
        t
3878
 
        t.package.distclean_custom
3879
 
        t.distclean
3880
 
        t.distclean_doc
3881
 
        t.distclean_test
3882
 
        args
 
4197
         (List.rev_map BaseFileAB.to_filename t.package.files_ab))
3883
4198
    in
3884
 
  
 
4199
 
3885
4200
      clean, distclean
3886
 
  
 
4201
 
3887
4202
  let version t _ =
3888
 
    print_endline t.version
3889
 
  
 
4203
    print_endline t.oasis_version
 
4204
 
 
4205
  let update_setup_ml, no_update_setup_ml_cli =
 
4206
    let b = ref true in
 
4207
      b,
 
4208
      ("-no-update-setup-ml",
 
4209
       Arg.Clear b,
 
4210
       s_ " Don't try to update setup.ml, even if _oasis has changed.")
 
4211
 
 
4212
  let update_setup_ml t =
 
4213
    let oasis_fn =
 
4214
      match t.oasis_fn with
 
4215
        | Some fn -> fn
 
4216
        | None -> "_oasis"
 
4217
    in
 
4218
    let oasis_exec =
 
4219
      match t.oasis_exec with
 
4220
        | Some fn -> fn
 
4221
        | None -> "oasis"
 
4222
    in
 
4223
    let ocaml =
 
4224
      Sys.executable_name
 
4225
    in
 
4226
    let setup_ml, args =
 
4227
      match Array.to_list Sys.argv with
 
4228
        | setup_ml :: args ->
 
4229
            setup_ml, args
 
4230
        | [] ->
 
4231
            failwith
 
4232
              (s_ "Expecting non-empty command line arguments.")
 
4233
    in
 
4234
    let ocaml, setup_ml =
 
4235
      if Sys.executable_name = Sys.argv.(0) then
 
4236
        (* We are not running in standard mode, probably the script
 
4237
         * is precompiled.
 
4238
         *)
 
4239
        "ocaml", "setup.ml"
 
4240
      else
 
4241
        ocaml, setup_ml
 
4242
    in
 
4243
    let no_update_setup_ml_cli, _, _ = no_update_setup_ml_cli in
 
4244
    let do_update () =
 
4245
      let oasis_exec_version =
 
4246
        OASISExec.run_read_one_line
 
4247
          ~ctxt:!BaseContext.default
 
4248
          ~f_exit_code:
 
4249
          (function
 
4250
             | 0 ->
 
4251
                 ()
 
4252
             | 1 ->
 
4253
                 failwithf
 
4254
                   (f_ "Executable '%s' is probably an old version \
 
4255
                      of oasis (< 0.3.0), please update to version \
 
4256
                      v%s.")
 
4257
                   oasis_exec t.oasis_version
 
4258
             | 127 ->
 
4259
                 failwithf
 
4260
                   (f_ "Cannot find executable '%s', please install \
 
4261
                        oasis v%s.")
 
4262
                   oasis_exec t.oasis_version
 
4263
             | n ->
 
4264
                 failwithf
 
4265
                   (f_ "Command '%s version' exited with code %d.")
 
4266
                   oasis_exec n)
 
4267
          oasis_exec ["version"]
 
4268
      in
 
4269
        if OASISVersion.comparator_apply
 
4270
             (OASISVersion.version_of_string oasis_exec_version)
 
4271
             (OASISVersion.VGreaterEqual
 
4272
                (OASISVersion.version_of_string t.oasis_version)) then
 
4273
          begin
 
4274
            (* We have a version >= for the executable oasis, proceed with
 
4275
             * update.
 
4276
             *)
 
4277
            (* TODO: delegate this check to 'oasis setup'. *)
 
4278
            if Sys.os_type = "Win32" then
 
4279
              failwithf
 
4280
                (f_ "It is not possible to update the running script \
 
4281
                     setup.ml on Windows. Please update setup.ml by \
 
4282
                     running '%s'.")
 
4283
                (String.concat " " (oasis_exec :: "setup" :: t.oasis_setup_args))
 
4284
            else
 
4285
              begin
 
4286
                OASISExec.run
 
4287
                  ~ctxt:!BaseContext.default
 
4288
                  ~f_exit_code:
 
4289
                  (function
 
4290
                     | 0 ->
 
4291
                         ()
 
4292
                     | n ->
 
4293
                         failwithf
 
4294
                           (f_ "Unable to update setup.ml using '%s', \
 
4295
                                please fix the problem and retry.")
 
4296
                           oasis_exec)
 
4297
                  oasis_exec ("setup" :: t.oasis_setup_args);
 
4298
                OASISExec.run ~ctxt:!BaseContext.default ocaml (setup_ml :: args)
 
4299
              end
 
4300
          end
 
4301
        else
 
4302
          failwithf
 
4303
            (f_ "The version of '%s' (v%s) doesn't match the version of \
 
4304
                 oasis used to generate the %s file. Please install at \
 
4305
                 least oasis v%s.")
 
4306
            oasis_exec oasis_exec_version setup_ml t.oasis_version
 
4307
    in
 
4308
 
 
4309
    if !update_setup_ml then
 
4310
      begin
 
4311
        try
 
4312
          match t.oasis_digest with
 
4313
            | Some dgst ->
 
4314
              if Sys.file_exists oasis_fn && dgst <> Digest.file "_oasis" then
 
4315
                begin
 
4316
                  do_update ();
 
4317
                  true
 
4318
                end
 
4319
              else
 
4320
                false
 
4321
            | None ->
 
4322
                false
 
4323
        with e ->
 
4324
          error
 
4325
            (f_ "Error when updating setup.ml. If you want to avoid this error, \
 
4326
                 you can bypass the update of %s by running '%s %s %s %s'")
 
4327
            setup_ml ocaml setup_ml no_update_setup_ml_cli
 
4328
            (String.concat " " args);
 
4329
          raise e
 
4330
      end
 
4331
    else
 
4332
      false
 
4333
 
3890
4334
  let setup t =
3891
4335
    let catch_exn =
3892
4336
      ref true
3898
4342
                   (f_ "No action defined, run '%s %s -help'")
3899
4343
                   Sys.executable_name
3900
4344
                   Sys.argv.(0))
3901
 
  
 
4345
 
3902
4346
        in
3903
4347
        let extra_args_ref =
3904
4348
          ref []
3910
4354
          Arg.Tuple
3911
4355
            [
3912
4356
              Arg.Rest (fun str -> extra_args_ref := str :: !extra_args_ref);
3913
 
  
 
4357
 
3914
4358
              Arg.Unit
3915
4359
                (fun () ->
3916
4360
                   allow_empty_env_ref := allow_empty_env;
3917
4361
                   act_ref := act);
3918
4362
            ]
3919
4363
        in
3920
 
  
 
4364
 
3921
4365
          Arg.parse
3922
4366
            (Arg.align
3923
 
               [
 
4367
               ([
3924
4368
                 "-configure",
3925
4369
                 arg_handle ~allow_empty_env:true configure,
3926
4370
                 s_ "[options*] Configure the whole build process.";
3927
 
  
 
4371
 
3928
4372
                 "-build",
3929
4373
                 arg_handle build,
3930
4374
                 s_ "[options*] Build executables and libraries.";
3931
 
  
 
4375
 
3932
4376
                 "-doc",
3933
4377
                 arg_handle doc,
3934
4378
                 s_ "[options*] Build documents.";
3935
 
  
 
4379
 
3936
4380
                 "-test",
3937
4381
                 arg_handle test,
3938
4382
                 s_ "[options*] Run tests.";
3939
 
  
 
4383
 
3940
4384
                 "-all",
3941
4385
                 arg_handle ~allow_empty_env:true all,
3942
4386
                 s_ "[options*] Run configure, build, doc and test targets.";
3943
 
  
 
4387
 
3944
4388
                 "-install",
3945
4389
                 arg_handle install,
3946
4390
                 s_ "[options*] Install libraries, data, executables \
3947
4391
                                and documents.";
3948
 
  
 
4392
 
3949
4393
                 "-uninstall",
3950
4394
                 arg_handle uninstall,
3951
4395
                 s_ "[options*] Uninstall libraries, data, executables \
3952
4396
                                and documents.";
3953
 
  
 
4397
 
3954
4398
                 "-reinstall",
3955
4399
                 arg_handle reinstall,
3956
4400
                 s_ "[options*] Uninstall and install libraries, data, \
3957
4401
                                executables and documents.";
3958
 
  
 
4402
 
3959
4403
                 "-clean",
3960
4404
                 arg_handle ~allow_empty_env:true clean,
3961
4405
                 s_ "[options*] Clean files generated by a build.";
3962
 
  
 
4406
 
3963
4407
                 "-distclean",
3964
4408
                 arg_handle ~allow_empty_env:true distclean,
3965
4409
                 s_ "[options*] Clean files generated by a build and configure.";
3966
 
  
 
4410
 
3967
4411
                 "-version",
3968
4412
                 arg_handle ~allow_empty_env:true version,
3969
4413
                 s_ " Display version of OASIS used to generate this setup.ml.";
3970
 
  
 
4414
 
3971
4415
                 "-no-catch-exn",
3972
4416
                 Arg.Clear catch_exn,
3973
4417
                 s_ " Don't catch exception, useful for debugging.";
3974
4418
               ]
3975
 
             @ (BaseContext.args ()))
 
4419
               @
 
4420
                (if t.setup_update then
 
4421
                   [no_update_setup_ml_cli]
 
4422
                 else
 
4423
                   [])
 
4424
               @ (BaseContext.args ())))
3976
4425
            (failwithf (f_ "Don't know what to do with '%s'"))
3977
4426
            (s_ "Setup and run build process current package\n");
3978
 
  
 
4427
 
3979
4428
          (* Build initial environment *)
3980
4429
          load ~allow_empty:!allow_empty_env_ref ();
3981
 
  
 
4430
 
3982
4431
          (** Initialize flags *)
3983
4432
          List.iter
3984
4433
            (function
4009
4458
               | _ ->
4010
4459
                   ())
4011
4460
            t.package.sections;
4012
 
  
 
4461
 
4013
4462
          BaseStandardVar.init t.package;
4014
 
  
 
4463
 
4015
4464
          BaseDynVar.init t.package;
4016
 
  
4017
 
          !act_ref t (Array.of_list (List.rev !extra_args_ref))
4018
 
  
 
4465
 
 
4466
          if t.setup_update && update_setup_ml t then
 
4467
            ()
 
4468
          else
 
4469
            !act_ref t (Array.of_list (List.rev !extra_args_ref))
 
4470
 
4019
4471
      with e when !catch_exn ->
4020
4472
        error "%s" (Printexc.to_string e);
4021
4473
        exit 1
4022
 
  
4023
 
end
4024
 
 
4025
 
module BaseDev = struct
4026
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/base/BaseDev.ml"
4027
 
  
4028
 
  
4029
 
  
4030
 
  open OASISGettext
4031
 
  open BaseMessage
4032
 
  
4033
 
  type t =
4034
 
      {
4035
 
        oasis_cmd:  string;
4036
 
      } 
4037
 
  
4038
 
  let update_and_run t =
4039
 
    (* Command line to run setup-dev *)
4040
 
    let oasis_args =
4041
 
      "setup-dev" :: "-run" ::
4042
 
      Sys.executable_name ::
4043
 
      (Array.to_list Sys.argv)
4044
 
    in
4045
 
  
4046
 
    let exit_on_child_error =
4047
 
      function
4048
 
        | 0 -> ()
4049
 
        | 2 ->
4050
 
            (* Bad CLI arguments *)
4051
 
            error
4052
 
              (f_ "The command '%s %s' exit with code 2. It often means that we \
4053
 
                   don't use the right command-line arguments, rerun \
4054
 
                   'oasis setup-dev'.")
4055
 
              t.oasis_cmd
4056
 
              (String.concat " " oasis_args)
4057
 
  
4058
 
        | 127 ->
4059
 
            (* Cannot find OASIS *)
4060
 
            error
4061
 
              (f_ "Cannot find executable '%s', check where 'oasis' is located \
4062
 
                   and rerun 'oasis setup-dev'")
4063
 
              t.oasis_cmd
4064
 
  
4065
 
        | i ->
4066
 
            exit i
4067
 
    in
4068
 
  
4069
 
    let () =
4070
 
      (* Run OASIS to generate a temporary setup.ml
4071
 
       *)
4072
 
      BaseExec.run
4073
 
        ~f_exit_code:exit_on_child_error
4074
 
        t.oasis_cmd
4075
 
        oasis_args
4076
 
    in
4077
 
  
4078
 
      ()
4079
 
  
4080
 
end
4081
 
 
4082
 
 
 
4474
 
 
4475
end
 
4476
 
 
4477
 
 
4478
# 4480 "setup.ml"
4083
4479
module InternalConfigurePlugin = struct
4084
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/internal/InternalConfigurePlugin.ml"
4085
 
  
 
4480
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/internal/InternalConfigurePlugin.ml" *)
 
4481
 
4086
4482
  (** Configure using internal scheme
4087
4483
      @author Sylvain Le Gall
4088
4484
    *)
4089
 
  
 
4485
 
4090
4486
  open BaseEnv
4091
4487
  open OASISTypes
4092
4488
  open OASISUtils
4093
4489
  open OASISGettext
4094
4490
  open BaseMessage
4095
 
  
 
4491
 
4096
4492
  (** Configure build using provided series of check to be done
4097
4493
    * and then output corresponding file.
4098
4494
    *)
4103
4499
      in
4104
4500
        ()
4105
4501
    in
4106
 
  
 
4502
 
4107
4503
    let errors =
4108
4504
      ref SetString.empty
4109
4505
    in
4110
 
  
 
4506
 
4111
4507
    let buff =
4112
4508
      Buffer.create 13
4113
4509
    in
4114
 
  
 
4510
 
4115
4511
    let add_errors fmt =
4116
4512
      Printf.kbprintf
4117
4513
        (fun b ->
4120
4516
        buff
4121
4517
        fmt
4122
4518
    in
4123
 
  
 
4519
 
4124
4520
    let warn_exception e =
4125
4521
      warning "%s" (Printexc.to_string e)
4126
4522
    in
4127
 
  
 
4523
 
4128
4524
    (* Check tools *)
4129
4525
    let check_tools lst =
4130
4526
      List.iter
4154
4550
                 pkg.sections)
4155
4551
        lst
4156
4552
    in
4157
 
  
 
4553
 
4158
4554
    let build_checks sct bs =
4159
4555
      if var_choose bs.bs_build then
4160
4556
        begin
4168
4564
                  (f_ "Section %s requires native compilation")
4169
4565
                  (OASISSection.string_of_section sct)
4170
4566
            end;
4171
 
  
 
4567
 
4172
4568
          (* Check tools *)
4173
4569
          check_tools bs.bs_build_tools;
4174
 
  
 
4570
 
4175
4571
          (* Check depends *)
4176
4572
          List.iter
4177
4573
            (function
4211
4607
            bs.bs_build_depends
4212
4608
        end
4213
4609
    in
4214
 
  
 
4610
 
4215
4611
    (* Parse command line *)
4216
4612
    BaseArgExt.parse argv (BaseEnv.args ());
4217
 
  
 
4613
 
4218
4614
    (* OCaml version *)
4219
4615
    begin
4220
4616
      match pkg.ocaml_version with
4236
4632
        | None ->
4237
4633
            ()
4238
4634
    end;
4239
 
  
 
4635
 
4240
4636
    (* Findlib version *)
4241
4637
    begin
4242
4638
      match pkg.findlib_version with
4258
4654
        | None ->
4259
4655
            ()
4260
4656
    end;
4261
 
  
 
4657
 
 
4658
    (* FlexDLL *)
 
4659
    if BaseStandardVar.os_type () = "Win32" ||
 
4660
       BaseStandardVar.os_type () = "Cygwin" then
 
4661
      begin
 
4662
        try
 
4663
          var_ignore_eval BaseStandardVar.flexlink
 
4664
        with e ->
 
4665
          warn_exception e;
 
4666
          add_errors (f_ "Cannot find 'flexlink'")
 
4667
      end;
 
4668
 
4262
4669
    (* Check build depends *)
4263
4670
    List.iter
4264
4671
      (function
4274
4681
         | _ ->
4275
4682
             ())
4276
4683
      pkg.sections;
4277
 
  
 
4684
 
 
4685
    (* Check if we need native dynlink (presence of libraries that compile to
 
4686
     * native)
 
4687
     *)
 
4688
    begin
 
4689
      let has_cmxa =
 
4690
        List.exists
 
4691
          (function
 
4692
             | Library (_, bs, _) ->
 
4693
                 var_choose bs.bs_build &&
 
4694
                 (bs.bs_compiled_object = Native ||
 
4695
                  (bs.bs_compiled_object = Best &&
 
4696
                   bool_of_string (BaseStandardVar.is_native ())))
 
4697
             | _  ->
 
4698
                 false)
 
4699
          pkg.sections
 
4700
      in
 
4701
        if has_cmxa then
 
4702
          var_ignore_eval BaseStandardVar.native_dynlink
 
4703
    end;
 
4704
 
4278
4705
    (* Check errors *)
4279
4706
    if SetString.empty != !errors then
4280
4707
      begin
4288
4715
             (SetString.cardinal !errors))
4289
4716
          (SetString.cardinal !errors)
4290
4717
      end
4291
 
  
 
4718
 
4292
4719
end
4293
4720
 
4294
4721
module InternalInstallPlugin = struct
4295
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/internal/InternalInstallPlugin.ml"
4296
 
  
 
4722
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/internal/InternalInstallPlugin.ml" *)
 
4723
 
4297
4724
  (** Install using internal scheme
4298
4725
      @author Sylvain Le Gall
4299
4726
    *)
4300
 
  
 
4727
 
4301
4728
  open BaseEnv
4302
4729
  open BaseStandardVar
4303
4730
  open BaseMessage
4305
4732
  open OASISLibrary
4306
4733
  open OASISGettext
4307
4734
  open OASISUtils
4308
 
  
 
4735
 
4309
4736
  let exec_hook =
4310
4737
    ref (fun (cs, bs, exec) -> cs, bs, exec)
4311
 
  
 
4738
 
4312
4739
  let lib_hook =
4313
4740
    ref (fun (cs, bs, lib) -> cs, bs, lib, [])
4314
 
  
 
4741
 
4315
4742
  let doc_hook =
4316
4743
    ref (fun (cs, doc) -> cs, doc)
4317
 
  
 
4744
 
4318
4745
  let install_file_ev =
4319
4746
    "install-file"
4320
 
  
 
4747
 
4321
4748
  let install_dir_ev =
4322
4749
    "install-dir"
4323
 
  
 
4750
 
4324
4751
  let install_findlib_ev =
4325
4752
    "install-findlib"
4326
 
  
 
4753
 
 
4754
  let win32_max_command_line_length = 8000
 
4755
 
 
4756
  let split_install_command ocamlfind findlib_name meta files =
 
4757
    if Sys.os_type = "Win32" then
 
4758
      (* Arguments for the first command: *)
 
4759
      let first_args = ["install"; findlib_name; meta] in
 
4760
      (* Arguments for remaining commands: *)
 
4761
      let other_args = ["install"; findlib_name; "-add"] in
 
4762
      (* Extract as much files as possible from [files], [len] is
 
4763
         the current command line length: *)
 
4764
      let rec get_files len acc files =
 
4765
        match files with
 
4766
          | [] ->
 
4767
              (List.rev acc, [])
 
4768
          | file :: rest ->
 
4769
              let len = len + 1 + String.length file in
 
4770
              if len > win32_max_command_line_length then
 
4771
                (List.rev acc, files)
 
4772
              else
 
4773
                get_files len (file :: acc) rest
 
4774
      in
 
4775
      (* Split the command into several commands. *)
 
4776
      let rec split args files =
 
4777
        match files with
 
4778
          | [] ->
 
4779
              []
 
4780
          | _ ->
 
4781
              (* Length of "ocamlfind install <lib> [META|-add]" *)
 
4782
              let len =
 
4783
                List.fold_left
 
4784
                  (fun len arg ->
 
4785
                     len + 1 (* for the space *) + String.length arg)
 
4786
                  (String.length ocamlfind)
 
4787
                  args
 
4788
              in
 
4789
              match get_files len [] files with
 
4790
                | ([], _) ->
 
4791
                    failwith (s_ "Command line too long.")
 
4792
                | (firsts, others) ->
 
4793
                    let cmd = args @ firsts in
 
4794
                    (* Use -add for remaining commands: *)
 
4795
                    let () = 
 
4796
                      let findlib_ge_132 =
 
4797
                        OASISVersion.comparator_apply
 
4798
                          (OASISVersion.version_of_string 
 
4799
                             (BaseStandardVar.findlib_version ()))
 
4800
                          (OASISVersion.VGreaterEqual 
 
4801
                             (OASISVersion.version_of_string "1.3.2"))
 
4802
                      in
 
4803
                        if not findlib_ge_132 then
 
4804
                          failwithf
 
4805
                            (f_ "Installing the library %s require to use the flag \
 
4806
                                 '-add' of ocamlfind because the command line is too \
 
4807
                                  long. This flag is only available for findlib 1.3.2. \
 
4808
                                  Please upgrade findlib from %s to 1.3.2")
 
4809
                            findlib_name (BaseStandardVar.findlib_version ())
 
4810
                    in
 
4811
                    let cmds = split other_args others in
 
4812
                    cmd :: cmds
 
4813
      in
 
4814
      (* The first command does not use -add: *)
 
4815
      split first_args files
 
4816
    else
 
4817
      ["install" :: findlib_name :: meta :: files]
 
4818
 
4327
4819
  let install pkg argv =
4328
 
  
 
4820
 
4329
4821
    let in_destdir =
4330
4822
      try
4331
4823
        let destdir =
4338
4830
      with PropList.Not_set _ ->
4339
4831
        fun fn -> fn
4340
4832
    in
4341
 
  
 
4833
 
4342
4834
    let install_file ?tgt_fn src_file envdir =
4343
4835
      let tgt_dir =
4344
4836
        in_destdir (envdir ())
4353
4845
                 Filename.basename src_file)
4354
4846
      in
4355
4847
        (* Create target directory if needed *)
4356
 
        BaseFileUtil.mkdir_parent
 
4848
        OASISFileUtil.mkdir_parent
 
4849
          ~ctxt:!BaseContext.default
4357
4850
          (fun dn ->
4358
4851
             info (f_ "Creating directory '%s'") dn;
4359
4852
             BaseLog.register install_dir_ev dn)
4360
4853
          tgt_dir;
4361
 
  
 
4854
 
4362
4855
        (* Really install files *)
4363
4856
        info (f_ "Copying file '%s' to '%s'") src_file tgt_file;
4364
 
        BaseFileUtil.cp src_file tgt_file;
 
4857
        OASISFileUtil.cp ~ctxt:!BaseContext.default src_file tgt_file;
4365
4858
        BaseLog.register install_file_ev tgt_file
4366
4859
    in
4367
 
  
 
4860
 
4368
4861
    (* Install data into defined directory *)
4369
4862
    let install_data srcdir lst tgtdir =
4370
4863
      let tgtdir =
4371
 
        BaseFilePath.of_unix (var_expand tgtdir)
 
4864
        OASISHostPath.of_unix (var_expand tgtdir)
4372
4865
      in
4373
4866
        List.iter
4374
4867
          (fun (src, tgt_opt) ->
4375
4868
             let real_srcs =
4376
 
               BaseFileUtil.glob
 
4869
               OASISFileUtil.glob
 
4870
                 ~ctxt:!BaseContext.default
4377
4871
                 (Filename.concat srcdir src)
4378
4872
             in
4379
4873
               if real_srcs = [] then
4387
4881
                      (fun () ->
4388
4882
                         match tgt_opt with
4389
4883
                           | Some s ->
4390
 
                               BaseFilePath.of_unix (var_expand s)
 
4884
                               OASISHostPath.of_unix (var_expand s)
4391
4885
                           | None ->
4392
4886
                               tgtdir))
4393
4887
                 real_srcs)
4394
4888
          lst
4395
4889
    in
4396
 
  
 
4890
 
4397
4891
    (** Install all libraries *)
4398
4892
    let install_libs pkg =
4399
 
  
 
4893
 
4400
4894
      let files_of_library (f_data, acc) data_lib =
4401
4895
        let cs, bs, lib, lib_extra =
4402
4896
          !lib_hook data_lib
4411
4905
              let acc =
4412
4906
                (* Add uncompiled header from the source tree *)
4413
4907
                let path =
4414
 
                  BaseFilePath.of_unix bs.bs_path
 
4908
                  OASISHostPath.of_unix bs.bs_path
4415
4909
                in
4416
4910
                  List.fold_left
4417
4911
                    (fun acc modul ->
4418
4912
                       try
4419
4913
                         List.find
4420
 
                           Sys.file_exists
 
4914
                           OASISFileUtil.file_exists_case
4421
4915
                           (List.map
4422
4916
                              (Filename.concat path)
4423
4917
                              [modul^".mli";
4438
4932
                    acc
4439
4933
                    lib.lib_modules
4440
4934
              in
4441
 
  
 
4935
 
4442
4936
              let acc =
4443
4937
               (* Get generated files *)
4444
4938
               BaseBuilt.fold
4447
4941
                 (fun acc fn -> fn :: acc)
4448
4942
                 acc
4449
4943
              in
4450
 
  
 
4944
 
4451
4945
              let f_data () =
4452
4946
                (* Install data associated with the library *)
4453
4947
                install_data
4458
4952
                     pkg.name);
4459
4953
                f_data ()
4460
4954
              in
4461
 
  
 
4955
 
4462
4956
                (f_data, acc)
4463
4957
            end
4464
4958
           else
4466
4960
              (f_data, acc)
4467
4961
            end
4468
4962
      in
4469
 
  
 
4963
 
4470
4964
      (* Install one group of library *)
4471
4965
      let install_group_lib grp =
4472
4966
        (* Iterate through all group nodes *)
4483
4977
              data_and_files
4484
4978
              children
4485
4979
        in
4486
 
  
 
4980
 
4487
4981
        (* Findlib name of the root library *)
4488
4982
        let findlib_name =
4489
4983
          findlib_of_group grp
4490
4984
        in
4491
 
  
 
4985
 
4492
4986
        (* Determine root library *)
4493
4987
        let root_lib =
4494
4988
          root_of_group grp
4495
4989
        in
4496
 
  
 
4990
 
4497
4991
        (* All files to install for this library *)
4498
4992
        let f_data, files =
4499
4993
          install_group_lib_aux (ignore, []) grp
4500
4994
        in
4501
 
  
 
4995
 
4502
4996
          (* Really install, if there is something to install *)
4503
4997
          if files = [] then
4504
4998
            begin
4516
5010
                let res =
4517
5011
                  Filename.concat bs.bs_path "META"
4518
5012
                in
4519
 
                  if not (Sys.file_exists res) then
 
5013
                  if not (OASISFileUtil.file_exists_case res) then
4520
5014
                    failwithf
4521
5015
                      (f_ "Cannot find file '%s' for findlib library %s")
4522
5016
                      res
4554
5048
                info
4555
5049
                  (f_ "Installing findlib library '%s'")
4556
5050
                  findlib_name;
4557
 
                BaseExec.run
4558
 
                  (ocamlfind ())
4559
 
                  ("install" :: findlib_name :: meta :: files);
 
5051
                let ocamlfind = ocamlfind () in
 
5052
                let commands =
 
5053
                  split_install_command
 
5054
                    ocamlfind
 
5055
                    findlib_name
 
5056
                    meta
 
5057
                    files
 
5058
                in
 
5059
                List.iter
 
5060
                  (OASISExec.run ~ctxt:!BaseContext.default ocamlfind)
 
5061
                  commands;
4560
5062
                BaseLog.register install_findlib_ev findlib_name
4561
5063
            end;
4562
 
  
 
5064
 
4563
5065
          (* Install data files *)
4564
5066
          f_data ();
4565
 
  
4566
 
      in
4567
 
  
 
5067
 
 
5068
      in
 
5069
 
 
5070
      let group_libs, _, _ =
 
5071
        findlib_mapping pkg
 
5072
      in
 
5073
 
4568
5074
        (* We install libraries in groups *)
4569
 
        List.iter
4570
 
          install_group_lib
4571
 
          (group_libs pkg)
 
5075
        List.iter install_group_lib group_libs
4572
5076
    in
4573
 
  
 
5077
 
4574
5078
    let install_execs pkg =
4575
5079
      let install_exec data_exec =
4576
5080
        let (cs, bs, exec) =
4589
5093
                  cs.cs_name
4590
5094
                  (fun () fn ->
4591
5095
                     install_file
4592
 
                       ~tgt_fn:cs.cs_name
 
5096
                       ~tgt_fn:(cs.cs_name ^ ext_program ())
4593
5097
                       fn
4594
5098
                       bindir)
4595
5099
                  ();
4617
5121
                 ())
4618
5122
          pkg.sections
4619
5123
    in
4620
 
  
 
5124
 
4621
5125
    let install_docs pkg =
4622
5126
      let install_doc data =
4623
5127
        let (cs, doc) =
4627
5131
             BaseBuilt.is_built BaseBuilt.BDoc cs.cs_name then
4628
5132
            begin
4629
5133
              let tgt_dir =
4630
 
                BaseFilePath.of_unix (var_expand doc.doc_install_dir)
 
5134
                OASISHostPath.of_unix (var_expand doc.doc_install_dir)
4631
5135
              in
4632
5136
                BaseBuilt.fold
4633
5137
                  BaseBuilt.BDoc
4651
5155
                 ())
4652
5156
          pkg.sections
4653
5157
    in
4654
 
  
 
5158
 
4655
5159
      install_libs  pkg;
4656
5160
      install_execs pkg;
4657
5161
      install_docs  pkg
4658
 
  
 
5162
 
4659
5163
  (* Uninstall already installed data *)
4660
5164
  let uninstall _ argv =
4661
5165
    List.iter
4662
5166
      (fun (ev, data) ->
4663
5167
         if ev = install_file_ev then
4664
5168
           begin
4665
 
             if Sys.file_exists data then
 
5169
             if OASISFileUtil.file_exists_case data then
4666
5170
               begin
4667
5171
                 info
4668
5172
                   (f_ "Removing file '%s'")
4685
5189
                     info
4686
5190
                       (f_ "Removing directory '%s'")
4687
5191
                       data;
4688
 
                     BaseFileUtil.rmdir data
 
5192
                     OASISFileUtil.rmdir ~ctxt:!BaseContext.default data
4689
5193
                   end
4690
5194
                 else
4691
5195
                   begin
4708
5212
         else if ev = install_findlib_ev then
4709
5213
           begin
4710
5214
             info (f_ "Removing findlib library '%s'") data;
4711
 
             BaseExec.run (ocamlfind ()) ["remove"; data]
 
5215
             OASISExec.run ~ctxt:!BaseContext.default
 
5216
               (ocamlfind ()) ["remove"; data]
4712
5217
           end
4713
5218
         else
4714
5219
           failwithf (f_ "Unknown log event '%s'") ev;
4719
5224
            [install_file_ev;
4720
5225
             install_dir_ev;
4721
5226
             install_findlib_ev;]))
4722
 
  
 
5227
 
4723
5228
end
4724
5229
 
4725
5230
 
 
5231
# 5233 "setup.ml"
4726
5232
module OCamlbuildCommon = struct
4727
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/ocamlbuild/OCamlbuildCommon.ml"
4728
 
  
 
5233
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
 
5234
 
4729
5235
  (** Functions common to OCamlbuild build and doc plugin
4730
5236
    *)
4731
 
  
 
5237
 
4732
5238
  open OASISGettext
4733
5239
  open BaseEnv
4734
5240
  open BaseStandardVar
4735
 
  
 
5241
 
4736
5242
  let ocamlbuild_clean_ev =
4737
5243
    "ocamlbuild-clean"
4738
 
  
 
5244
 
4739
5245
  let ocamlbuildflags =
4740
5246
    var_define
4741
5247
      ~short_desc:(fun () -> "OCamlbuild additional flags")
4742
5248
      "ocamlbuildflags"
4743
5249
      (fun () -> "")
4744
 
  
 
5250
 
4745
5251
  (** Fix special arguments depending on environment *)
4746
5252
  let fix_args args extra_argv =
4747
5253
    List.flatten
4756
5262
          ]
4757
5263
        else
4758
5264
          [];
4759
 
  
 
5265
 
4760
5266
        if not (bool_of_string (is_native ())) || (os_type ()) = "Win32" then
4761
5267
          [
4762
5268
            "-byte-plugin"
4764
5270
        else
4765
5271
          [];
4766
5272
        args;
4767
 
  
 
5273
 
4768
5274
        if bool_of_string (debug ()) then
4769
5275
          ["-tag"; "debug"]
4770
5276
        else
4771
5277
          [];
4772
 
  
 
5278
 
4773
5279
        if bool_of_string (profile ()) then
4774
5280
          ["-tag"; "profile"]
4775
5281
        else
4776
5282
          [];
4777
 
  
4778
 
        OASISUtils.split ' ' (ocamlbuildflags ());
4779
 
  
 
5283
 
 
5284
        OASISString.nsplit (ocamlbuildflags ()) ' ';
 
5285
 
4780
5286
        Array.to_list extra_argv;
4781
5287
      ]
4782
 
  
 
5288
 
4783
5289
  (** Run 'ocamlbuild -clean' if not already done *)
4784
5290
  let run_clean extra_argv =
4785
5291
    let extra_cli =
4788
5294
      (* Run if never called with these args *)
4789
5295
      if not (BaseLog.exists ocamlbuild_clean_ev extra_cli) then
4790
5296
        begin
4791
 
          BaseExec.run (ocamlbuild ()) (fix_args ["-clean"] extra_argv);
 
5297
          OASISExec.run ~ctxt:!BaseContext.default
 
5298
            (ocamlbuild ()) (fix_args ["-clean"] extra_argv);
4792
5299
          BaseLog.register ocamlbuild_clean_ev extra_cli;
4793
5300
          at_exit
4794
5301
            (fun () ->
4797
5304
               with _ ->
4798
5305
                 ())
4799
5306
        end
4800
 
  
 
5307
 
4801
5308
  (** Run ocamlbuild, unregister all clean events *)
4802
5309
  let run_ocamlbuild args extra_argv =
4803
5310
    (* TODO: enforce that target in args must be UNIX encoded i.e. toto/index.html
4804
5311
     *)
4805
 
    BaseExec.run (ocamlbuild ()) (fix_args args extra_argv);
 
5312
    OASISExec.run ~ctxt:!BaseContext.default
 
5313
      (ocamlbuild ()) (fix_args args extra_argv);
4806
5314
    (* Remove any clean event, we must run it again *)
4807
5315
    List.iter
4808
5316
      (fun (e, d) -> BaseLog.unregister e d)
4809
5317
      (BaseLog.filter [ocamlbuild_clean_ev])
4810
 
  
 
5318
 
4811
5319
  (** Determine real build directory *)
4812
5320
  let build_dir extra_argv =
4813
5321
    let rec search_args dir =
4820
5328
            dir
4821
5329
    in
4822
5330
      search_args "_build" (fix_args [] extra_argv)
4823
 
  
 
5331
 
4824
5332
end
4825
5333
 
4826
5334
module OCamlbuildPlugin = struct
4827
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/ocamlbuild/OCamlbuildPlugin.ml"
4828
 
  
 
5335
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" *)
 
5336
 
4829
5337
  (** Build using ocamlbuild
4830
5338
      @author Sylvain Le Gall
4831
5339
    *)
4832
 
  
 
5340
 
4833
5341
  open OASISTypes
4834
5342
  open OASISGettext
4835
5343
  open OASISUtils
4837
5345
  open OCamlbuildCommon
4838
5346
  open BaseStandardVar
4839
5347
  open BaseMessage
4840
 
  
 
5348
 
4841
5349
  let cond_targets_hook =
4842
5350
    ref (fun lst -> lst)
4843
 
  
 
5351
 
4844
5352
  let build pkg argv =
4845
 
  
 
5353
 
4846
5354
    (* Return the filename in build directory *)
4847
5355
    let in_build_dir fn =
4848
5356
      Filename.concat
4849
5357
        (build_dir argv)
4850
5358
        fn
4851
5359
    in
4852
 
  
 
5360
 
4853
5361
    (* Return the unix filename in host build directory *)
4854
5362
    let in_build_dir_of_unix fn =
4855
 
      in_build_dir (BaseFilePath.of_unix fn)
 
5363
      in_build_dir (OASISHostPath.of_unix fn)
4856
5364
    in
4857
 
  
 
5365
 
4858
5366
    let cond_targets =
4859
5367
      List.fold_left
4860
5368
        (fun acc ->
4866
5374
                       in_build_dir_of_unix
4867
5375
                       (cs, bs, lib)
4868
5376
                   in
4869
 
  
 
5377
 
4870
5378
                   let ends_with nd fn =
4871
5379
                     let nd_len =
4872
5380
                       String.length nd
4878
5386
                          (String.length fn - nd_len)
4879
5387
                          nd_len) = nd
4880
5388
                   in
4881
 
  
 
5389
 
4882
5390
                   let tgts =
4883
5391
                     List.flatten
4884
5392
                       (List.filter
4886
5394
                          (List.map
4887
5395
                             (List.filter
4888
5396
                                (fun fn ->
4889
 
                                   ends_with ".cma" fn ||
4890
 
                                   ends_with ".cmxa" fn ||
4891
 
                                   ends_with (ext_lib ()) fn ||
4892
 
                                   ends_with (ext_dll ()) fn))
 
5397
                                 ends_with ".cma" fn
 
5398
                                 || ends_with ".cmxs" fn
 
5399
                                 || ends_with ".cmxa" fn
 
5400
                                 || ends_with (ext_lib ()) fn
 
5401
                                 || ends_with (ext_dll ()) fn))
4893
5402
                             unix_files))
4894
5403
                   in
4895
 
  
 
5404
 
4896
5405
                     match tgts with
4897
5406
                       | _ :: _ ->
4898
5407
                           (evs, tgts) :: acc
4901
5410
                             (f_ "No possible ocamlbuild targets for library %s")
4902
5411
                             cs.cs_name
4903
5412
                 end
4904
 
  
 
5413
 
4905
5414
             | Executable (cs, bs, exec) when var_choose bs.bs_build ->
4906
5415
                 begin
4907
5416
                   let evs, unix_exec_is, unix_dll_opt =
4909
5418
                       in_build_dir_of_unix
4910
5419
                       (cs, bs, exec)
4911
5420
                   in
4912
 
  
 
5421
 
4913
5422
                   let target ext =
4914
5423
                     let unix_tgt =
4915
 
                       (BaseFilePath.Unix.concat
 
5424
                       (OASISUnixPath.concat
4916
5425
                          bs.bs_path
4917
 
                          (BaseFilePath.Unix.chop_extension
 
5426
                          (OASISUnixPath.chop_extension
4918
5427
                             exec.exec_main_is))^ext
4919
5428
                     in
4920
5429
                     let evs = 
4929
5438
                     in
4930
5439
                       evs, [unix_tgt]
4931
5440
                   in
4932
 
  
 
5441
 
4933
5442
                   (* Add executable *)
4934
5443
                   let acc =
4935
5444
                     match bs.bs_compiled_object with
4943
5452
                   in
4944
5453
                     acc
4945
5454
                 end
4946
 
  
 
5455
 
4947
5456
             | Library _ | Executable _ | Test _
4948
5457
             | SrcRepo _ | Flag _ | Doc _ ->
4949
5458
                 acc)
4951
5460
        (* Keep the pkg.sections ordered *)
4952
5461
        (List.rev pkg.sections);
4953
5462
    in
4954
 
  
 
5463
 
4955
5464
    (* Check and register built files *)
4956
5465
    let check_and_register (bt, bnm, lst) =
4957
5466
      List.iter
4958
5467
        (fun fns ->
4959
 
           if not (List.exists Sys.file_exists fns) then
 
5468
           if not (List.exists OASISFileUtil.file_exists_case fns) then
4960
5469
             failwithf
4961
5470
               (f_ "No one of expected built files %s exists")
4962
5471
               (String.concat (s_ ", ") (List.map (Printf.sprintf "'%s'") fns)))
4963
5472
        lst;
4964
5473
        (BaseBuilt.register bt bnm lst)
4965
5474
    in
4966
 
  
 
5475
 
4967
5476
    let cond_targets =
4968
5477
      (* Run the hook *)
4969
5478
      !cond_targets_hook cond_targets
4970
5479
    in
4971
 
  
 
5480
 
4972
5481
      (* Run a list of target... *)
4973
5482
      run_ocamlbuild 
4974
5483
        (List.flatten 
4978
5487
      List.iter
4979
5488
        check_and_register
4980
5489
        (List.flatten (List.map fst cond_targets))
4981
 
  
4982
 
  
 
5490
 
 
5491
 
4983
5492
  let clean pkg extra_args  =
4984
5493
    run_clean extra_args;
4985
5494
    List.iter
4992
5501
         | _ ->
4993
5502
             ())
4994
5503
      pkg.sections
4995
 
  
 
5504
 
4996
5505
end
4997
5506
 
4998
5507
module OCamlbuildDocPlugin = struct
4999
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml"
5000
 
  
 
5508
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" *)
 
5509
 
5001
5510
  (* Create documentation using ocamlbuild .odocl files
5002
5511
     @author Sylvain Le Gall
5003
5512
   *)
5004
 
  
 
5513
 
5005
5514
  open OASISTypes
5006
5515
  open OASISGettext
5007
5516
  open OASISMessage
5008
5517
  open OCamlbuildCommon
5009
5518
  open BaseStandardVar
5010
 
  
5011
 
  
5012
 
  
 
5519
 
 
5520
 
 
5521
 
5013
5522
  let doc_build path pkg (cs, doc) argv =
5014
5523
    let index_html =
5015
 
      BaseFilePath.Unix.make
 
5524
      OASISUnixPath.make
5016
5525
        [
5017
5526
          path;
5018
5527
          cs.cs_name^".docdir";
5020
5529
        ]
5021
5530
    in
5022
5531
    let tgt_dir =
5023
 
      BaseFilePath.make
 
5532
      OASISHostPath.make
5024
5533
        [
5025
5534
          build_dir argv;
5026
 
          BaseFilePath.of_unix path;
 
5535
          OASISHostPath.of_unix path;
5027
5536
          cs.cs_name^".docdir";
5028
5537
        ]
5029
5538
    in
5033
5542
           BaseBuilt.register
5034
5543
             BaseBuilt.BDoc
5035
5544
             cs.cs_name
5036
 
             [BaseFileUtil.glob
 
5545
             [OASISFileUtil.glob ~ctxt:!BaseContext.default
5037
5546
                (Filename.concat tgt_dir glb)])
5038
5547
        ["*.html"; "*.css"]
5039
 
  
 
5548
 
5040
5549
  let doc_clean t pkg (cs, doc) argv =
5041
5550
    run_clean argv;
5042
5551
    BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name
5043
 
  
 
5552
 
5044
5553
end
5045
5554
 
5046
5555
 
 
5556
# 5558 "setup.ml"
5047
5557
module CustomPlugin = struct
5048
 
# 21 "/Users/mmottl/Downloads/oasis-0.3.0~rc2/src/plugins/custom/CustomPlugin.ml"
5049
 
  
 
5558
(* # 21 "/home/ysulsky/local/opam-full/4.00.1/build/oasis.0.3.0/src/plugins/custom/CustomPlugin.ml" *)
 
5559
 
5050
5560
  (** Generate custom configure/build/doc/test/install system
5051
5561
      @author
5052
5562
    *)
5053
 
  
 
5563
 
5054
5564
  open BaseEnv
5055
5565
  open OASISGettext
5056
5566
  open OASISTypes
5057
 
  
5058
 
  
5059
 
  
 
5567
 
 
5568
 
 
5569
 
5060
5570
  type t =
5061
5571
      {
5062
5572
        cmd_main:      command_line conditional;
5063
5573
        cmd_clean:     (command_line option) conditional;
5064
5574
        cmd_distclean: (command_line option) conditional;
5065
5575
      } 
5066
 
  
 
5576
 
5067
5577
  let run  = BaseCustom.run 
5068
 
  
 
5578
 
5069
5579
  let main t _ extra_args =
5070
5580
    let cmd, args =
5071
5581
      var_choose 
5073
5583
        t.cmd_main
5074
5584
    in
5075
5585
      run cmd args extra_args 
5076
 
  
 
5586
 
5077
5587
  let clean t pkg extra_args =
5078
5588
    match var_choose t.cmd_clean with
5079
5589
      | Some (cmd, args) ->
5080
5590
          run cmd args extra_args
5081
5591
      | _ ->
5082
5592
          ()
5083
 
  
 
5593
 
5084
5594
  let distclean t pkg extra_args =
5085
5595
    match var_choose t.cmd_distclean with
5086
5596
      | Some (cmd, args) ->
5087
5597
          run cmd args extra_args
5088
5598
      | _ ->
5089
5599
          ()
5090
 
  
 
5600
 
5091
5601
  module Build =
5092
5602
  struct 
5093
5603
    let main t pkg extra_args =
5100
5610
                   begin
5101
5611
                     let evs, _ = 
5102
5612
                       BaseBuilt.of_library 
5103
 
                         BaseFilePath.of_unix
 
5613
                         OASISHostPath.of_unix
5104
5614
                         (cs, bs, lib) 
5105
5615
                     in
5106
5616
                       evs
5109
5619
                   begin
5110
5620
                     let evs, _, _ =
5111
5621
                       BaseBuilt.of_executable
5112
 
                         BaseFilePath.of_unix
 
5622
                         OASISHostPath.of_unix
5113
5623
                         (cs, bs, exec)
5114
5624
                     in
5115
5625
                       evs
5121
5631
               (fun (bt, bnm, lst) -> BaseBuilt.register bt bnm lst)
5122
5632
               evs)
5123
5633
        pkg.sections
5124
 
  
 
5634
 
5125
5635
    let clean t pkg extra_args =
5126
5636
      clean t pkg extra_args;
5127
5637
      (* TODO: this seems to be pretty generic (at least wrt to ocamlbuild
5137
5647
           | _ ->
5138
5648
               ())
5139
5649
        pkg.sections
5140
 
  
 
5650
 
5141
5651
    let distclean t pkg extra_args =
5142
5652
      distclean t pkg extra_args
5143
5653
  end
5144
 
  
 
5654
 
5145
5655
  module Test =
5146
5656
  struct
5147
5657
    let main t pkg (cs, test) extra_args =
5154
5664
          cs.cs_name
5155
5665
          s;
5156
5666
        1.0
5157
 
  
 
5667
 
5158
5668
    let clean t pkg (cs, test) extra_args =
5159
5669
      clean t pkg extra_args
5160
 
  
 
5670
 
5161
5671
    let distclean t pkg (cs, test) extra_args =
5162
5672
      distclean t pkg extra_args 
5163
5673
  end
5164
 
  
 
5674
 
5165
5675
  module Doc =
5166
5676
  struct
5167
5677
    let main t pkg (cs, _) extra_args =
5168
5678
      main t pkg extra_args;
5169
5679
      BaseBuilt.register BaseBuilt.BDoc cs.cs_name []
5170
 
  
 
5680
 
5171
5681
    let clean t pkg (cs, _) extra_args =
5172
5682
      clean t pkg extra_args;
5173
5683
      BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name
5174
 
  
 
5684
 
5175
5685
    let distclean t pkg (cs, _) extra_args =
5176
5686
      distclean t pkg extra_args
5177
5687
  end
5178
 
  
 
5688
 
5179
5689
end
5180
5690
 
5181
5691
 
 
5692
# 5694 "setup.ml"
5182
5693
open OASISTypes;;
5183
5694
 
5184
5695
let setup_t =
5261
5772
     package =
5262
5773
       {
5263
5774
          oasis_version = "0.3";
5264
 
          ocaml_version = Some (OASISVersion.VGreaterEqual "3.12");
5265
 
          findlib_version = None;
 
5775
          ocaml_version = Some (OASISVersion.VGreaterEqual "4.00.0");
 
5776
          findlib_version = Some (OASISVersion.VGreaterEqual "1.3.2");
5266
5777
          name = "sexplib";
5267
 
          version = "7.0.5";
 
5778
          version = "109.20.00";
5268
5779
          license =
5269
5780
            OASISLicense.DEP5License
5270
 
              {
5271
 
                 OASISLicense.license = "LGPL";
5272
 
                 exceptions = ["OCaml linking"];
5273
 
                 version = OASISLicense.Version "2.1";
5274
 
                 };
5275
 
          license_file = Some "LICENSE";
5276
 
          copyrights = ["(C) 2005-2011 Jane Street Capital LLC"];
5277
 
          maintainers = [];
5278
 
          authors = ["Markus Mottl"; "Martin Sandin"];
5279
 
          homepage = None;
5280
 
          synopsis = "automated S-expression conversion";
 
5781
              (OASISLicense.DEP5Unit
 
5782
                 {
 
5783
                    OASISLicense.license = "Apache";
 
5784
                    excption = None;
 
5785
                    version = OASISLicense.Version "2.0";
 
5786
                    });
 
5787
          license_file = Some "LICENSE.txt";
 
5788
          copyrights =
 
5789
            [
 
5790
               "(C) 2005-2013 Jane Street Capital LLC <opensource@janestreet.com>"
 
5791
            ];
 
5792
          maintainers =
 
5793
            ["Jane Street Capital LLC <opensource@janestreet.com>"];
 
5794
          authors = ["Jane Street Capital LLC <opensource@janestreet.com>"];
 
5795
          homepage = Some "https://github.com/janestreet/sexplib";
 
5796
          synopsis = "sexplib - automated S-expression conversion";
5281
5797
          description = None;
5282
5798
          categories = [];
5283
5799
          conf_type = (`Configure, "internal", Some "0.3");
5347
5863
                   {
5348
5864
                      lib_modules =
5349
5865
                        [
5350
 
                           "Type";
5351
 
                           "Parser";
5352
 
                           "Lexer";
5353
 
                           "Pre_sexp";
5354
 
                           "Sexp_intf";
5355
 
                           "Sexp";
5356
 
                           "Path";
5357
5866
                           "Conv";
5358
5867
                           "Conv_error";
5359
5868
                           "Exn_magic";
5360
 
                           "Std"
 
5869
                           "Path";
 
5870
                           "Pre_sexp";
 
5871
                           "Sexp";
 
5872
                           "Sexp_intf";
 
5873
                           "Sexp_with_layout";
 
5874
                           "Src_pos";
 
5875
                           "Std";
 
5876
                           "Type";
 
5877
                           "Type_with_layout";
 
5878
                           "Parser";
 
5879
                           "Parser_with_layout";
 
5880
                           "Lexer"
5361
5881
                        ];
5362
5882
                      lib_pack = true;
5363
5883
                      lib_internal_modules = [];
5364
5884
                      lib_findlib_parent = None;
5365
 
                      lib_findlib_name = None;
 
5885
                      lib_findlib_name = Some "sexplib";
5366
5886
                      lib_findlib_containers = [];
5367
5887
                      });
5368
5888
               Library
5375
5895
                      bs_build = [(OASISExpr.EBool true, true)];
5376
5896
                      bs_install = [(OASISExpr.EBool true, true)];
5377
5897
                      bs_path = "syntax";
5378
 
                      bs_compiled_object = Byte;
 
5898
                      bs_compiled_object = Best;
5379
5899
                      bs_build_depends =
5380
5900
                        [
5381
5901
                           FindlibPackage ("camlp4.quotations", None);
5382
5902
                           FindlibPackage ("camlp4.extend", None);
5383
5903
                           FindlibPackage
5384
5904
                             ("type_conv",
5385
 
                               Some (OASISVersion.VGreaterEqual "3.0.5"))
 
5905
                               Some (OASISVersion.VGreaterEqual "109.20.00"))
5386
5906
                        ];
5387
5907
                      bs_build_tools =
5388
5908
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
5403
5923
                      lib_findlib_name = Some "syntax";
5404
5924
                      lib_findlib_containers = [];
5405
5925
                      });
 
5926
               Library
 
5927
                 ({
 
5928
                     cs_name = "sexplib_top";
 
5929
                     cs_data = PropList.Data.create ();
 
5930
                     cs_plugin_data = [];
 
5931
                     },
 
5932
                   {
 
5933
                      bs_build = [(OASISExpr.EBool true, true)];
 
5934
                      bs_install = [(OASISExpr.EBool true, true)];
 
5935
                      bs_path = "top";
 
5936
                      bs_compiled_object = Best;
 
5937
                      bs_build_depends = [];
 
5938
                      bs_build_tools =
 
5939
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
 
5940
                      bs_c_sources = [];
 
5941
                      bs_data_files = [];
 
5942
                      bs_ccopt = [(OASISExpr.EBool true, [])];
 
5943
                      bs_cclib = [(OASISExpr.EBool true, [])];
 
5944
                      bs_dlllib = [(OASISExpr.EBool true, [])];
 
5945
                      bs_dllpath = [(OASISExpr.EBool true, [])];
 
5946
                      bs_byteopt = [(OASISExpr.EBool true, [])];
 
5947
                      bs_nativeopt = [(OASISExpr.EBool true, [])];
 
5948
                      },
 
5949
                   {
 
5950
                      lib_modules = ["Sexplib_install_printers"];
 
5951
                      lib_pack = false;
 
5952
                      lib_internal_modules = [];
 
5953
                      lib_findlib_parent = Some "sexplib";
 
5954
                      lib_findlib_name = Some "top";
 
5955
                      lib_findlib_containers = [];
 
5956
                      });
 
5957
               Executable
 
5958
                 ({
 
5959
                     cs_name = "sexp_test";
 
5960
                     cs_data = PropList.Data.create ();
 
5961
                     cs_plugin_data = [];
 
5962
                     },
 
5963
                   {
 
5964
                      bs_build =
 
5965
                        [
 
5966
                           (OASISExpr.EBool true, false);
 
5967
                           (OASISExpr.EFlag "tests", true)
 
5968
                        ];
 
5969
                      bs_install = [(OASISExpr.EBool true, false)];
 
5970
                      bs_path = "lib_test";
 
5971
                      bs_compiled_object = Byte;
 
5972
                      bs_build_depends = [InternalLibrary "sexplib"];
 
5973
                      bs_build_tools =
 
5974
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
 
5975
                      bs_c_sources = [];
 
5976
                      bs_data_files = [];
 
5977
                      bs_ccopt = [(OASISExpr.EBool true, [])];
 
5978
                      bs_cclib = [(OASISExpr.EBool true, [])];
 
5979
                      bs_dlllib = [(OASISExpr.EBool true, [])];
 
5980
                      bs_dllpath = [(OASISExpr.EBool true, [])];
 
5981
                      bs_byteopt = [(OASISExpr.EBool true, [])];
 
5982
                      bs_nativeopt = [(OASISExpr.EBool true, [])];
 
5983
                      },
 
5984
                   {exec_custom = false; exec_main_is = "sexp_test.ml"; });
5406
5985
               Executable
5407
5986
                 ({
5408
5987
                     cs_name = "conv_test";
5435
6014
                      bs_nativeopt = [(OASISExpr.EBool true, [])];
5436
6015
                      },
5437
6016
                   {exec_custom = false; exec_main_is = "conv_test.ml"; });
5438
 
               Library
5439
 
                 ({
5440
 
                     cs_name = "sexplib_top";
5441
 
                     cs_data = PropList.Data.create ();
5442
 
                     cs_plugin_data = [];
5443
 
                     },
5444
 
                   {
5445
 
                      bs_build = [(OASISExpr.EBool true, true)];
5446
 
                      bs_install = [(OASISExpr.EBool true, true)];
5447
 
                      bs_path = "top";
5448
 
                      bs_compiled_object = Best;
5449
 
                      bs_build_depends = [];
5450
 
                      bs_build_tools =
5451
 
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
5452
 
                      bs_c_sources = [];
5453
 
                      bs_data_files = [];
5454
 
                      bs_ccopt = [(OASISExpr.EBool true, [])];
5455
 
                      bs_cclib = [(OASISExpr.EBool true, [])];
5456
 
                      bs_dlllib = [(OASISExpr.EBool true, [])];
5457
 
                      bs_dllpath = [(OASISExpr.EBool true, [])];
5458
 
                      bs_byteopt = [(OASISExpr.EBool true, [])];
5459
 
                      bs_nativeopt = [(OASISExpr.EBool true, [])];
5460
 
                      },
5461
 
                   {
5462
 
                      lib_modules = ["Install_printers"];
5463
 
                      lib_pack = false;
5464
 
                      lib_internal_modules = [];
5465
 
                      lib_findlib_parent = Some "sexplib";
5466
 
                      lib_findlib_name = Some "top";
5467
 
                      lib_findlib_containers = [];
5468
 
                      });
5469
6017
               Test
5470
6018
                 ({
5471
6019
                     cs_name = "sexp";
5487
6035
                      test_working_directory = Some "lib_test";
5488
6036
                      test_run =
5489
6037
                        [
5490
 
                           (OASISExpr.EBool true, false);
5491
 
                           (OASISExpr.EFlag "tests", true)
 
6038
                           (OASISExpr.ENot (OASISExpr.EFlag "tests"), false);
 
6039
                           (OASISExpr.EFlag "tests", false);
 
6040
                           (OASISExpr.EAnd
 
6041
                              (OASISExpr.EFlag "tests",
 
6042
                                OASISExpr.EFlag "tests"),
 
6043
                             true)
5492
6044
                        ];
5493
6045
                      test_tools =
5494
6046
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
5511
6063
                      test_working_directory = Some "lib_test";
5512
6064
                      test_run =
5513
6065
                        [
5514
 
                           (OASISExpr.EBool true, false);
5515
 
                           (OASISExpr.EFlag "tests", true)
 
6066
                           (OASISExpr.ENot (OASISExpr.EFlag "tests"), false);
 
6067
                           (OASISExpr.EFlag "tests", false);
 
6068
                           (OASISExpr.EAnd
 
6069
                              (OASISExpr.EFlag "tests",
 
6070
                                OASISExpr.EFlag "tests"),
 
6071
                             true)
5516
6072
                        ];
5517
6073
                      test_tools =
5518
6074
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
5519
6075
                      });
5520
 
               Executable
5521
 
                 ({
5522
 
                     cs_name = "sexp_test";
5523
 
                     cs_data = PropList.Data.create ();
5524
 
                     cs_plugin_data = [];
5525
 
                     },
5526
 
                   {
5527
 
                      bs_build =
5528
 
                        [
5529
 
                           (OASISExpr.EBool true, false);
5530
 
                           (OASISExpr.EFlag "tests", true)
5531
 
                        ];
5532
 
                      bs_install = [(OASISExpr.EBool true, false)];
5533
 
                      bs_path = "lib_test";
5534
 
                      bs_compiled_object = Byte;
5535
 
                      bs_build_depends = [InternalLibrary "sexplib"];
5536
 
                      bs_build_tools =
5537
 
                        [ExternalTool "ocamlbuild"; ExternalTool "camlp4o"];
5538
 
                      bs_c_sources = [];
5539
 
                      bs_data_files = [];
5540
 
                      bs_ccopt = [(OASISExpr.EBool true, [])];
5541
 
                      bs_cclib = [(OASISExpr.EBool true, [])];
5542
 
                      bs_dlllib = [(OASISExpr.EBool true, [])];
5543
 
                      bs_dllpath = [(OASISExpr.EBool true, [])];
5544
 
                      bs_byteopt = [(OASISExpr.EBool true, [])];
5545
 
                      bs_nativeopt = [(OASISExpr.EBool true, [])];
5546
 
                      },
5547
 
                   {exec_custom = false; exec_main_is = "sexp_test.ml"; });
5548
6076
               Doc
5549
6077
                 ({
5550
6078
                     cs_name = "sexplib";
5560
6088
                           };
5561
6089
                      doc_build =
5562
6090
                        [
5563
 
                           (OASISExpr.EBool true, false);
 
6091
                           (OASISExpr.ENot (OASISExpr.EFlag "docs"), false);
5564
6092
                           (OASISExpr.EFlag "docs", true)
5565
6093
                        ];
5566
6094
                      doc_install = [(OASISExpr.EBool true, true)];
5587
6115
          schema_data = PropList.Data.create ();
5588
6116
          plugin_data = [];
5589
6117
          };
5590
 
     version = "0.3.0~rc2";
 
6118
     oasis_fn = Some "_oasis";
 
6119
     oasis_version = "0.3.0";
 
6120
     oasis_digest = Some ":\208\234\234\206xK\195b\004C\015\2405\145\191";
 
6121
     oasis_exec = None;
 
6122
     oasis_setup_args = [];
 
6123
     setup_update = false;
5591
6124
     };;
5592
6125
 
5593
6126
let setup () = BaseSetup.setup setup_t;;
5594
6127
 
5595
 
# 5596 "setup.ml"
 
6128
# 6131 "setup.ml"
5596
6129
(* OASIS_STOP *)
5597
 
let () = setup ();;
 
6130
let () = setup ()