Browse Source

Version 0.3.0-rc1

Leo 8 years ago
parent
commit
e791990df3
8 changed files with 3969 additions and 3464 deletions
  1. 2 2
      Makefile
  2. 1 1
      VERSION
  3. 1 1
      _oasis
  4. 6 2
      configure
  5. 383 265
      myocamlbuild.ml
  6. 1 1
      opam
  7. 3574 3191
      setup.ml
  8. 1 1
      src/oclaunch.ml

+ 2 - 2
Makefile

@@ -1,5 +1,5 @@
 # OASIS_START
 # OASIS_START
-# DO NOT EDIT (digest: 46f8bd9984975bd4727bed22d0876cd2)
+# DO NOT EDIT (digest: 0ea630b0d23ed49c1bf5c457a3a51866)
 
 
 SETUP = ./setup.exe
 SETUP = ./setup.exe
 
 
@@ -38,7 +38,7 @@ configure: $(SETUP)
 	$(SETUP) -configure $(CONFIGUREFLAGS)
 	$(SETUP) -configure $(CONFIGUREFLAGS)
 
 
 setup.exe: setup.ml
 setup.exe: setup.ml
-	ocamlfind ocamlopt -o $@ $< || ocamlfind ocamlc -o $@ $< || true
+	ocamlfind ocamlopt -o $@ setup.ml || ocamlfind ocamlc -o $@ setup.ml || true
 	$(RM) setup.cmi setup.cmo setup.cmx setup.o
 	$(RM) setup.cmi setup.cmo setup.cmx setup.o
 
 
 .PHONY: build doc test all install uninstall reinstall clean distclean configure
 .PHONY: build doc test all install uninstall reinstall clean distclean configure

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.3.0
+0.3.0-rc1

+ 1 - 1
_oasis

@@ -1,6 +1,6 @@
 OASISFormat: 0.4
 OASISFormat: 0.4
 Name:        OcLaunch
 Name:        OcLaunch
-Version:     0.3.0
+Version:     0.3.0-rc1
 Synopsis:    Launch commands automagically
 Synopsis:    Launch commands automagically
 Authors:     Joly Clément <leowzukw@oclaunch.eu.org>
 Authors:     Joly Clément <leowzukw@oclaunch.eu.org>
 Maintainers: Joly Clément <leowzukw@oclaunch.eu.org>
 Maintainers: Joly Clément <leowzukw@oclaunch.eu.org>

+ 6 - 2
configure

@@ -1,7 +1,7 @@
 #!/bin/sh
 #!/bin/sh
 
 
 # OASIS_START
 # OASIS_START
-# DO NOT EDIT (digest: 6f7b8221311e800a7093dc3b793f67ca)
+# DO NOT EDIT (digest: 67dd0def14e1d99625d2485f6a4d5df1)
 set -e
 set -e
 
 
 FST=true
 FST=true
@@ -23,5 +23,9 @@ for i in "$@"; do
   esac
   esac
 done
 done
 
 
-make configure CONFIGUREFLAGS="$*"
+if [ ! -e setup.exe ] || [ _oasis -nt setup.exe ] || [ setup.ml -nt setup.exe ] || [ configure -nt setup.exe ]; then
+  ocamlfind ocamlopt -o setup.exe setup.ml || ocamlfind ocamlc -o setup.exe setup.ml || exit 1
+  rm -f setup.cmi setup.cmo setup.cmx setup.o
+fi
+./setup.exe -configure "$@"
 # OASIS_STOP
 # OASIS_STOP

+ 383 - 265
myocamlbuild.ml

@@ -1,19 +1,12 @@
 (* OASIS_START *)
 (* OASIS_START *)
