summaryrefslogtreecommitdiff
path: root/tools/ocamldep.ml
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2014-10-03 20:31:34 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2014-10-03 20:31:34 +0000
commit97cff22e455737ebbe1b863db979addb01553253 (patch)
treedf0f9acf02c94fa9d9891d2bf70a147e39ce18fd /tools/ocamldep.ml
parentdfcccc7999587195625a71a2051c9d75673a9dfd (diff)
downloadocaml-97cff22e455737ebbe1b863db979addb01553253.tar.gz
ocamldep support for -open
Adding an `open_module` function to the Depend interface instead of directly mutating `free_structure_names` makes the approach robust to eventual improvement to ocamldep's handling of `open` (for example, in presence of .cmi for the opened units it could add their submodules to the set of bound vars). This only goes so far, however, as the overall imperative style would not nicely support proper local handling of `let open M in e`. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15468 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools/ocamldep.ml')
-rw-r--r--tools/ocamldep.ml12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index 0ca6adb191..db0695c9c7 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -223,8 +223,14 @@ let read_parse_and_extract parse_function extract_function magic source_file =
let input_file = Pparse.preprocess source_file in
begin try
let ast =
- Pparse.file ~tool_name Format.err_formatter input_file parse_function magic in
- extract_function Depend.StringSet.empty ast;
+ Pparse.file ~tool_name Format.err_formatter
+ input_file parse_function magic
+ in
+ let bound_vars = Depend.StringSet.empty in
+ List.iter (fun modname ->
+ Depend.open_module bound_vars (Longident.Lident modname)
+ ) !Clflags.open_modules;
+ extract_function bound_vars ast;
Pparse.remove_preprocessed input_file;
!Depend.free_structure_names
with x ->
@@ -431,6 +437,8 @@ let _ =
" Generate dependencies for native-code only (no .cmo files)";
"-one-line", Arg.Set one_line,
" Output one line per file, regardless of the length";
+ "-open", Arg.String (add_to_list Clflags.open_modules),
+ "<module> Opens the module <module> before typing";
"-pp", Arg.String(fun s -> Clflags.preprocessor := Some s),
"<cmd> Pipe sources through preprocessor <cmd>";
"-ppx", Arg.String (add_to_list first_ppx),