diff options
author | Maxence Guesdon <maxence.guesdon@inria.fr> | 2004-01-28 13:36:20 +0000 |
---|---|---|
committer | Maxence Guesdon <maxence.guesdon@inria.fr> | 2004-01-28 13:36:20 +0000 |
commit | 2b54201f20cebcb1dfc6f69d4c7f893c6850813e (patch) | |
tree | 9add9100e1552948f515cf11f885f9d65a449533 /ocamldoc/odoc.ml | |
parent | 25d02fa881739fecc74e2fb735ec714c166f54b0 (diff) | |
download | ocaml-2b54201f20cebcb1dfc6f69d4c7f893c6850813e.tar.gz |
handling a path to load custom generators
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6087 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'ocamldoc/odoc.ml')
-rw-r--r-- | ocamldoc/odoc.ml | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/ocamldoc/odoc.ml b/ocamldoc/odoc.ml index c8a1d9368a..b1b6477ef9 100644 --- a/ocamldoc/odoc.ml +++ b/ocamldoc/odoc.ml @@ -19,6 +19,8 @@ open Misc open Format open Typedtree +module M = Odoc_messages + let print_DEBUG s = print_string s ; print_newline () (* we check if we must load a module given on the command line *) @@ -36,10 +38,30 @@ let (cmo_or_cma_opt, paths) = | _ :: q -> iter (f_opt, inc) q in - iter (None, []) arg_list + iter (None, [Odoc_config.custom_generators_path]) arg_list let _ = print_DEBUG "Fin analyse des arguments pour le dynamic load" +(** Return the real name of the file to load, + searching it in the paths if it is + a simple name and not in the current directory. *) +let get_real_filename name = + if Filename.basename name <> name then + name + else + ( + let paths = Filename.current_dir_name :: paths in + try + let d = List.find + (fun d -> Sys.file_exists (Filename.concat d name)) + paths + in + Filename.concat d name + with + Not_found -> + failwith (M.file_not_found_in_paths paths name) + ) + let _ = match cmo_or_cma_opt with None -> @@ -50,8 +72,8 @@ let _ = Dynlink.allow_unsafe_modules true; try Dynlink.add_available_units Odoc_crc.crc_unit_list ; - let _ = Dynlink.loadfile file in - () + let real_file = get_real_filename file in + ignore(Dynlink.loadfile real_file) with Dynlink.Error e -> prerr_endline (Odoc_messages.load_file_error file (Dynlink.error_message e)) ; @@ -59,7 +81,8 @@ let _ = | Not_found -> prerr_endline (Odoc_messages.load_file_error file "Not_found"); exit 1 - | Sys_error s -> + | Sys_error s + | Failure s -> prerr_endline (Odoc_messages.load_file_error file s); exit 1 |