-(* DO NOT EDIT (digest: a02f38e3e2213d6985da0d03d4f432d7) *)
+(* DO NOT EDIT (digest: ef1a54452f0cead733c1a9a890b617ad) *)
 module OASISGettext = struct
 module OASISGettext = struct
 (* # 22 "src/oasis/OASISGettext.ml" *)
 (* # 22 "src/oasis/OASISGettext.ml" *)
 
 
 
 
-  let ns_ str =
-    str
-
-
-  let s_ str =
-    str
-
-
-  let f_ (str: ('a, 'b, 'c, 'd) format4) =
-    str
+  let ns_ str = str
+  let s_ str = str
+  let f_ (str: ('a, 'b, 'c, 'd) format4) = str
 
 
 
 
   let fn_ fmt1 fmt2 n =
   let fn_ fmt1 fmt2 n =
@@ -23,10 +16,7 @@ module OASISGettext = struct
       fmt2^^""
       fmt2^^""
 
 
 
 
-  let init =
-    []
-
-
+  let init = []
 end
 end
 
 
 module OASISString = struct
 module OASISString = struct
@@ -38,7 +28,7 @@ module OASISString = struct
       Mostly inspired by extlib and batteries ExtString and BatString libraries.
       Mostly inspired by extlib and batteries ExtString and BatString libraries.
 
 
       @author Sylvain Le Gall
       @author Sylvain Le Gall
-    *)
+  *)
 
 
 
 
   let nsplitf str f =
   let nsplitf str f =
@@ -52,19 +42,19 @@ module OASISString = struct
         Buffer.clear buf
         Buffer.clear buf
       in
       in
       let str_len = String.length str in
       let str_len = String.length str in
-        for i = 0 to str_len - 1 do
-          if f str.[i] then
-            push ()
-          else
-            Buffer.add_char buf str.[i]
-        done;
-        push ();
-        List.rev !lst
+      for i = 0 to str_len - 1 do
+        if f str.[i] then
+          push ()
+        else
+          Buffer.add_char buf str.[i]
+      done;
+      push ();
+      List.rev !lst
 
 
 
 
   (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
   (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
       separator.
       separator.
-    *)
+  *)
   let nsplit str c =
   let nsplit str c =
     nsplitf str ((=) c)
     nsplitf str ((=) c)
 
 
@@ -72,18 +62,18 @@ module OASISString = struct
   let find ~what ?(offset=0) str =
   let find ~what ?(offset=0) str =
     let what_idx = ref 0 in
     let what_idx = ref 0 in
     let str_idx = ref offset in
     let str_idx = ref offset in
-      while !str_idx < String.length str &&
-            !what_idx < String.length what do
-        if str.[!str_idx] = what.[!what_idx] then
-          incr what_idx
-        else
-          what_idx := 0;
-        incr str_idx
-      done;
-      if !what_idx <> String.length what then
-        raise Not_found
+    while !str_idx < String.length str &&
+          !what_idx < String.length what do
+      if str.[!str_idx] = what.[!what_idx] then
+        incr what_idx
       else
       else
-        !str_idx - !what_idx
+        what_idx := 0;
+      incr str_idx
+    done;
+    if !what_idx <> String.length what then
+      raise Not_found
+    else
+      !str_idx - !what_idx
 
 
 
 
   let sub_start str len =
   let sub_start str len =
@@ -106,19 +96,19 @@ module OASISString = struct
     let what_idx = ref 0 in
     let what_idx = ref 0 in
     let str_idx = ref offset in
     let str_idx = ref offset in
     let ok = ref true in
     let ok = ref true in
-      while !ok &&
-            !str_idx < String.length str &&
-            !what_idx < String.length what do
-        if str.[!str_idx] = what.[!what_idx] then
-          incr what_idx
-        else
-          ok := false;
-        incr str_idx
-      done;
-      if !what_idx = String.length what then
-        true
+    while !ok &&
+          !str_idx < String.length str &&
+          !what_idx < String.length what do
+      if str.[!str_idx] = what.[!what_idx] then
+        incr what_idx
       else
       else
-        false
+        ok := false;
+      incr str_idx
+    done;
+    if !what_idx = String.length what then
+      true
+    else
+      false
 
 
 
 
   let strip_starts_with ~what str =
   let strip_starts_with ~what str =
@@ -132,19 +122,19 @@ module OASISString = struct
     let what_idx = ref ((String.length what) - 1) in
     let what_idx = ref ((String.length what) - 1) in
     let str_idx = ref ((String.length str) - 1) in
     let str_idx = ref ((String.length str) - 1) in
     let ok = ref true in
     let ok = ref true in
-      while !ok &&
-            offset <= !str_idx &&
-            0 <= !what_idx do
-        if str.[!str_idx] = what.[!what_idx] then
-          decr what_idx
-        else
-          ok := false;
-        decr str_idx
-      done;
-      if !what_idx = -1 then
-        true
+    while !ok &&
+          offset <= !str_idx &&
+          0 <= !what_idx do
+      if str.[!str_idx] = what.[!what_idx] then
+        decr what_idx
       else
       else
