[make] Add target to generate interface file

Summary:
This diff adds a make target to generate interface files from
implementation files.  These generated interface files can then be used
as a starting point for documenting and restricting the exposed module
interface.  For example, to generate an interface for JavaTaintAnalysis.ml,
execute:
```
make -C infer/src M=quandary/JavaTaintAnalysis mli
```
Note that this relies on `ocamlc -i`, which for reason currently
produces syntactically ill-formed files.

Reviewed By: sblackshear, jvillard

Differential Revision: D3998175

fbshipit-source-id: f653737
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent cb4b2339a3
commit 4319b08e77

@ -190,7 +190,7 @@ inferTraceBugs_test: infer
check_missing_mli:
@bash -c '\
for x in `find infer/src -name "*.ml"`; do \
for x in `find infer/src -name "*.ml" -or -name "*.re"`; do \
test -f "$$x"i || echo Missing "$$x"i; done'
inferScriptMode_test: toplevel

@ -215,6 +215,21 @@ test_build: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) $(CLANG_AT
-cflags -warn-error,$(OCAML_FATAL_WARNINGS) \
$(INFER_ALL_TARGETS:.native=.byte)
# to generate interface file.mli from implementation file.ml execute:
# make M=file mli
mli:
ocamlfind ocamlc -package atdgen,extlib,oUnit,str,unix,yojson,zip $(addprefix -I ../_build/infer/,$(DEPENDENCIES)) -i $(M).ml > $(M).mli
rei:
ocamlfind ocamlc -package atdgen,extlib,oUnit,str,unix,yojson,zip $(addprefix -I ../_build/infer/,$(DEPENDENCIES)) -i -pp refmt -impl $(M).re > $(M).rei
# convert to reason
%.re : %.ml
refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.re
%.rei : %.mli
refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.rei
roots:=Infer InferAnalyze InferClang CMain JMain InferPrint BuckCompilationDatabase
clusters:=base clang java IR
@ -346,10 +361,3 @@ endif
$(REMOVE) $(INFER_CLANG_FCP_MIRRORED_FILES)
$(REMOVE) mod_dep.dot
$(REMOVE) mod_dep.pdf
# convert to reason
%.re : %.ml
refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.re
%.rei : %.mli
refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.rei

Loading…
Cancel
Save