Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ocamldep: add -plugin and use compilerlibs to build (ocaml#1015)
* ocamldep: add -plugin argument, and use compilerlibs to build
  • Loading branch information
lefessan committed Mar 2, 2017
1 parent cb1d427 commit cbb2049
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Changes
Expand Up @@ -106,6 +106,10 @@ Next version (4.05.0):
spent in subprocesses like preprocessors
(Valentin Gatien-Baron, review by Gabriel Scherer)

- GPR#1015: add option "-plugin PLUGIN" to ocamldep too. Use compilerlibs
to build ocamldep.
(Fabrice Le Fessant)

### Standard library:

- PR#6975, GPR#902: Truncate function added to stdlib Buffer module
Expand Down
17 changes: 17 additions & 0 deletions man/ocamldep.m
Expand Up @@ -155,6 +155,23 @@ causes dependencies on native compiled files (.cmx) to be generated instead
is opened before parsing each of the
following files.
.TP
.BI \-plugin \ plugin
Dynamically load the code of the given
.I plugin
(a .cmo, .cma or .cmxs file) in
.BR ocamldep (1).
The plugin must exist in
the same kind of code as the tool (
.BR ocamldep.byte
must load bytecode
plugins, while
.BR ocamldep.opt
must load native code plugins), and
extension adaptation is done automatically for .cma files (to .cmxs files
if
.BR ocamldep (1)
is compiled in native code).
.TP
.BI \-pp \ command
Cause
.BR ocamldep (1)
Expand Down
8 changes: 8 additions & 0 deletions manual/manual/cmds/depend.etex
Expand Up @@ -111,6 +111,14 @@ Output one line per file, regardless of the length.
Assume that module \var{module} is opened before parsing each of the
following files.

\item["-plugin" \var{plugin}]
Dynamically load the code of the given \var{plugin}
(a ".cmo", ".cma" or ".cmxs" file) in "ocamldep". \var{plugin} must exist in
the same kind of code as "ocamldep" ("ocamldep.byte" must load bytecode
plugins, while "ocamldep.opt" must load native code plugins), and
extension adaptation is done automatically for ".cma" files (to ".cmxs" files
if "ocamldep" is compiled in native code).

\item["-pp" \var{command}]
Cause "ocamldep" to call the given \var{command} as a preprocessor
for each source file.
Expand Down
11 changes: 3 additions & 8 deletions tools/Makefile
Expand Up @@ -108,14 +108,9 @@ VPATH := $(filter-out -I,$(INCLUDES))
# The dependency generator

CAMLDEP_OBJ=ocamldep.cmo
CAMLDEP_IMPORTS=timings.cmo misc.cmo config.cmo identifiable.cmo numbers.cmo \
arg_helper.cmo clflags.cmo terminfo.cmo \
warnings.cmo location.cmo longident.cmo docstrings.cmo \
syntaxerr.cmo ast_helper.cmo parser.cmo lexer.cmo parse.cmo \
ccomp.cmo ast_mapper.cmo ast_iterator.cmo \
builtin_attributes.cmo ast_invariants.cmo \
pparse.cmo compenv.cmo depend.cmo

CAMLDEP_IMPORTS= \
../compilerlibs/ocamlcommon.cma \
../compilerlibs/ocamlbytecomp.cma
ocamldep: LINKFLAGS += -compat-32
$(call byte_and_opt,ocamldep,$(CAMLDEP_IMPORTS) $(CAMLDEP_OBJ),)
ocamldep: depend.cmi
Expand Down
7 changes: 5 additions & 2 deletions tools/ocamldep.ml
Expand Up @@ -546,7 +546,7 @@ let _ =
Clflags.classic := false;
add_to_list first_include_dirs Filename.current_dir_name;
Compenv.readenv ppf Before_args;
Arg.parse_expand [
Clflags.add_arguments __LOC__ [
"-absname", Arg.Set Location.absname,
" Show absolute filenames in error messages";
"-all", Arg.Set all_dependencies,
Expand Down Expand Up @@ -580,6 +580,8 @@ let _ =
" 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";
"-plugin", Arg.String Compplugin.load,
"<plugin> Load dynamic plugin <plugin>";
"-pp", Arg.String(fun s -> Clflags.preprocessor := Some s),
"<cmd> Pipe sources through preprocessor <cmd>";
"-ppx", Arg.String (add_to_list first_ppx),
Expand All @@ -598,7 +600,8 @@ let _ =
"-args0", Arg.Expand Arg.read_arg0,
"<file> Read additional NUL separated command line arguments from \n\
\ <file>"
] file_dependencies usage;
];
Clflags.parse_arguments file_dependencies usage;
Compenv.readenv ppf Before_link;
if !sort_files then sort_files_by_dependencies !files
else List.iter print_file_dependencies (List.sort compare !files);
Expand Down

0 comments on commit cbb2049

Please sign in to comment.