-        false
+        ok := false;
+      decr str_idx
+    done;
+    if !what_idx = -1 then
+      true
+    else
+      false
 
 
 
 
   let strip_ends_with ~what str =
   let strip_ends_with ~what str =
@@ -189,19 +179,181 @@ module OASISString = struct
 
 
 end
 end
 
 
-module OASISExpr = struct
-(* # 22 "src/oasis/OASISExpr.ml" *)
+module OASISUtils = struct
+(* # 22 "src/oasis/OASISUtils.ml" *)
 
 
 
 
+  open OASISGettext
 
 
 
 
+  module MapExt =
+  struct
+    module type S =
+    sig
+      include Map.S
+      val add_list: 'a t -> (key * 'a) list -> 'a t
+      val of_list: (key * 'a) list -> 'a t
+      val to_list: 'a t -> (key * 'a) list
+    end
 
 
-  open OASISGettext
+    module Make (Ord: Map.OrderedType) =
+    struct
+      include Map.Make(Ord)
 
 
+      let rec add_list t =
+        function
+          | (k, v) :: tl -> add_list (add k v t) tl
+          | [] -> t
 
 
-  type test = string
+      let of_list lst = add_list empty lst
+
+      let to_list t = fold (fun k v acc -> (k, v) :: acc) t []
+    end
+  end
+
+
+  module MapString = MapExt.Make(String)
+
+
+  module SetExt  =
+  struct
+    module type S =
+    sig
+      include Set.S
+      val add_list: t -> elt list -> t
+      val of_list: elt list -> t
+      val to_list: t -> elt list
+    end
+
+    module Make (Ord: Set.OrderedType) =
+    struct
+      include Set.Make(Ord)
+
+      let rec add_list t =
+        function
+          | e :: tl -> add_list (add e t) tl
+          | [] -> t
+
+      let of_list lst = add_list empty lst
+
+      let to_list = elements
+    end
+  end
+
+
+  module SetString = SetExt.Make(String)
+
+
+  let compare_csl s1 s2 =
+    String.compare (OASISString.lowercase_ascii s1) (OASISString.lowercase_ascii s2)
+
+
+  module HashStringCsl =
+    Hashtbl.Make
+      (struct
+         type t = string
+         let equal s1 s2 = (compare_csl s1 s2) = 0
+         let hash s = Hashtbl.hash (OASISString.lowercase_ascii s)
+       end)
+
+  module SetStringCsl =
+    SetExt.Make
+      (struct
+         type t = string
+         let compare = compare_csl
+       end)
+
+
+  let varname_of_string ?(hyphen='_') s =
+    if String.length s = 0 then
+      begin
+        invalid_arg "varname_of_string"
+      end
+    else
+      begin
+        let buf =
+          OASISString.replace_chars
+            (fun c ->
+               if ('a' <= c && c <= 'z')
+                 ||
+                  ('A' <= c && c <= 'Z')
+                 ||
+                  ('0' <= c && c <= '9') then
+                 c
+               else
+                 hyphen)
+            s;
+        in
+        let buf =
+          (* Start with a _ if digit *)
+          if '0' <= s.[0] && s.[0] <= '9' then
+            "_"^buf
+          else
+            buf
+        in
+          OASISString.lowercase_ascii buf
+      end
+
+
+  let varname_concat ?(hyphen='_') p s =
+    let what = String.make 1 hyphen in
+    let p =
+      try
+        OASISString.strip_ends_with ~what p
+      with Not_found ->
+        p
+    in
+    let s =
+      try
+        OASISString.strip_starts_with ~what s
+      with Not_found ->
+        s
+    in
+      p^what^s
+
+
+  let is_varname str =
+    str = varname_of_string str
 
 
 
 
+  let failwithf fmt = Printf.ksprintf failwith fmt
+
+
+  let rec file_location ?pos1 ?pos2 ?lexbuf () =
+      match pos1, pos2, lexbuf with
+      | Some p, None, _ | None, Some p, _ ->
+        file_location ~pos1:p ~pos2:p ?lexbuf ()
+      | Some p1, Some p2, _ ->
+        let open Lexing in
+        let fn, lineno = p1.pos_fname, p1.pos_lnum in
+        let c1 = p1.pos_cnum - p1.pos_bol in
+        let c2 = c1 + (p2.pos_cnum - p1.pos_cnum) in
+        Printf.sprintf (f_ "file %S, line %d, characters %d-%d")  fn lineno c1 c2
+      | _, _, Some lexbuf ->
+        file_location
+          ~pos1:(Lexing.lexeme_start_p lexbuf)
+          ~pos2:(Lexing.lexeme_end_p lexbuf)
+          ()
+      | None, None, None ->
+        s_ "<position undefined>"
+
+
+  let failwithpf ?pos1 ?pos2 ?lexbuf fmt =
+    let loc = file_location ?pos1 ?pos2 ?lexbuf () in
+    Printf.ksprintf (fun s -> failwith (Printf.sprintf "%s: %s" loc s)) fmt
+
+
+end
+
+module OASISExpr = struct
+(* # 22 "src/oasis/OASISExpr.ml" *)
+
+
+  open OASISGettext
+  open OASISUtils
+
+
+  type test = string
   type flag = string
   type flag = string
 
 
 
 
@@ -214,7 +366,6 @@ module OASISExpr = struct
     | ETest of test * string
     | ETest of test * string
 
 
 
 
-
   type 'a choices = (t * 'a) list
   type 'a choices = (t * 'a) list
 
 
 
 
