diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2005-01-28 17:52:58 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2005-01-28 17:52:58 +0000 |
commit | df6f81e16ca9847ff0cc50471adf8f649bc505be (patch) | |
tree | f2783f0fe04776fc0ee8b8b7eac13486f7dd8d64 | |
parent | 5f122919460e36f03c69d2b20181572592e12b71 (diff) |
PR#3328 option ocaml -init <fichier>
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6758 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | toplevel/toploop.ml | 15 | ||||
-rw-r--r-- | toplevel/topmain.ml | 2 | ||||
-rw-r--r-- | utils/clflags.ml | 1 |
3 files changed, 13 insertions, 5 deletions
diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml index 6757abf34..a8bb58297 100644 --- a/toplevel/toploop.ml +++ b/toplevel/toploop.ml @@ -368,11 +368,16 @@ let _ = crc_intfs let load_ocamlinit ppf = - let home_init = - try Filename.concat (Sys.getenv "HOME") ".ocamlinit" - with Not_found -> ".ocamlinit" in - if Sys.file_exists ".ocamlinit" then ignore(use_silently ppf ".ocamlinit") - else if Sys.file_exists home_init then ignore(use_silently ppf home_init) + match !Clflags.init_file with + | Some f -> if Sys.file_exists f then ignore (use_silently ppf f) + else fprintf ppf "Init file not found: \"%s\".@." f + | None -> + if Sys.file_exists ".ocamlinit" then ignore (use_silently ppf ".ocamlinit") + else try + let home_init = Filename.concat (Sys.getenv "HOME") ".ocamlinit" in + if Sys.file_exists home_init then ignore (use_silently ppf home_init) + with Not_found -> () +;; let set_paths () = (* Add whatever -I options have been specified on the command line, diff --git a/toplevel/topmain.ml b/toplevel/topmain.ml index fadfb57c5..012951675 100644 --- a/toplevel/topmain.ml +++ b/toplevel/topmain.ml @@ -56,6 +56,8 @@ let main () = let dir = Misc.expand_directory Config.standard_library dir in include_dirs := dir :: !include_dirs), "<dir> Add <dir> to the list of include directories"; + "-init", Arg.String (fun s -> init_file := Some s), + "<file> Load <file> instead of default init file"; "-labels", Arg.Clear classic, " Labels commute (default)"; "-noassert", Arg.Set noassert, " Do not compile assertion checks"; "-nolabels", Arg.Set classic, " Ignore labels and do not commute"; diff --git a/utils/clflags.ml b/utils/clflags.ml index 4d7987565..e51e430c9 100644 --- a/utils/clflags.ml +++ b/utils/clflags.ml @@ -39,6 +39,7 @@ and use_vmthreads = ref false (* -vmthread *) and noassert = ref false (* -noassert *) and verbose = ref false (* -verbose *) and noprompt = ref false (* -noprompt *) +and init_file = ref (None : string option) (* -init *) and use_prims = ref "" (* -use-prims ... *) and use_runtime = ref "" (* -use-runtime ... *) and principal = ref false (* -principal *) |