diff options
Diffstat (limited to 'ocamlbuild/ocaml_utils.ml')
-rw-r--r-- | ocamlbuild/ocaml_utils.ml | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/ocamlbuild/ocaml_utils.ml b/ocamlbuild/ocaml_utils.ml index 6eaff007b..3174819cf 100644 --- a/ocamlbuild/ocaml_utils.ml +++ b/ocamlbuild/ocaml_utils.ml @@ -52,11 +52,14 @@ let module_importance modpath x = else if ignore_stdlib x then `just_try else `mandatory let expand_module include_dirs module_name exts = + let dirname = Pathname.dirname module_name in + let basename = Pathname.basename module_name in + let module_name_cap = dirname/(String.capitalize basename) in + let module_name_uncap = dirname/(String.uncapitalize basename) in List.fold_right begin fun include_dir -> List.fold_right begin fun ext acc -> - let module_name_ext = module_name-.-ext in - include_dir/(String.uncapitalize module_name_ext) :: - include_dir/(String.capitalize module_name_ext) :: acc + include_dir/(module_name_uncap-.-ext) :: + include_dir/(module_name_cap-.-ext) :: acc end exts end include_dirs [] @@ -96,10 +99,15 @@ let ocaml_lib ?(extern=false) ?(byte=true) ?(native=true) ?dir ?tag_name libpath | None -> "use_" ^ Pathname.basename libpath in Hashtbl.replace info_libraries tag_name (libpath, extern); - if byte then - flag ["ocaml"; tag_name; "link"; "byte"] (add_dir (A (libpath^".cma"))); - if native then - flag ["ocaml"; tag_name; "link"; "native"] (add_dir (A (libpath^".cmxa"))); + if extern then begin + if byte then + flag ["ocaml"; tag_name; "link"; "byte"] (add_dir (A (libpath^".cma"))); + if native then + flag ["ocaml"; tag_name; "link"; "native"] (add_dir (A (libpath^".cmxa"))); + end else begin + if not byte && not native then + invalid_arg "ocaml_lib: ~byte:false or ~native:false only works with ~extern:true"; + end; match dir with | None -> () | Some dir -> flag ["ocaml"; tag_name; "compile"] (S[A"-I"; P dir]) |