@@ -289,7 +440,7 @@ module OASISExpr = struct
 end
 end
 
 
 
 
-# 292 "myocamlbuild.ml"
+# 443 "myocamlbuild.ml"
 module BaseEnvLight = struct
 module BaseEnvLight = struct
 (* # 22 "src/base/BaseEnvLight.ml" *)
 (* # 22 "src/base/BaseEnvLight.ml" *)
 
 
@@ -300,132 +451,103 @@ module BaseEnvLight = struct
   type t = string MapString.t
   type t = string MapString.t
 
 
 
 
-  let default_filename =
-    Filename.concat
-      (Sys.getcwd ())
-      "setup.data"
+  let default_filename = Filename.concat (Sys.getcwd ()) "setup.data"
 
 
 
 
-  let load ?(allow_empty=false) ?(filename=default_filename) () =
-    if Sys.file_exists filename then
-      begin
-        let chn =
-          open_in_bin filename
-        in
-        let st =
-          Stream.of_channel chn
-        in
-        let line =
-          ref 1
-        in
-        let st_line =
-          Stream.from
-            (fun _ ->
-               try
-                 match Stream.next st with
-                   | '\n' -> incr line; Some '\n'
-                   | c -> Some c
-               with Stream.Failure -> None)
-        in
-        let lexer =
-          Genlex.make_lexer ["="] st_line
-        in
-        let rec read_file mp =
-          match Stream.npeek 3 lexer with
-            | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
-                Stream.junk lexer;
-                Stream.junk lexer;
-                Stream.junk lexer;
-                read_file (MapString.add nm value mp)
-            | [] ->
-                mp
-            | _ ->
-                failwith
-                  (Printf.sprintf
-                     "Malformed data file '%s' line %d"
-                     filename !line)
-        in
-        let mp =
-          read_file MapString.empty
-        in
-          close_in chn;
-          mp
-      end
-    else if allow_empty then
-      begin
+  let load ?(allow_empty=false) ?(filename=default_filename) ?stream () =
+    let line = ref 1 in
+    let lexer st =
+      let st_line =
+        Stream.from
+          (fun _ ->
+             try
+               match Stream.next st with
+               | '\n' -> incr line; Some '\n'
+               | c -> Some c
+             with Stream.Failure -> None)
+      in
+      Genlex.make_lexer ["="] st_line
+    in
+    let rec read_file lxr mp =
+      match Stream.npeek 3 lxr with
+      | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
+        Stream.junk lxr; Stream.junk lxr; Stream.junk lxr;
+        read_file lxr (MapString.add nm value mp)
+      | [] -> mp
+      | _ ->
+        failwith
+          (Printf.sprintf "Malformed data file '%s' line %d" filename !line)
+    in
+    match stream with
+    | Some st -> read_file (lexer st) MapString.empty
+    | None ->
+      if Sys.file_exists filename then begin
+        let chn = open_in_bin filename in
+        let st = Stream.of_channel chn in
+        try
+          let mp = read_file (lexer st) MapString.empty in
+          close_in chn; mp
+        with e ->
+          close_in chn; raise e
+      end else if allow_empty then begin
         MapString.empty
         MapString.empty
-      end
-    else
-      begin
+      end else begin
         failwith
         failwith
           (Printf.sprintf
           (Printf.sprintf
              "Unable to load environment, the file '%s' doesn't exist."
              "Unable to load environment, the file '%s' doesn't exist."
              filename)
              filename)
       end
       end
 
 
-
   let rec var_expand str env =
   let rec var_expand str env =
-    let buff =
-      Buffer.create ((String.length str) * 2)
-    in
-      Buffer.add_substitute
-        buff
-        (fun var ->
-           try
-             var_expand (MapString.find var env) env
-           with Not_found ->
-             failwith
-               (Printf.sprintf
-                  "No variable %s defined when trying to expand %S."
-                  var
-                  str))
-        str;
-      Buffer.contents buff
-
-
-  let var_get name env =
-    var_expand (MapString.find name env) env
-
-
-  let var_choose lst env =
-    OASISExpr.choose
-      (fun nm -> var_get nm env)
-      lst
+    let buff = Buffer.create ((String.length str) * 2) in
+    Buffer.add_substitute
+      buff
+      (fun var ->
+         try
+           var_expand (MapString.find var env) env
+         with Not_found ->
+           failwith
+             (Printf.sprintf
+                "No variable %s defined when trying to expand %S."
+                var
+                str))
+      str;
+    Buffer.contents buff
+
+
+  let var_get name env = var_expand (MapString.find name env) env
+  let var_choose lst env = OASISExpr.choose (fun nm -> var_get nm env) lst
 end
 end
 
 
 
 
-# 397 "myocamlbuild.ml"
+# 523 "myocamlbuild.ml"
 module MyOCamlbuildFindlib = struct
 module MyOCamlbuildFindlib = struct
 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
 
 
 
 
   (** OCamlbuild extension, copied from
   (** OCamlbuild extension, copied from
-    * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
+    * https://ocaml.org/learn/tutorials/ocamlbuild/Using_ocamlfind_with_ocamlbuild.html
     * by N. Pouillard and others
     * by N. Pouillard and others
     *
     *
-    * Updated on 2009/02/28
+    * Updated on 2016-06-02
     *
     *
     * Modified by Sylvain Le Gall
     * Modified by Sylvain Le Gall
-    *)
+  *)
   open Ocamlbuild_plugin
   open Ocamlbuild_plugin
 
 
-  type conf =
-    { no_automatic_syntax: bool;
-    }
 
 
-  (* these functions are not really officially exported *)
-  let run_and_read =
-    Ocamlbuild_pack.My_unix.run_and_read
+  type conf = {no_automatic_syntax: bool}
+
 
 
+  let run_and_read = Ocamlbuild_pack.My_unix.run_and_read
 
 
-  let blank_sep_strings =
-    Ocamlbuild_pack.Lexers.blank_sep_strings
+
+  let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings
 
 
 
 
   let exec_from_conf exec =
   let exec_from_conf exec =
     let exec =
     let exec =
-      let env_filename = Pathname.basename BaseEnvLight.default_filename in
-      let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in
+      let env = BaseEnvLight.load ~allow_empty:true () in
       try
       try
         BaseEnvLight.var_get exec env
         BaseEnvLight.var_get exec env
       with Not_found ->
       with Not_found ->
@@ -436,7 +558,7 @@ module MyOCamlbuildFindlib = struct
       if Sys.os_type = "Win32" then begin
       if Sys.os_type = "Win32" then begin
         let buff = Buffer.create (String.length str) in
         let buff = Buffer.create (String.length str) in
         (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'.
         (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'.
-         *)
+        *)
         String.iter
         String.iter
           (fun c -> Buffer.add_char buff (if c = '\\' then '/' else c))
           (fun c -> Buffer.add_char buff (if c = '\\' then '/' else c))
           str;
           str;
@@ -445,7 +567,8 @@ module MyOCamlbuildFindlib = struct
         str
         str
       end
       end
     in
     in
-      fix_win32 exec
+    fix_win32 exec
+
 
 
   let split s ch =
   let split s ch =
     let buf = Buffer.create 13 in
     let buf = Buffer.create 13 in
@@ -454,15 +577,15 @@ module MyOCamlbuildFindlib = struct
       x := (Buffer.contents buf) :: !x;
       x := (Buffer.contents buf) :: !x;
       Buffer.clear buf
       Buffer.clear buf
     in
     in
-      String.iter
-        (fun c ->
-           if c = ch then
-             flush ()
-           else
-             Buffer.add_char buf c)
-        s;
-      flush ();
-      List.rev !x
+    String.iter
+      (fun c ->
+         if c = ch then
+           flush ()
+         else
+           Buffer.add_char buf c)
+      s;
+    flush ();
+    List.rev !x
 
 
 
 
   let split_nl s = split s '\n'
   let split_nl s = split s '\n'
@@ -504,85 +627,89 @@ module MyOCamlbuildFindlib = struct
   let dispatch conf =
   let dispatch conf =
     function
     function
       | After_options ->
       | After_options ->
-          (* By using Before_options one let command line options have an higher
-           * priority on the contrary using After_options will guarantee to have
-           * the higher priority override default commands by ocamlfind ones *)
-          Options.ocamlc     := ocamlfind & A"ocamlc";
-          Options.ocamlopt   := ocamlfind & A"ocamlopt";
-          Options.ocamldep   := ocamlfind & A"ocamldep";
-          Options.ocamldoc   := ocamlfind & A"ocamldoc";
-          Options.ocamlmktop := ocamlfind & A"ocamlmktop";
-          Options.ocamlmklib := ocamlfind & A"ocamlmklib"
+        (* By using Before_options one let command line options have an higher
+         * priority on the contrary using After_options will guarantee to have
+         * the higher priority override default commands by ocamlfind ones *)
+        Options.ocamlc     := ocamlfind & A"ocamlc";
+        Options.ocamlopt   := ocamlfind & A"ocamlopt";
+        Options.ocamldep   := ocamlfind & A"ocamldep";
+        Options.ocamldoc   := ocamlfind & A"ocamldoc";
+        Options.ocamlmktop := ocamlfind & A"ocamlmktop";
+        Options.ocamlmklib := ocamlfind & A"ocamlmklib"
 
 
       | After_rules ->
       | After_rules ->
 
 
-          (* When one link an OCaml library/binary/package, one should use
-           * -linkpkg *)
-          flag ["ocaml"; "link"; "program"] & A"-linkpkg";
-
-          if not (conf.no_automatic_syntax) then begin
-            (* For each ocamlfind package one inject the -package option when
-             * compiling, computing dependencies, generating documentation and
-             * linking. *)
-            List.iter
-              begin fun pkg ->
-                let base_args = [A"-package"; A pkg] in
-                (* TODO: consider how to really choose camlp4o or camlp4r. *)
-                let syn_args = [A"-syntax"; A "camlp4o"] in
-                let (args, pargs) =
-                  (* Heuristic to identify syntax extensions: whether they end in
-                     ".syntax"; some might not.
-                  *)
-                  if Filename.check_suffix pkg "syntax" ||
-                     List.mem pkg well_known_syntax then
-                    (syn_args @ base_args, syn_args)
-                  else
-                    (base_args, [])
-                in
-                flag ["ocaml"; "compile";  "pkg_"^pkg] & S args;
-                flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
-                flag ["ocaml"; "doc";      "pkg_"^pkg] & S args;
-                flag ["ocaml"; "link";     "pkg_"^pkg] & S base_args;
-                flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
-
-                (* TODO: Check if this is allowed for OCaml < 3.12.1 *)
-                flag ["ocaml"; "compile";  "package("^pkg^")"] & S pargs;
-                flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
-                flag ["ocaml"; "doc";      "package("^pkg^")"] & S pargs;
-                flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
-              end
-              (find_packages ());
-          end;
-
-          (* Like -package but for extensions syntax. Morover -syntax is useless
-           * when linking. *)
-          List.iter begin fun syntax ->
+        (* Avoid warnings for unused tag *)
+        flag ["tests"] N;
+
+        (* When one link an OCaml library/binary/package, one should use
+         * -linkpkg *)
+        flag ["ocaml"; "link"; "program"] & A"-linkpkg";
+
+        (* For each ocamlfind package one inject the -package option when
+         * compiling, computing dependencies, generating documentation and
+         * linking. *)
+        List.iter
+          begin fun pkg ->
+            let base_args = [A"-package"; A pkg] in
+            (* TODO: consider how to really choose camlp4o or camlp4r. *)
+            let syn_args = [A"-syntax"; A "camlp4o"] in
+            let (args, pargs) =
+              (* Heuristic to identify syntax extensions: whether they end in
+                 ".syntax"; some might not.
+              *)
+              if not (conf.no_automatic_syntax) &&
+                 (Filename.check_suffix pkg "syntax" ||
+                  List.mem pkg well_known_syntax) then
+                (syn_args @ base_args, syn_args)
+              else
+                (base_args, [])
+            in
+            flag ["ocaml"; "compile";  "pkg_"^pkg] & S args;
+            flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
+            flag ["ocaml"; "doc";      "pkg_"^pkg] & S args;
+            flag ["ocaml"; "link";     "pkg_"^pkg] & S base_args;
+            flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
+
+            (* TODO: Check if this is allowed for OCaml < 3.12.1 *)
+            flag ["ocaml"; "compile";  "package("^pkg^")"] & S pargs;
+            flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
+            flag ["ocaml"; "doc";      "package("^pkg^")"] & S pargs;
+            flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
+          end
+          (find_packages ());
+
+        (* Like -package but for extensions syntax. Morover -syntax is useless
+         * when linking. *)
+        List.iter begin fun syntax ->
           flag ["ocaml"; "compile";  "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "compile";  "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "doc";      "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "doc";      "syntax_"^syntax] & S[A"-syntax"; A syntax];
           flag ["ocaml"; "infer_interface"; "syntax_"^syntax] &
           flag ["ocaml"; "infer_interface"; "syntax_"^syntax] &
-                S[A"-syntax"; A syntax];
-          end (find_syntaxes ());
-
-          (* The default "thread" tag is not compatible with ocamlfind.
-           * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
-           * options when using this tag. When using the "-linkpkg" option with
-           * ocamlfind, this module will then be added twice on the command line.
-           *
-           * To solve this, one approach is to add the "-thread" option when using
-           * the "threads" package using the previous plugin.
-           *)
-          flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
-          flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
-          flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
-          flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]);
-          flag ["ocaml"; "package(threads)"; "compile"] (S[A "-thread"]);
-          flag ["ocaml"; "package(threads)"; "doc"] (S[A "-I"; A "+threads"]);
-          flag ["ocaml"; "package(threads)"; "link"] (S[A "-thread"]);
-          flag ["ocaml"; "package(threads)"; "infer_interface"] (S[A "-thread"]);
+          S[A"-syntax"; A syntax];
+        end (find_syntaxes ());
+
+        (* The default "thread" tag is not compatible with ocamlfind.
+         * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
+         * options when using this tag. When using the "-linkpkg" option with
+         * ocamlfind, this module will then be added twice on the command line.
+         *
+         * To solve this, one approach is to add the "-thread" option when using
+         * the "threads" package using the previous plugin.
+        *)
+        flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
+        flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
+        flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
+        flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]);
+        flag ["c"; "pkg_threads"; "compile"] (S[A "-thread"]);
+        flag ["ocaml"; "package(threads)"; "compile"] (S[A "-thread"]);
+        flag ["ocaml"; "package(threads)"; "doc"] (S[A "-I"; A "+threads"]);
+        flag ["ocaml"; "package(threads)"; "link"] (S[A "-thread"]);
+        flag ["ocaml"; "package(threads)"; "infer_interface"] (S[A "-thread"]);
+        flag ["c"; "package(threads)"; "compile"] (S[A "-thread"]);
 
 
       | _ ->
       | _ ->
-          ()
+        ()
 end
 end
 
 
 module MyOCamlbuildBase = struct
 module MyOCamlbuildBase = struct
@@ -594,9 +721,6 @@ module MyOCamlbuildBase = struct
     *)
     *)
 
 
 
 
-
-
-
   open Ocamlbuild_plugin
   open Ocamlbuild_plugin
   module OC = Ocamlbuild_pack.Ocaml_compiler
   module OC = Ocamlbuild_pack.Ocaml_compiler
 
 
@@ -607,9 +731,6 @@ module MyOCamlbuildBase = struct
   type tag = string
   type tag = string
 
 
 
 
-(* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
-
-
   type t =
   type t =
       {
       {
         lib_ocaml: (name * dir list * string list) list;
         lib_ocaml: (name * dir list * string list) list;
@@ -622,9 +743,10 @@ module MyOCamlbuildBase = struct
       }
       }
 
 
 
 
-  let env_filename =
-    Pathname.basename
-      BaseEnvLight.default_filename
+(* # 110 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
+
+
+  let env_filename = Pathname.basename BaseEnvLight.default_filename
 
 
 
 
   let dispatch_combine lst =
   let dispatch_combine lst =
@@ -643,12 +765,7 @@ module MyOCamlbuildBase = struct
 
 
 
 
   let dispatch t e =
   let dispatch t e =
-    let env =
-      BaseEnvLight.load
-        ~filename:env_filename
-        ~allow_empty:true
-        ()
-    in
+    let env = BaseEnvLight.load ~allow_empty:true () in
       match e with
       match e with
         | Before_options ->
         | Before_options ->
             let no_trailing_dot s =
             let no_trailing_dot s =
@@ -712,18 +829,19 @@ module MyOCamlbuildBase = struct
                    flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib]
                    flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib]
                      (S[A"-cclib"; A("-l"^(nm_libstubs lib))]);
                      (S[A"-cclib"; A("-l"^(nm_libstubs lib))]);
 
 
-                   flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
-                     (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
+                   if bool_of_string (BaseEnvLight.var_get "native_dynlink" env) then
+                     flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
+                         (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
 
 
                    (* When ocaml link something that use the C library, then one
                    (* When ocaml link something that use the C library, then one
                       need that file to be up to date.
                       need that file to be up to date.
                       This holds both for programs and for libraries.
                       This holds both for programs and for libraries.
                     *)
                     *)
-  		 dep ["link"; "ocaml"; tag_libstubs lib]
-  		     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
+                   dep ["link"; "ocaml"; tag_libstubs lib]
+                     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
 
 
-  		 dep  ["compile"; "ocaml"; tag_libstubs lib]
-  		      [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
+                   dep  ["compile"; "ocaml"; tag_libstubs lib]
+                     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
 
 
                    (* TODO: be more specific about what depends on headers *)
                    (* TODO: be more specific about what depends on headers *)
                    (* Depends on .h files *)
                    (* Depends on .h files *)
@@ -763,7 +881,7 @@ module MyOCamlbuildBase = struct
 end
 end
 
 
 
 
-# 766 "myocamlbuild.ml"
+# 884 "myocamlbuild.ml"
 open Ocamlbuild_plugin;;
 open Ocamlbuild_plugin;;
 let package_default =
 let package_default =
   {
   {
@@ -778,6 +896,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
 
 
 let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
 let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
 
 
-# 782 "myocamlbuild.ml"
+# 900 "myocamlbuild.ml"
 (* OASIS_STOP *)
 (* OASIS_STOP *)
 Ocamlbuild_plugin.dispatch dispatch_default;;
 Ocamlbuild_plugin.dispatch dispatch_default;;

+ 1 - 1
opam

@@ -1,6 +1,6 @@
 opam-version: "1.2"
 opam-version: "1.2"
 name: "oclaunch"
 name: "oclaunch"
-version: "0.3.0"
+version: "0.3.0-rc1"
 maintainer: "Leo <leowzukw@oclaunch.eu.org>"
 maintainer: "Leo <leowzukw@oclaunch.eu.org>"
 authors: "Leo <leowzukw@oclaunch.eu.org>"
 authors: "Leo <leowzukw@oclaunch.eu.org>"
 homepage: "http://www.oclaunch.eu.org"
 homepage: "http://www.oclaunch.eu.org"

File diff suppressed because it is too large
+ 3574 - 3191
setup.ml


+ 1 - 1
src/oclaunch.ml

@@ -38,7 +38,7 @@ open Core.Std;;
 
 
 (* Variable to store version number *)
 (* Variable to store version number *)
 (* TODO Get value from file *)
 (* TODO Get value from file *)
-let version_number = "0.3.0";;
+let version_number = "0.3.0-rc1";;
 
 
 (* Variable store building information *)
 (* Variable store building information *)
 (* XXX This is fake value, it corresponds to the running
 (* XXX This is fake value, it corresponds to the running