Leo 10 years ago
parent
commit
70f72ae963
3 changed files with 161 additions and 112 deletions
  1. 0 0
      Makefile
  2. 51 37
      myocamlbuild.ml
  3. 110 75
      setup.ml

+ 0 - 0
Makefile


+ 51 - 37
myocamlbuild.ml

@@ -1,5 +1,5 @@
 (* OASIS_START *)
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 5a9a2168dcb86db37476d58b8c0e25b3) *)
+(* DO NOT EDIT (digest: 2b686a81cec9fb16d1640bda36a68fbd) *)
 module OASISGettext = struct
 module OASISGettext = struct
 (* # 22 "src/oasis/OASISGettext.ml" *)
 (* # 22 "src/oasis/OASISGettext.ml" *)
 
 
@@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct
     *)
     *)
   open Ocamlbuild_plugin
   open Ocamlbuild_plugin
 
 
+  type conf =
+    { no_automatic_syntax: bool;
+    }
 
 
   (* these functions are not really officially exported *)
   (* these functions are not really officially exported *)
   let run_and_read =
   let run_and_read =
@@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct
 
 
   (* This lists all supported packages. *)
   (* This lists all supported packages. *)
   let find_packages () =
   let find_packages () =
-    List.map before_space (split_nl & run_and_read "ocamlfind list")
+    List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))
 
 
 
 
   (* Mock to list available syntaxes. *)
   (* Mock to list available syntaxes. *)
@@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct
   ]
   ]
 
 
 
 
-  let dispatch =
+  let dispatch conf =
     function
     function
       | After_options ->
       | After_options ->
           (* By using Before_options one let command line options have an higher
           (* By using Before_options one let command line options have an higher
@@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct
            * -linkpkg *)
            * -linkpkg *)
           flag ["ocaml"; "link"; "program"] & A"-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 =
-              (* 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
-                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;
-            end
-            (find_packages ());
+          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
           (* Like -package but for extensions syntax. Morover -syntax is useless
            * when linking. *)
            * when linking. *)
@@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct
 
 
                    (* 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.
                     *)
                     *)
-                   dep ["link"; "ocaml"; "program"; 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"; "program"; 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 *)
@@ -580,25 +592,27 @@ module MyOCamlbuildBase = struct
             ()
             ()
 
 
 
 
-  let dispatch_default t =
+  let dispatch_default conf t =
     dispatch_combine
     dispatch_combine
       [
       [
         dispatch t;
         dispatch t;
-        MyOCamlbuildFindlib.dispatch;
+        MyOCamlbuildFindlib.dispatch conf;
       ]
       ]
 
 
 
 
 end
 end
 
 
 
 
-# 594 "myocamlbuild.ml"
+# 606 "myocamlbuild.ml"
 open Ocamlbuild_plugin;;
 open Ocamlbuild_plugin;;
 let package_default =
 let package_default =
   {MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []}
   {MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []}
   ;;
   ;;
 
 
-let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
+let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
+
+let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
 
 
-# 603 "myocamlbuild.ml"
+# 617 "myocamlbuild.ml"
 (* OASIS_STOP *)
 (* OASIS_STOP *)
 Ocamlbuild_plugin.dispatch dispatch_default;;
 Ocamlbuild_plugin.dispatch dispatch_default;;

+ 110 - 75
setup.ml

@@ -1,9 +1,9 @@
-(* setup.ml generated for the first time by OASIS v0.4.4 *)
+(* setup.ml generated for the first time by OASIS v0.4.5 *)
 
 
 (* OASIS_START *)
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 7afac2a7d590f3e7310d0937a63cf476) *)
+(* DO NOT EDIT (digest: 436bb003763bf6fbc311240ecf850d89) *)
 (*
 (*
-   Regenerated by OASIS v0.4.4
+   Regenerated by OASIS v0.4.5
    Visit http://oasis.forge.ocamlcore.org for more information and
    Visit http://oasis.forge.ocamlcore.org for more information and
    documentation about functions used in this file.
    documentation about functions used in this file.
 *)
 *)
@@ -242,11 +242,9 @@ module OASISString = struct
 
 
 
 
   let replace_chars f s =
   let replace_chars f s =
-    let buf = String.make (String.length s) 'X' in
-      for i = 0 to String.length s - 1 do
-        buf.[i] <- f s.[i]
-      done;
-      buf
+    let buf = Buffer.create (String.length s) in
+    String.iter (fun c -> Buffer.add_char buf (f c)) s;
+    Buffer.contents buf
 
 
 
 
 end
 end
