Project

General

Profile

Revision 9603460e setup.ml

View differences:

setup.ml
1 1
(* setup.ml generated for the first time by OASIS v0.2.0 *)
2 2

  
3 3
(* OASIS_START *)
4
(* DO NOT EDIT (digest: 243f7ef4ca5fa7182acbe98e77d9c7f4) *)
4
(* DO NOT EDIT (digest: d0957d7fdd9eb6ce163190fb18a724b8) *)
5 5
(*
6
   Regenerated by OASIS v0.3.0
6
   Regenerated by OASIS v0.4.4
7 7
   Visit http://oasis.forge.ocamlcore.org for more information and
8 8
   documentation about functions used in this file.
9 9
*)
10 10
module OASISGettext = struct
11
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISGettext.ml" *)
11
(* # 22 "src/oasis/OASISGettext.ml" *)
12

  
12 13

  
13 14
  let ns_ str =
14 15
    str
15 16

  
17

  
16 18
  let s_ str =
17 19
    str
18 20

  
19
  let f_ (str : ('a, 'b, 'c, 'd) format4) =
21

  
22
  let f_ (str: ('a, 'b, 'c, 'd) format4) =
20 23
    str
21 24

  
25

  
22 26
  let fn_ fmt1 fmt2 n =
23 27
    if n = 1 then
24 28
      fmt1^^""
25 29
    else
26 30
      fmt2^^""
27 31

  
32

  
28 33
  let init =
29 34
    []
30 35

  
36

  
31 37
end
32 38

  
33 39
module OASISContext = struct
34
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISContext.ml" *)
40
(* # 22 "src/oasis/OASISContext.ml" *)
41

  
35 42

  
36 43
  open OASISGettext
37 44

  
45

  
38 46
  type level =
39 47
    [ `Debug
40 48
    | `Info
41 49
    | `Warning
42 50
    | `Error]
43 51

  
52

  
44 53
  type t =
45 54
    {
55
      (* TODO: replace this by a proplist. *)
46 56
      quiet:                 bool;
47 57
      info:                  bool;
48 58
      debug:                 bool;
......
51 61
      printf:                level -> string -> unit;
52 62
    }
53 63

  
64

  
54 65
  let printf lvl str =
55 66
    let beg =
56 67
      match lvl with
......
61 72
    in
62 73
      prerr_endline (beg^str)
63 74

  
75

  
64 76
  let default =
65 77
    ref
66 78
      {
......
72 84
        printf                = printf;
73 85
      }
74 86

  
87

  
75 88
  let quiet =
76 89
    {!default with quiet = true}
77 90

  
78 91

  
79
  let args () =
92
  let fspecs () =
93
    (* TODO: don't act on default. *)
94
    let ignore_plugins = ref false in
80 95
    ["-quiet",
81 96
     Arg.Unit (fun () -> default := {!default with quiet = true}),
82
     (s_ " Run quietly");
97
     s_ " Run quietly";
83 98

  
84 99
     "-info",
85 100
     Arg.Unit (fun () -> default := {!default with info = true}),
86
     (s_ " Display information message");
101
     s_ " Display information message";
87 102

  
88 103

  
89 104
     "-debug",
90 105
     Arg.Unit (fun () -> default := {!default with debug = true}),
91
     (s_ " Output debug message")]
106
     s_ " Output debug message";
107

  
108
     "-ignore-plugins",
109
     Arg.Set ignore_plugins,
110
     s_ " Ignore plugin's field.";
111

  
112
     "-C",
113
     (* TODO: remove this chdir. *)
114
     Arg.String (fun str -> Sys.chdir str),
115
     s_ "dir Change directory before running."],
116
    fun () -> {!default with ignore_plugins = !ignore_plugins}
92 117
end
93 118

  
94 119
module OASISString = struct
95
(* # 1 "/build/buildd/oasis-0.3.0/src/oasis/OASISString.ml" *)
96

  
120
(* # 22 "src/oasis/OASISString.ml" *)
97 121

  
98 122

  
99 123
  (** Various string utilities.
100
     
124

  
101 125
      Mostly inspired by extlib and batteries ExtString and BatString libraries.
102 126

  
103 127
      @author Sylvain Le Gall
104 128
    *)
105 129

  
130

  
106 131
  let nsplitf str f =
107 132
    if str = "" then
108 133
      []
......
123 148
        push ();
124 149
        List.rev !lst
125 150

  
151

  
126 152
  (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
127 153
      separator.
128 154
    *)
129 155
  let nsplit str c =
130 156
    nsplitf str ((=) c)
131 157

  
158

  
132 159
  let find ~what ?(offset=0) str =
133 160
    let what_idx = ref 0 in
134
    let str_idx = ref offset in 
135
      while !str_idx < String.length str && 
161
    let str_idx = ref offset in
162
      while !str_idx < String.length str &&
136 163
            !what_idx < String.length what do
137 164
        if str.[!str_idx] = what.[!what_idx] then
138 165
          incr what_idx
......
142 169
      done;
143 170
      if !what_idx <> String.length what then
144 171
        raise Not_found
145
      else 
172
      else
146 173
        !str_idx - !what_idx
147 174

  
148
  let sub_start str len = 
175

  
176
  let sub_start str len =
149 177
    let str_len = String.length str in
150 178
    if len >= str_len then
151 179
      ""
152 180
    else
153 181
      String.sub str len (str_len - len)
154 182

  
183

  
155 184
  let sub_end ?(offset=0) str len =
156 185
    let str_len = String.length str in
157 186
    if len >= str_len then
......
159 188
    else
160 189
      String.sub str 0 (str_len - len)
161 190

  
191

  
162 192
  let starts_with ~what ?(offset=0) str =
163 193
    let what_idx = ref 0 in
164 194
    let str_idx = ref offset in
165 195
    let ok = ref true in
166 196
      while !ok &&
167
            !str_idx < String.length str && 
197
            !str_idx < String.length str &&
168 198
            !what_idx < String.length what do
169 199
        if str.[!str_idx] = what.[!what_idx] then
170 200
          incr what_idx
......
174 204
      done;
175 205
      if !what_idx = String.length what then
176 206
        true
177
      else 
207
      else
178 208
        false
179 209

  
210

  
180 211
  let strip_starts_with ~what str =
181 212
    if starts_with ~what str then
182 213
      sub_start str (String.length what)
183 214
    else
184 215
      raise Not_found
185 216

  
217

  
186 218
  let ends_with ~what ?(offset=0) str =
187 219
    let what_idx = ref ((String.length what) - 1) in
188 220
    let str_idx = ref ((String.length str) - 1) in
189 221
    let ok = ref true in
190 222
      while !ok &&
191
            offset <= !str_idx && 
223
            offset <= !str_idx &&
192 224
            0 <= !what_idx do
193 225
        if str.[!str_idx] = what.[!what_idx] then
194 226
          decr what_idx
......
198 230
      done;
199 231
      if !what_idx = -1 then
200 232
        true
201
      else 
233
      else
202 234
        false
203 235

  
236

  
204 237
  let strip_ends_with ~what str =
205 238
    if ends_with ~what str then
206 239
      sub_end str (String.length what)
207 240
    else
208 241
      raise Not_found
209 242

  
243

  
210 244
  let replace_chars f s =
211 245
    let buf = String.make (String.length s) 'X' in
212 246
      for i = 0 to String.length s - 1 do
......
214 248
      done;
215 249
      buf
216 250

  
251

  
217 252
end
218 253

  
219 254
module OASISUtils = struct
220
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISUtils.ml" *)
255
(* # 22 "src/oasis/OASISUtils.ml" *)
256

  
221 257

  
222 258
  open OASISGettext
223 259

  
224
  module MapString = Map.Make(String)
225 260

  
226
  let map_string_of_assoc assoc =
227
    List.fold_left
228
      (fun acc (k, v) -> MapString.add k v acc)
229
      MapString.empty
230
      assoc
261
  module MapExt =
262
  struct
263
    module type S =
264
    sig
265
      include Map.S
266
      val add_list: 'a t -> (key * 'a) list -> 'a t
267
      val of_list: (key * 'a) list -> 'a t
268
      val to_list: 'a t -> (key * 'a) list
269
    end
270

  
271
    module Make (Ord: Map.OrderedType) =
272
    struct
273
      include Map.Make(Ord)
274

  
275
      let rec add_list t =
276
        function
277
          | (k, v) :: tl -> add_list (add k v t) tl
278
          | [] -> t
231 279

  
232
  module SetString = Set.Make(String)
280
      let of_list lst = add_list empty lst
233 281

  
234
  let set_string_add_list st lst =
235
    List.fold_left
236
      (fun acc e -> SetString.add e acc)
237
      st
238
      lst
282
      let to_list t = fold (fun k v acc -> (k, v) :: acc) t []
283
    end
284
  end
285

  
286

  
287
  module MapString = MapExt.Make(String)
288

  
289

  
290
  module SetExt  =
291
  struct
292
    module type S =
293
    sig
294
      include Set.S
295
      val add_list: t -> elt list -> t
296
      val of_list: elt list -> t
297
      val to_list: t -> elt list
298
    end
299

  
300
    module Make (Ord: Set.OrderedType) =
301
    struct
302
      include Set.Make(Ord)
303

  
304
      let rec add_list t =
305
        function
306
          | e :: tl -> add_list (add e t) tl
307
          | [] -> t
239 308

  
240
  let set_string_of_list =
241
    set_string_add_list
242
      SetString.empty
309
      let of_list lst = add_list empty lst
310

  
311
      let to_list = elements
312
    end
313
  end
314

  
315

  
316
  module SetString = SetExt.Make(String)
243 317

  
244 318

  
245 319
  let compare_csl s1 s2 =
246 320
    String.compare (String.lowercase s1) (String.lowercase s2)
247 321

  
322

  
248 323
  module HashStringCsl =
249 324
    Hashtbl.Make
250 325
      (struct
......
257 332
           Hashtbl.hash (String.lowercase s)
258 333
       end)
259 334

  
335
  module SetStringCsl =
336
    SetExt.Make
337
      (struct
338
         type t = string
339
         let compare = compare_csl
340
       end)
341

  
342

  
260 343
  let varname_of_string ?(hyphen='_') s =
261 344
    if String.length s = 0 then
262 345
      begin
......
287 370
          String.lowercase buf
288 371
      end
289 372

  
373

  
290 374
  let varname_concat ?(hyphen='_') p s =
291 375
    let what = String.make 1 hyphen in
292 376
    let p =
......
307 391
  let is_varname str =
308 392
    str = varname_of_string str
309 393

  
394

  
310 395
  let failwithf fmt = Printf.ksprintf failwith fmt
311 396

  
397

  
312 398
end
313 399

  
314 400
module PropList = struct
315
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/PropList.ml" *)
401
(* # 22 "src/oasis/PropList.ml" *)
402

  
316 403

  
317 404
  open OASISGettext
318 405

  
406

  
319 407
  type name = string
320 408

  
409

  
321 410
  exception Not_set of name * string option
322 411
  exception No_printer of name
323 412
  exception Unknown_field of name * name
324 413

  
414

  
325 415
  let () =
326 416
    Printexc.register_printer
327 417
      (function
328 418
         | Not_set (nm, Some rsn) ->
329
             Some 
419
             Some
330 420
               (Printf.sprintf (f_ "Field '%s' is not set: %s") nm rsn)
331 421
         | Not_set (nm, None) ->
332
             Some 
422
             Some
333 423
               (Printf.sprintf (f_ "Field '%s' is not set") nm)
334 424
         | No_printer nm ->
335 425
             Some
336 426
               (Printf.sprintf (f_ "No default printer for value %s") nm)
337 427
         | Unknown_field (nm, schm) ->
338
             Some 
339
               (Printf.sprintf (f_ "Field %s is not defined in schema %s") nm schm)
428
             Some
429
               (Printf.sprintf
430
                  (f_ "Field %s is not defined in schema %s") nm schm)
340 431
         | _ ->
341 432
             None)
342 433

  
434

  
343 435
  module Data =
344 436
  struct
345

  
346 437
    type t =
347 438
        (name, unit -> unit) Hashtbl.t
348 439

  
......
352 443
    let clear t =
353 444
      Hashtbl.clear t
354 445

  
355
(* # 71 "/build/buildd/oasis-0.3.0/src/oasis/PropList.ml" *)
446

  
447
(* # 78 "src/oasis/PropList.ml" *)
356 448
  end
357 449

  
450

  
358 451
  module Schema =
359 452
  struct
360

  
361 453
    type ('ctxt, 'extra) value =
362 454
        {
363 455
          get:   Data.t -> string;
......
445 537
      t.name
446 538
  end
447 539

  
540

  
448 541
  module Field =
449 542
  struct
450

  
451 543
    type ('ctxt, 'value, 'extra) t =
452 544
        {
453 545
          set:    Data.t -> ?context:'ctxt -> 'value -> unit;
......
577 669

  
578 670
    let fgets data t =
579 671
      t.gets data
580

  
581 672
  end
582 673

  
674

  
583 675
  module FieldRO =
584 676
  struct
585

  
586 677
    let create ?schema ?name ?parse ?print ?default ?update ?help extra =
587 678
      let fld =
588 679
        Field.create ?schema ?name ?parse ?print ?default ?update ?help extra
589 680
      in
590 681
        fun data -> Field.fget data fld
591

  
592 682
  end
593 683
end
594 684

  
595 685
module OASISMessage = struct
596
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISMessage.ml" *)
686
(* # 22 "src/oasis/OASISMessage.ml" *)
597 687

  
598 688

  
599 689
  open OASISGettext
600 690
  open OASISContext
601 691

  
692

  
602 693
  let generic_message ~ctxt lvl fmt =
603 694
    let cond =
604 695
      if ctxt.quiet then
......
617 708
             end)
618 709
        fmt
619 710

  
711

  
620 712
  let debug ~ctxt fmt =
621 713
    generic_message ~ctxt `Debug fmt
622 714

  
715

  
623 716
  let info ~ctxt fmt =
624 717
    generic_message ~ctxt `Info fmt
625 718

  
719

  
626 720
  let warning ~ctxt fmt =
627 721
    generic_message ~ctxt `Warning fmt
628 722

  
723

  
629 724
  let error ~ctxt fmt =
630 725
    generic_message ~ctxt `Error fmt
631 726

  
632 727
end
633 728

  
634 729
module OASISVersion = struct
635
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISVersion.ml" *)
730
(* # 22 "src/oasis/OASISVersion.ml" *)
731

  
636 732

  
637 733
  open OASISGettext
638 734

  
639 735

  
640 736

  
737

  
738

  
641 739
  type s = string
642 740

  
643
  type t = string 
741

  
742
  type t = string
743

  
644 744

  
645 745
  type comparator =
646 746
    | VGreater of t
......
650 750
    | VLesserEqual of t
651 751
    | VOr of  comparator * comparator
652 752
    | VAnd of comparator * comparator
653
    
753

  
754

  
654 755

  
655 756
  (* Range of allowed characters *)
656 757
  let is_digit c =
657 758
    '0' <= c && c <= '9'
658 759

  
760

  
659 761
  let is_alpha c =
660 762
    ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
661 763

  
764

  
662 765
  let is_special =
663 766
    function
664 767
      | '.' | '+' | '-' | '~' -> true
665 768
      | _ -> false
666 769

  
770

  
667 771
  let rec version_compare v1 v2 =
668 772
    if v1 <> "" || v2 <> "" then
669 773
      begin
......
707 811
              while !p < String.length v && is_digit v.[!p] do
708 812
                incr p
709 813
              done;
710
              let substr = 
814
              let substr =
711 815
                String.sub v !p ((String.length v) - !p)
712
              in 
713
              let res = 
714
                match String.sub v start_p (!p - start_p) with 
816
              in
817
              let res =
818
                match String.sub v start_p (!p - start_p) with
715 819
                  | "" -> 0
716 820
                  | s -> int_of_string s
717 821
              in
......
747 851

  
748 852
  let version_of_string str = str
749 853

  
854

  
750 855
  let string_of_version t = t
751 856

  
857

  
858
  let version_compare_string s1 s2 =
859
    version_compare (version_of_string s1) (version_of_string s2)
860

  
861

  
752 862
  let chop t =
753 863
    try
754 864
      let pos =
......
758 868
    with Not_found ->
759 869
      t
760 870

  
871

  
761 872
  let rec comparator_apply v op =
762 873
    match op with
763 874
      | VGreater cv ->
......
775 886
      | VAnd (op1, op2) ->
776 887
          (comparator_apply v op1) && (comparator_apply v op2)
777 888

  
889

  
778 890
  let rec string_of_comparator =
779 891
    function
780 892
      | VGreater v  -> "> "^(string_of_version v)
......
787 899
      | VAnd (c1, c2) ->
788 900
          (string_of_comparator c1)^" && "^(string_of_comparator c2)
789 901

  
902

  
790 903
  let rec varname_of_comparator =
791 904
    let concat p v =
792 905
      OASISUtils.varname_concat
......
805 918
        | VAnd (c1, c2) ->
806 919
            (varname_of_comparator c1)^"_and_"^(varname_of_comparator c2)
807 920

  
808
  let version_0_3_or_after t =
809
    comparator_apply t (VGreaterEqual (string_of_version "0.3"))
921

  
922
  let rec comparator_ge v' =
923
    let cmp v = version_compare v v' >= 0 in
924
    function
925
      | VEqual v
926
      | VGreaterEqual v
927
      | VGreater v -> cmp v
928
      | VLesserEqual _
929
      | VLesser _ -> false
930
      | VOr (c1, c2) -> comparator_ge v' c1 || comparator_ge v' c2
931
      | VAnd (c1, c2) -> comparator_ge v' c1 && comparator_ge v' c2
932

  
810 933

  
811 934
end
812 935

  
813 936
module OASISLicense = struct
814
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISLicense.ml" *)
937
(* # 22 "src/oasis/OASISLicense.ml" *)
938

  
815 939

  
816 940
  (** License for _oasis fields
817 941
      @author Sylvain Le Gall
......
819 943

  
820 944

  
821 945

  
822
  type license = string 
823 946

  
824
  type license_exception = string 
947

  
948
  type license = string
949

  
950

  
951
  type license_exception = string
952

  
825 953

  
826 954
  type license_version =
827 955
    | Version of OASISVersion.t
828 956
    | VersionOrLater of OASISVersion.t
829 957
    | NoVersion
830
    
958

  
959

  
831 960

  
832 961
  type license_dep_5_unit =
833 962
    {
......
835 964
      excption:  license_exception option;
836 965
      version:   license_version;
837 966
    }
838
    
967

  
968

  
839 969

  
840 970
  type license_dep_5 =
841 971
    | DEP5Unit of license_dep_5_unit
842 972
    | DEP5Or of license_dep_5 list
843 973
    | DEP5And of license_dep_5 list
844
    
974

  
845 975

  
846 976
  type t =
847 977
    | DEP5License of license_dep_5
848 978
    | OtherLicense of string (* URL *)
849
    
979

  
980

  
850 981

  
851 982
end
852 983

  
853 984
module OASISExpr = struct
854
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISExpr.ml" *)
985
(* # 22 "src/oasis/OASISExpr.ml" *)
986

  
987

  
855 988

  
856 989

  
857 990

  
858 991
  open OASISGettext
859 992

  
860
  type test = string 
861 993

  
862
  type flag = string 
994
  type test = string
995

  
996

  
997
  type flag = string
998

  
863 999

  
864 1000
  type t =
865 1001
    | EBool of bool
......
868 1004
    | EOr of t * t
869 1005
    | EFlag of flag
870 1006
    | ETest of test * string
871
    
872 1007

  
873
  type 'a choices = (t * 'a) list 
1008

  
1009

  
1010
  type 'a choices = (t * 'a) list
1011

  
874 1012

  
875 1013
  let eval var_get t =
876 1014
    let rec eval' =
......
902 1040
    in
903 1041
      eval' t
904 1042

  
1043

  
905 1044
  let choose ?printer ?name var_get lst =
906 1045
    let rec choose_aux =
907 1046
      function
......
938 1077
    in
939 1078
      choose_aux (List.rev lst)
940 1079

  
1080

  
1081
end
1082

  
1083
module OASISText = struct
1084
(* # 22 "src/oasis/OASISText.ml" *)
1085

  
1086

  
1087

  
1088
  type elt =
1089
    | Para of string
1090
    | Verbatim of string
1091
    | BlankLine
1092

  
1093

  
1094
  type t = elt list
1095

  
941 1096
end
942 1097

  
943 1098
module OASISTypes = struct
944
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISTypes.ml" *)
1099
(* # 22 "src/oasis/OASISTypes.ml" *)
1100

  
1101

  
1102

  
945 1103

  
946 1104

  
1105
  type name          = string
1106
  type package_name  = string
1107
  type url           = string
1108
  type unix_dirname  = string
1109
  type unix_filename = string
1110
  type host_dirname  = string
1111
  type host_filename = string
1112
  type prog          = string
1113
  type arg           = string
1114
  type args          = string list
1115
  type command_line  = (prog * arg list)
947 1116

  
948 1117

  
949
  type name          = string 
950
  type package_name  = string 
951
  type url           = string 
952
  type unix_dirname  = string 
953
  type unix_filename = string 
954
  type host_dirname  = string 
955
  type host_filename = string 
956
  type prog          = string 
957
  type arg           = string 
958
  type args          = string list 
959
  type command_line  = (prog * arg list) 
1118
  type findlib_name = string
1119
  type findlib_full = string
960 1120

  
961
  type findlib_name = string 
962
  type findlib_full = string 
963 1121

  
964 1122
  type compiled_object =
965 1123
    | Byte
966 1124
    | Native
967 1125
    | Best
968
    
1126

  
1127

  
969 1128

  
970 1129
  type dependency =
971 1130
    | FindlibPackage of findlib_full * OASISVersion.comparator option
972 1131
    | InternalLibrary of name
973
    
1132

  
1133

  
974 1134

  
975 1135
  type tool =
976 1136
    | ExternalTool of name
977 1137
    | InternalExecutable of name
978
    
1138

  
1139

  
979 1140

  
980 1141
  type vcs =
981 1142
    | Darcs
......
987 1148
    | Arch
988 1149
    | Monotone
989 1150
    | OtherVCS of url
990
    
1151

  
1152

  
991 1153

  
992 1154
  type plugin_kind =
993 1155
      [  `Configure
......
998 1160
       | `Extra
999 1161
      ]
1000 1162

  
1163

  
1001 1164
  type plugin_data_purpose =
1002 1165
      [  `Configure
1003 1166
       | `Build
......
1012 1175
       | `Other of string
1013 1176
      ]
1014 1177

  
1015
  type 'a plugin = 'a * name * OASISVersion.t option 
1178

  
1179
  type 'a plugin = 'a * name * OASISVersion.t option
1180

  
1016 1181

  
1017 1182
  type all_plugin = plugin_kind plugin
1018 1183

  
1184

  
1019 1185
  type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list
1020 1186

  
1021
(* # 102 "/build/buildd/oasis-0.3.0/src/oasis/OASISTypes.ml" *)
1022 1187

  
1023
  type 'a conditional = 'a OASISExpr.choices 
1188
(* # 115 "src/oasis/OASISTypes.ml" *)
1189

  
1190

  
1191
  type 'a conditional = 'a OASISExpr.choices
1192

  
1024 1193

  
1025 1194
  type custom =
1026 1195
      {
1027 1196
        pre_command:  (command_line option) conditional;
1028 1197
        post_command: (command_line option) conditional;
1029 1198
      }
1030
      
1199

  
1200

  
1031 1201

  
1032 1202
  type common_section =
1033 1203
      {
......
1035 1205
        cs_data: PropList.Data.t;
1036 1206
        cs_plugin_data: plugin_data;
1037 1207
      }
1038
      
1208

  
1209

  
1039 1210

  
1040 1211
  type build_section =
1041 1212
      {
......
1054 1225
        bs_byteopt:         args conditional;
1055 1226
        bs_nativeopt:       args conditional;
1056 1227
      }
1057
      
1228

  
1229

  
1058 1230

  
1059 1231
  type library =
1060 1232
      {
......
1064 1236
        lib_findlib_parent:     findlib_name option;
1065 1237
        lib_findlib_name:       findlib_name option;
1066 1238
        lib_findlib_containers: findlib_name list;
1067
      } 
1239
      }
1240

  
1241

  
1242
  type object_ =
1243
      {
1244
        obj_modules:            string list;
1245
        obj_findlib_fullname:   findlib_name list option;
1246
      }
1247

  
1068 1248

  
1069 1249
  type executable =
1070 1250
      {
1071 1251
        exec_custom:          bool;
1072 1252
        exec_main_is:         unix_filename;
1073
      } 
1253
      }
1254

  
1074 1255

  
1075 1256
  type flag =
1076 1257
      {
1077 1258
        flag_description:  string option;
1078 1259
        flag_default:      bool conditional;
1079
      } 
1260
      }
1261

  
1080 1262

  
1081 1263
  type source_repository =
1082 1264
      {
......
1087 1269
        src_repo_branch:      string option;
1088 1270
        src_repo_tag:         string option;
1089 1271
        src_repo_subdir:      unix_filename option;
1090
      } 
1272
      }
1273

  
1091 1274

  
1092 1275
  type test =
1093 1276
      {
......
1097 1280
        test_working_directory:  unix_filename option;
1098 1281
        test_run:                bool conditional;
1099 1282
        test_tools:              tool list;
1100
      } 
1283
      }
1284

  
1101 1285

  
1102 1286
  type doc_format =
1103 1287
    | HTML of unix_filename
......
1107 1291
    | Info of unix_filename
1108 1292
    | DVI
1109 1293
    | OtherDoc
1110
    
1294

  
1295

  
1111 1296

  
1112 1297
  type doc =
1113 1298
      {
......
1122 1307
        doc_format:      doc_format;
1123 1308
        doc_data_files:  (unix_filename * unix_filename option) list;
1124 1309
        doc_build_tools: tool list;
1125
      } 
1310
      }
1311

  
1312

  
1313
  type section =
1314
    | Library    of common_section * build_section * library
1315
    | Object     of common_section * build_section * object_
1316
    | Executable of common_section * build_section * executable
1317
    | Flag       of common_section * flag
1318
    | SrcRepo    of common_section * source_repository
1319
    | Test       of common_section * test
1320
    | Doc        of common_section * doc
1321

  
1322

  
1323

  
1324
  type section_kind =
1325
      [ `Library | `Object | `Executable | `Flag | `SrcRepo | `Test | `Doc ]
1326

  
1327

  
1328
  type package =
1329
      {
1330
        oasis_version:          OASISVersion.t;
1331
        ocaml_version:          OASISVersion.comparator option;
1332
        findlib_version:        OASISVersion.comparator option;
1333
        alpha_features:         string list;
1334
        beta_features:          string list;
1335
        name:                   package_name;
1336
        version:                OASISVersion.t;
1337
        license:                OASISLicense.t;
1338
        license_file:           unix_filename option;
1339
        copyrights:             string list;
1340
        maintainers:            string list;
1341
        authors:                string list;
1342
        homepage:               url option;
1343
        synopsis:               string;
1344
        description:            OASISText.t option;
1345
        categories:             url list;
1346

  
1347
        conf_type:              [`Configure] plugin;
1348
        conf_custom:            custom;
1349

  
1350
        build_type:             [`Build] plugin;
1351
        build_custom:           custom;
1352

  
1353
        install_type:           [`Install] plugin;
1354
        install_custom:         custom;
1355
        uninstall_custom:       custom;
1356

  
1357
        clean_custom:           custom;
1358
        distclean_custom:       custom;
1359

  
1360
        files_ab:               unix_filename list;
1361
        sections:               section list;
1362
        plugins:                [`Extra] plugin list;
1363
        disable_oasis_section:  unix_filename list;
1364
        schema_data:            PropList.Data.t;
1365
        plugin_data:            plugin_data;
1366
      }
1367

  
1368

  
1369
end
1370

  
1371
module OASISFeatures = struct
1372
(* # 22 "src/oasis/OASISFeatures.ml" *)
1373

  
1374
  open OASISTypes
1375
  open OASISUtils
1376
  open OASISGettext
1377
  open OASISVersion
1378

  
1379
  module MapPlugin =
1380
    Map.Make
1381
      (struct
1382
         type t = plugin_kind * name
1383
         let compare = Pervasives.compare
1384
       end)
1385

  
1386
  module Data =
1387
  struct
1388
    type t =
1389
        {
1390
          oasis_version: OASISVersion.t;
1391
          plugin_versions: OASISVersion.t option MapPlugin.t;
1392
          alpha_features: string list;
1393
          beta_features: string list;
1394
        }
1395

  
1396
    let create oasis_version alpha_features beta_features =
1397
      {
1398
        oasis_version = oasis_version;
1399
        plugin_versions = MapPlugin.empty;
1400
        alpha_features = alpha_features;
1401
        beta_features = beta_features
1402
      }
1403

  
1404
    let of_package pkg =
1405
      create
1406
        pkg.OASISTypes.oasis_version
1407
        pkg.OASISTypes.alpha_features
1408
        pkg.OASISTypes.beta_features
1409

  
1410
    let add_plugin (plugin_kind, plugin_name, plugin_version) t =
1411
      {t with
1412
           plugin_versions = MapPlugin.add
1413
                               (plugin_kind, plugin_name)
1414
                               plugin_version
1415
                               t.plugin_versions}
1416

  
1417
    let plugin_version plugin_kind plugin_name t =
1418
      MapPlugin.find (plugin_kind, plugin_name) t.plugin_versions
1419

  
1420
    let to_string t =
1421
      Printf.sprintf
1422
        "oasis_version: %s; alpha_features: %s; beta_features: %s; \
1423
         plugins_version: %s"
1424
        (OASISVersion.string_of_version t.oasis_version)
1425
        (String.concat ", " t.alpha_features)
1426
        (String.concat ", " t.beta_features)
1427
        (String.concat ", "
1428
           (MapPlugin.fold
1429
              (fun (_, plg) ver_opt acc ->
1430
                 (plg^
1431
                  (match ver_opt with
1432
                     | Some v ->
1433
                         " "^(OASISVersion.string_of_version v)
1434
                     | None -> ""))
1435
                 :: acc)
1436
              t.plugin_versions []))
1437
  end
1438

  
1439
  type origin =
1440
    | Field of string * string
1441
    | Section of string
1442
    | NoOrigin
1443

  
1444
  type stage = Alpha | Beta
1445

  
1446

  
1447
  let string_of_stage =
1448
    function
1449
      | Alpha -> "alpha"
1450
      | Beta -> "beta"
1451

  
1452

  
1453
  let field_of_stage =
1454
    function
1455
      | Alpha -> "AlphaFeatures"
1456
      | Beta -> "BetaFeatures"
1457

  
1458
  type publication = InDev of stage | SinceVersion of OASISVersion.t
1459

  
1460
  type t =
1461
      {
1462
        name: string;
1463
        plugin: all_plugin option;
1464
        publication: publication;
1465
        description: unit -> string;
1466
      }
1467

  
1468
  (* TODO: mutex protect this. *)
1469
  let all_features = Hashtbl.create 13
1470

  
1471

  
1472
  let since_version ver_str = SinceVersion (version_of_string ver_str)
1473
  let alpha = InDev Alpha
1474
  let beta = InDev Beta
1475

  
1476

  
1477
  let to_string t =
1478
    Printf.sprintf
1479
      "feature: %s; plugin: %s; publication: %s"
1480
      t.name
1481
      (match t.plugin with
1482
         | None -> "<none>"
1483
         | Some (_, nm, _) -> nm)
1484
      (match t.publication with
1485
         | InDev stage -> string_of_stage stage
1486
         | SinceVersion ver -> ">= "^(OASISVersion.string_of_version ver))
1487

  
1488
  let data_check t data origin =
1489
    let no_message = "no message" in
1490

  
1491
    let check_feature features stage =
1492
      let has_feature = List.mem t.name features in
1493
      if not has_feature then
1494
        match origin with
1495
          | Field (fld, where) ->
1496
              Some
1497
                (Printf.sprintf
1498
                   (f_ "Field %s in %s is only available when feature %s \
1499
                        is in field %s.")
1500
                   fld where t.name (field_of_stage stage))
1501
          | Section sct ->
1502
              Some
1503
                (Printf.sprintf
1504
                   (f_ "Section %s is only available when features %s \
1505
                        is in field %s.")
1506
                   sct t.name (field_of_stage stage))
1507
          | NoOrigin ->
1508
              Some no_message
1509
      else
1510
        None
1511
    in
1512

  
1513
    let version_is_good ~min_version version fmt =
1514
      let version_is_good =
1515
        OASISVersion.comparator_apply
1516
          version (OASISVersion.VGreaterEqual min_version)
1517
      in
1518
        Printf.ksprintf
1519
          (fun str ->
1520
             if version_is_good then
1521
               None
1522
             else
1523
               Some str)
1524
          fmt
1525
    in
1526

  
1527
    match origin, t.plugin, t.publication with
1528
      | _, _, InDev Alpha -> check_feature data.Data.alpha_features Alpha
1529
      | _, _, InDev Beta -> check_feature data.Data.beta_features Beta
1530
      | Field(fld, where), None, SinceVersion min_version ->
1531
          version_is_good ~min_version data.Data.oasis_version
1532
            (f_ "Field %s in %s is only valid since OASIS v%s, update \
1533
                 OASISFormat field from '%s' to '%s' after checking \
1534
                 OASIS changelog.")
1535
            fld where (string_of_version min_version)
1536
            (string_of_version data.Data.oasis_version)
1537
            (string_of_version min_version)
1538

  
1539
      | Field(fld, where), Some(plugin_knd, plugin_name, _),
1540
        SinceVersion min_version ->
1541
          begin
1542
            try
1543
              let plugin_version_current =
1544
                try
1545
                  match Data.plugin_version plugin_knd plugin_name data with
1546
                    | Some ver -> ver
1547
                    | None ->
1548
                        failwithf
1549
                          (f_ "Field %s in %s is only valid for the OASIS \
1550
                               plugin %s since v%s, but no plugin version is \
1551
                               defined in the _oasis file, change '%s' to \
1552
                               '%s (%s)' in your _oasis file.")
1553
                          fld where plugin_name (string_of_version min_version)
1554
                          plugin_name
1555
                          plugin_name (string_of_version min_version)
1556
                with Not_found ->
1557
                  failwithf
1558
                    (f_ "Field %s in %s is only valid when the OASIS plugin %s \
1559
                         is defined.")
1560
                    fld where plugin_name
1561
              in
1562
              version_is_good ~min_version plugin_version_current
1563
                (f_ "Field %s in %s is only valid for the OASIS plugin %s \
1564
                     since v%s, update your plugin from '%s (%s)' to \
1565
                     '%s (%s)' after checking the plugin's changelog.")
1566
                fld where plugin_name (string_of_version min_version)
1567
                plugin_name (string_of_version plugin_version_current)
1568
                plugin_name (string_of_version min_version)
1569
            with Failure msg ->
1570
              Some msg
1571
          end
1572

  
1573
      | Section sct, None, SinceVersion min_version ->
1574
          version_is_good ~min_version data.Data.oasis_version
1575
            (f_ "Section %s is only valid for since OASIS v%s, update \
1576
                 OASISFormat field from '%s' to '%s' after checking OASIS \
1577
                 changelog.")
1578
            sct (string_of_version min_version)
1579
            (string_of_version data.Data.oasis_version)
1580
            (string_of_version min_version)
1581

  
1582
      | Section sct, Some(plugin_knd, plugin_name, _),
1583
        SinceVersion min_version ->
1584
          begin
1585
            try
1586
              let plugin_version_current =
1587
                try
1588
                  match Data.plugin_version plugin_knd plugin_name data with
1589
                    | Some ver -> ver
1590
                    | None ->
1591
                        failwithf
1592
                          (f_ "Section %s is only valid for the OASIS \
1593
                               plugin %s since v%s, but no plugin version is \
1594
                               defined in the _oasis file, change '%s' to \
1595
                               '%s (%s)' in your _oasis file.")
1596
                          sct plugin_name (string_of_version min_version)
1597
                          plugin_name
1598
                          plugin_name (string_of_version min_version)
1599
                with Not_found ->
1600
                  failwithf
1601
                    (f_ "Section %s is only valid when the OASIS plugin %s \
1602
                         is defined.")
1603
                    sct plugin_name
1604
              in
1605
              version_is_good ~min_version plugin_version_current
1606
                (f_ "Section %s is only valid for the OASIS plugin %s \
1607
                     since v%s, update your plugin from '%s (%s)' to \
1608
                     '%s (%s)' after checking the plugin's changelog.")
1609
                sct plugin_name (string_of_version min_version)
1610
                plugin_name (string_of_version plugin_version_current)
1611
                plugin_name (string_of_version min_version)
1612
            with Failure msg ->
1613
              Some msg
1614
          end
1615

  
1616
      | NoOrigin, None, SinceVersion min_version ->
1617
          version_is_good ~min_version data.Data.oasis_version "%s" no_message
1618

  
1619
      | NoOrigin, Some(plugin_knd, plugin_name, _), SinceVersion min_version ->
1620
          begin
1621
            try
1622
              let plugin_version_current =
1623
                match Data.plugin_version plugin_knd plugin_name data with
1624
                  | Some ver -> ver
1625
                  | None -> raise Not_found
1626
              in
1627
              version_is_good ~min_version plugin_version_current
1628
                "%s" no_message
1629
            with Not_found ->
1630
              Some no_message
1631
          end
1632

  
1633

  
1634
  let data_assert t data origin =
1635
    match data_check t data origin with
1636
      | None -> ()
1637
      | Some str -> failwith str
1638

  
1639

  
1640
  let data_test t data =
1641
    match data_check t data NoOrigin with
1642
      | None -> true
1643
      | Some str -> false
1644

  
1645

  
1646
  let package_test t pkg =
1647
    data_test t (Data.of_package pkg)
1648

  
1649

  
1650
  let create ?plugin name publication description =
1651
    let () =
1652
      if Hashtbl.mem all_features name then
1653
        failwithf "Feature '%s' is already declared." name
1654
    in
1655
    let t =
1656
      {
1657
        name = name;
1658
        plugin = plugin;
1659
        publication = publication;
1660
        description = description;
1661
      }
1662
    in
1663
      Hashtbl.add all_features name t;
1664
      t
1665

  
1666

  
1667
  let get_stage name =
1668
    try
1669
      (Hashtbl.find all_features name).publication
1670
    with Not_found ->
1671
      failwithf (f_ "Feature %s doesn't exist.") name
1672

  
1673

  
1674
  let list () =
1675
    Hashtbl.fold (fun _ v acc -> v :: acc) all_features []
1676

  
1677
  (*
1678
   * Real flags.
1679
   *)
1680

  
1681

  
1682
  let features =
1683
    create "features_fields"
1684
      (since_version "0.4")
1685
      (fun () ->
1686
         s_ "Enable to experiment not yet official features.")
1687

  
1688

  
1689
  let flag_docs =
1690
    create "flag_docs"
1691
      (since_version "0.3")
1692
      (fun () ->
1693
         s_ "Building docs require '-docs' flag at configure.")
1126 1694

  
1127
  type section =
1128
    | Library    of common_section * build_section * library
1129
    | Executable of common_section * build_section * executable
1130
    | Flag       of common_section * flag
1131
    | SrcRepo    of common_section * source_repository
1132
    | Test       of common_section * test
1133
    | Doc        of common_section * doc
1134
    
1135 1695

  
1136
  type section_kind =
1137
      [ `Library | `Executable | `Flag | `SrcRepo | `Test | `Doc ]
1696
  let flag_tests =
1697
    create "flag_tests"
1698
      (since_version "0.3")
1699
      (fun () ->
1700
         s_ "Running tests require '-tests' flag at configure.")
1701

  
1702

  
1703
  let pack =
1704
    create "pack"
1705
      (since_version "0.3")
1706
      (fun () ->
1707
         s_ "Allow to create packed library.")
1708

  
1709

  
1710
  let section_object =
1711
    create "section_object" beta
1712
      (fun () ->
1713
         s_ "Implement an object section.")
1138 1714

  
1139
  type package = 
1140
      {
1141
        oasis_version:    OASISVersion.t;
1142
        ocaml_version:    OASISVersion.comparator option;
1143
        findlib_version:  OASISVersion.comparator option;
1144
        name:             package_name;
1145
        version:          OASISVersion.t;
1146
        license:          OASISLicense.t;
1147
        license_file:     unix_filename option;
1148
        copyrights:       string list;
1149
        maintainers:      string list;
1150
        authors:          string list;
1151
        homepage:         url option;
1152
        synopsis:         string;
1153
        description:      string option;
1154
        categories:       url list;
1155

  
1156
        conf_type:        [`Configure] plugin;
1157
        conf_custom:      custom;
1158

  
1159
        build_type:       [`Build] plugin;
1160
        build_custom:     custom;
1161

  
1162
        install_type:     [`Install] plugin;
1163
        install_custom:   custom;
1164
        uninstall_custom: custom;
1165

  
1166
        clean_custom:     custom;
1167
        distclean_custom: custom;
1168

  
1169
        files_ab:         unix_filename list;
1170
        sections:         section list;
1171
        plugins:          [`Extra] plugin list;
1172
        schema_data:      PropList.Data.t;
1173
        plugin_data:      plugin_data;
1174
      } 
1175 1715

  
1716
  let dynrun_for_release =
1717
    create "dynrun_for_release" alpha
1718
      (fun () ->
1719
         s_ "Make '-setup-update dynamic' suitable for releasing project.")
1720

  
1721

  
1722
  let compiled_setup_ml =
1723
    create "compiled_setup_ml" alpha
1724
      (fun () ->
1725
         s_ "It compiles the setup.ml and speed-up actions done with it.")
1726

  
1727
  let disable_oasis_section =
1728
    create "disable_oasis_section" alpha
1729
      (fun () ->
1730
        s_ "Allows the OASIS section comments and digest to be omitted in \
1731
            generated files.")
1176 1732
end
1177 1733

  
1178 1734
module OASISUnixPath = struct
1179
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISUnixPath.ml" *)
1735
(* # 22 "src/oasis/OASISUnixPath.ml" *)
1736

  
1180 1737

  
1181 1738
  type unix_filename = string
1182 1739
  type unix_dirname = string
1183 1740

  
1741

  
1184 1742
  type host_filename = string
1185 1743
  type host_dirname = string
1186 1744

  
1745

  
1187 1746
  let current_dir_name = "."
1188 1747

  
1748

  
1189 1749
  let parent_dir_name = ".."
1190 1750

  
1751

  
1191 1752
  let is_current_dir fn =
1192 1753
    fn = current_dir_name || fn = ""
1193 1754

  
1755

  
1194 1756
  let concat f1 f2 =
1195 1757
    if is_current_dir f1 then
1196 1758
      f2
......
1200 1762
      in
1201 1763
        f1'^"/"^f2
1202 1764

  
1765

  
1203 1766
  let make =
1204 1767
    function
1205 1768
      | hd :: tl ->
......
1210 1773
      | [] ->
1211 1774
          invalid_arg "OASISUnixPath.make"
1212 1775

  
1776

  
1213 1777
  let dirname f =
1214 1778
    try
1215 1779
      String.sub f 0 (String.rindex f '/')
1216 1780
    with Not_found ->
1217 1781
      current_dir_name
1218 1782

  
1783

  
1219 1784
  let basename f =
1220 1785
    try
1221 1786
      let pos_start =
......
1225 1790
    with Not_found ->
1226 1791
      f
1227 1792

  
1793

  
1228 1794
  let chop_extension f =
1229 1795
    try
1230 1796
      let last_dot =
......
1247 1813
    with Not_found ->
1248 1814
      f
1249 1815

  
1816

  
1250 1817
  let capitalize_file f =
1251 1818
    let dir = dirname f in
1252 1819
    let base = basename f in
1253 1820
    concat dir (String.capitalize base)
1254 1821

  
1822

  
1255 1823
  let uncapitalize_file f =
1256 1824
    let dir = dirname f in
1257 1825
    let base = basename f in
1258 1826
    concat dir (String.uncapitalize base)
1259 1827

  
1828

  
1260 1829
end
1261 1830

  
1262 1831
module OASISHostPath = struct
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff