Skip to content

Commit

Permalink
PR#5628: Add Topdirs.remove_directory (and directive #remove_director…
Browse files Browse the repository at this point in the history
…y) to remove a directory from the load path

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12660 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
gasche committed Jul 7, 2012
1 parent 1c7f208 commit b667a00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Feature wishes:
- PR#5555: Add function Hashtbl.reset to resize the bucket table to
its initial size.
- PR#5599: Add warn() tag in ocamlbuild to control -w compiler switch
- PR#5628: add #remove_directory and Topdirs.remove_directory to remove
a directory from the load path
- PR#5636: in system threads library, issue with linking of pthread_atfork
- ocamldebug: ability to inspect values that contain code pointers
- ocamldebug: new 'environment' directive to set environment variables
Expand Down
3 changes: 3 additions & 0 deletions bytecomp/dll.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ let names_of_opened_dlls = ref ([] : string list)
let add_path dirs =
search_path := dirs @ !search_path

let remove_path dirs =
search_path := List.filter (fun d -> not (List.mem d dirs)) !search_path

(* Extract the name of a DLLs from its external name (xxx.so or -lxxx) *)

let extract_dll_name file =
Expand Down
3 changes: 3 additions & 0 deletions bytecomp/dll.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ val synchronize_primitive: int -> dll_address -> unit
(* Add the given directories at the head of the search path for DLLs *)
val add_path: string list -> unit

(* Remove the given directories from the search path for DLLs *)
val remove_path: string list -> unit

(* Initialization for separate compilation.
Initialize the DLL search path to the directories given in the
environment variable CAML_LD_LIBRARY_PATH, plus contents of ld.conf file
Expand Down
10 changes: 10 additions & 0 deletions toplevel/topdirs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ let dir_directory s =

let _ = Hashtbl.add directive_table "directory" (Directive_string dir_directory)

(* To remove a directory from the load path *)
let dir_remove_directory s =
let d = expand_directory Config.standard_library s in
Config.load_path := List.filter (fun d' -> d' <> d) !Config.load_path;
Dll.remove_path [d]

let _ =
Hashtbl.add directive_table "remove_directory"
(Directive_string dir_remove_directory)

(* To change the current directory *)

let dir_cd s = Sys.chdir s
Expand Down
1 change: 1 addition & 0 deletions toplevel/topdirs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ open Format

val dir_quit : unit -> unit
val dir_directory : string -> unit
val dir_remove_directory : string -> unit
val dir_cd : string -> unit
val dir_load : formatter -> string -> unit
val dir_use : formatter -> string -> unit
Expand Down

0 comments on commit b667a00

Please sign in to comment.