@@ -1729,6 +1727,13 @@ module OASISFeatures = struct
       (fun () ->
       (fun () ->
         s_ "Allows the OASIS section comments and digest to be omitted in \
         s_ "Allows the OASIS section comments and digest to be omitted in \
             generated files.")
             generated files.")
+
+  let no_automatic_syntax =
+    create "no_automatic_syntax" alpha
+      (fun () ->
+         s_ "Disable the automatic inclusion of -syntax camlp4o for packages \
+             that matches the internal heuristic (if a dependency ends with \
+             a .syntax or is a well known syntax).")
 end
 end
 
 
 module OASISUnixPath = struct
 module OASISUnixPath = struct
@@ -2099,16 +2104,6 @@ module OASISLibrary = struct
         lst
         lst
     in
     in
 
 
-    (* The headers that should be compiled along *)
-    let headers =
-      if lib.lib_pack then
-        []
-      else
-        find_modules
-          lib.lib_modules
-          "cmi"
-    in
-
     (* The .cmx that be compiled along *)
     (* The .cmx that be compiled along *)
     let cmxs =
     let cmxs =
       let should_be_built =
       let should_be_built =
@@ -2134,12 +2129,32 @@ module OASISLibrary = struct
       []
       []
     in
     in
 
 
+    (* The headers and annot/cmt files that should be compiled along *)
+    let headers =
+      let sufx =
+        if lib.lib_pack
+        then [".cmti"; ".cmt"; ".annot"]
+        else [".cmi"; ".cmti"; ".cmt"; ".annot"]
+      in
+      List.map
+        begin
+          List.fold_left
+            begin fun accu s ->
+              let dot = String.rindex s '.' in
+              let base = String.sub s 0 dot in
+              List.map ((^) base) sufx @ accu
+            end
+            []
+        end
+        (find_modules lib.lib_modules "cmi")
+    in
+
     (* Compute what libraries should be built *)
     (* Compute what libraries should be built *)
     let acc_nopath =
     let acc_nopath =
       (* Add the packed header file if required *)
       (* Add the packed header file if required *)
       let add_pack_header acc =
       let add_pack_header acc =
         if lib.lib_pack then
         if lib.lib_pack then
-          [cs.cs_name^".cmi"] :: acc
+          [cs.cs_name^".cmi"; cs.cs_name^".cmti"; cs.cs_name^".cmt"] :: acc
         else
         else
           acc
           acc
       in
       in
@@ -2499,13 +2514,13 @@ module OASISFindlib = struct
     in
     in
 
 
     let library_name_of_findlib_name =
     let library_name_of_findlib_name =
-      Lazy.lazy_from_fun
-        (fun () ->
-           (* Revert findlib_name_of_library_name. *)
-           MapString.fold
-             (fun k v mp -> MapString.add v k mp)
-             fndlb_name_of_lib_name
-             MapString.empty)
+      lazy begin
+        (* Revert findlib_name_of_library_name. *)
+        MapString.fold
+          (fun k v mp -> MapString.add v k mp)
+          fndlb_name_of_lib_name
+          MapString.empty
+      end
     in
     in
     let library_name_of_findlib_name fndlb_nm =
     let library_name_of_findlib_name fndlb_nm =
       try
       try
@@ -2875,7 +2890,7 @@ module OASISFileUtil = struct
 end
 end
 
 
 
 
-# 2878 "setup.ml"
+# 2893 "setup.ml"
 module BaseEnvLight = struct
 module BaseEnvLight = struct
 (* # 22 "src/base/BaseEnvLight.ml" *)
 (* # 22 "src/base/BaseEnvLight.ml" *)
 
 
@@ -2980,7 +2995,7 @@ module BaseEnvLight = struct
 end
 end
 
 
 
 
-# 2983 "setup.ml"
+# 2998 "setup.ml"
 module BaseContext = struct
 module BaseContext = struct
 (* # 22 "src/base/BaseContext.ml" *)
 (* # 22 "src/base/BaseContext.ml" *)
 
 
@@ -5391,7 +5406,7 @@ module BaseSetup = struct
 end
 end
 
 
 
 
-# 5394 "setup.ml"
+# 5409 "setup.ml"
 module InternalConfigurePlugin = struct
 module InternalConfigurePlugin = struct
 (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)
 (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)
 
 
@@ -5827,6 +5842,17 @@ module InternalInstallPlugin = struct
           lst
           lst
     in
     in
 
 
+    let make_fnames modul sufx =
+      List.fold_right
+        begin fun sufx accu ->
+          (String.capitalize modul ^ sufx) ::
+          (String.uncapitalize modul ^ sufx) ::
+          accu
+        end
+        sufx
+        []
+    in
+
     (** Install all libraries *)
     (** Install all libraries *)
     let install_libs pkg =
     let install_libs pkg =
 
 
@@ -5847,27 +5873,29 @@ module InternalInstallPlugin = struct
                   OASISHostPath.of_unix bs.bs_path
                   OASISHostPath.of_unix bs.bs_path
                 in
                 in
                   List.fold_left
                   List.fold_left
-                    (fun acc modul ->
-                       try
-                         List.find
-                           OASISFileUtil.file_exists_case
-                           (List.map
-                              (Filename.concat path)
-                              [modul^".mli";
-                               modul^".ml";
-                               String.uncapitalize modul^".mli";
-                               String.capitalize   modul^".mli";
-                               String.uncapitalize modul^".ml";
-                               String.capitalize   modul^".ml"])
-                         :: acc
-                       with Not_found ->
-                         begin
-                           warning
-                             (f_ "Cannot find source header for module %s \
-                                  in library %s")
-                             modul cs.cs_name;
-                           acc
-                         end)
+                    begin fun acc modul ->
+                      begin
+                        try
+                          [List.find
+                            OASISFileUtil.file_exists_case
+                            (List.map
+                               (Filename.concat path)
+                               (make_fnames modul [".mli"; ".ml"]))]
+                        with Not_found ->
+                          warning
+                            (f_ "Cannot find source header for module %s \
+                                 in library %s")
+                            modul cs.cs_name;
+                          []
+                      end
+                      @
+                      List.filter
+                        OASISFileUtil.file_exists_case
+                        (List.map
+                           (Filename.concat path)
+                           (make_fnames modul [".annot";".cmti";".cmt"]))
+                      @ acc
+                    end
                     acc
                     acc
                     lib.lib_modules
                     lib.lib_modules
               in
               in
@@ -5915,27 +5943,29 @@ module InternalInstallPlugin = struct
                   OASISHostPath.of_unix bs.bs_path
                   OASISHostPath.of_unix bs.bs_path
                 in
                 in
                   List.fold_left
                   List.fold_left
-                    (fun acc modul ->
-                       try
-                         List.find
-                           OASISFileUtil.file_exists_case
-                           (List.map
-                              (Filename.concat path)
-                              [modul^".mli";
-                               modul^".ml";
-                               String.uncapitalize modul^".mli";
-                               String.capitalize   modul^".mli";
-                               String.uncapitalize modul^".ml";
-                               String.capitalize   modul^".ml"])
-                         :: acc
-                       with Not_found ->
-                         begin
-                           warning
-                             (f_ "Cannot find source header for module %s \
-                                  in object %s")
-                             modul cs.cs_name;
-                           acc
-                         end)
+                    begin fun acc modul ->
+                      begin
+                        try
+                          [List.find
+                             OASISFileUtil.file_exists_case
+                             (List.map
+                                (Filename.concat path)
+                                (make_fnames modul [".mli"; ".ml"]))]
+                        with Not_found ->
+                          warning
+                            (f_ "Cannot find source header for module %s \
+                                 in object %s")
+                            modul cs.cs_name;
+                          []
+                      end
+                      @
+                      List.filter
+                        OASISFileUtil.file_exists_case
+                        (List.map
+                           (Filename.concat path)
+                           (make_fnames modul [".annot";".cmti";".cmt"]))
+                      @ acc
+                    end
                     acc
                     acc
                     obj.obj_modules
                     obj.obj_modules
               in
               in
@@ -6240,7 +6270,7 @@ module InternalInstallPlugin = struct
 end
 end
 
 
 
 
-# 6243 "setup.ml"
+# 6273 "setup.ml"
 module OCamlbuildCommon = struct
 module OCamlbuildCommon = struct
 (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
 (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
 
 
@@ -6298,6 +6328,11 @@ module OCamlbuildCommon = struct
         else
         else
           [];
           [];
 
 
+        if bool_of_string (tests ()) then
+          ["-tag"; "tests"]
+        else
+          [];
+
         if bool_of_string (profile ()) then
         if bool_of_string (profile ()) then
           ["-tag"; "profile"]
           ["-tag"; "profile"]
         else
         else
@@ -6613,7 +6648,7 @@ module OCamlbuildDocPlugin = struct
 end
 end
 
 
 
 
-# 6616 "setup.ml"
+# 6651 "setup.ml"
 open OASISTypes;;
 open OASISTypes;;
 
 
 let setup_t =
 let setup_t =
@@ -6742,7 +6777,7 @@ let setup_t =
           plugin_data = []
           plugin_data = []
        };
        };
      oasis_fn = Some "_oasis";
      oasis_fn = Some "_oasis";
-     oasis_version = "0.4.4";
+     oasis_version = "0.4.5";
      oasis_digest = Some "\231'\229\025\213\168=)4\1302\015\206v\139\027";
      oasis_digest = Some "\231'\229\025\213\168=)4\1302\015\206v\139\027";
      oasis_exec = None;
      oasis_exec = None;
      oasis_setup_args = [];
      oasis_setup_args = [];
@@ -6751,6 +6786,6 @@ let setup_t =
 
 
 let setup () = BaseSetup.setup setup_t;;
 let setup () = BaseSetup.setup setup_t;;
 
 
-# 6755 "setup.ml"
+# 6790 "setup.ml"
 (* OASIS_STOP *)
 (* OASIS_STOP *)
 let () = setup ();;
 let () = setup ();;