From bf2a0cfc53089b0d82583622ec7ee440541af895 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 11 Jul 2017 04:29:24 -0700 Subject: [PATCH] Prepare to format OCaml and convert Reason code Summary: Add support for converting without actually converting. To be used as a landing pad for rebasing over the conversion. Reviewed By: jvillard Differential Revision: D5379967 fbshipit-source-id: 1bd932d --- .ocamlformat | 2 ++ Makefile | 26 ++++++++++++++++++- configure.ac | 2 +- ...tch_script.ml => infer_batch_script.mltop} | 0 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .ocamlformat rename infer/tests/repl/{infer_batch_script.ml => infer_batch_script.mltop} (100%) diff --git a/.ocamlformat b/.ocamlformat new file mode 100644 index 000000000..1c7efde5c --- /dev/null +++ b/.ocamlformat @@ -0,0 +1,2 @@ +margin 100 +sparse true diff --git a/Makefile b/Makefile index 661e016b2..a3c8300e2 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,30 @@ fb-setup: $(QUIET)$(call silent_on_success,Facebook setup,\ $(MAKE) -C facebook setup) +OCAMLFORMAT_EXE=facebook/dependencies/ocamlformat/src/_build/opt/ocamlformat.exe + +SRC_ML:=$(shell find * \( -name _build -or -name facebook-clang-plugins -or -path facebook/dependencies \) -not -prune -or -type f -and -name '*'.ml -or -name '*'.mli 2>/dev/null) + +.PHONY: fmt_all_ml +fmt_all_ml: + parallel $(OCAMLFORMAT_EXE) --no-warn-error -i -- $(SRC_ML) + +SRC_RE:=$(shell find infer/src -name '*'.re 2>/dev/null) +SRC_REI:=$(shell find infer/src -name '*'.rei 2>/dev/null) +SRC_RE_ML:=$(patsubst %.re,%.ml,$(SRC_RE)) +SRC_REI_MLI:=$(patsubst %.rei,%.mli,$(SRC_REI)) + +%.ml: %.re + refmt --print=binary_reason $< | $(OCAMLFORMAT_EXE) $< --reason-impl -o $@ + +%.mli: %.rei + refmt --print=binary_reason $< | $(OCAMLFORMAT_EXE) $< --reason-intf -o $@ + +.PHONY: fmt_all +fmt_all: fmt_all_ml $(SRC_RE_ML) $(SRC_REI_MLI) + git add $(SRC_RE_ML) $(SRC_REI_MLI) + rm -f $(SRC_RE) $(SRC_REI) + .PHONY: src_build src_build: $(QUIET)$(call silent_on_success,Building native Infer,\ @@ -308,7 +332,7 @@ toplevel: clang_plugin inferScriptMode_test: test_build $(QUIET)$(call silent_on_success,Testing infer OCaml REPL,\ INFER_REPL_BINARY=ocaml TOPLEVEL_DIR=$(BUILD_DIR)/test/infer $(SCRIPT_DIR)/infer_repl \ - $(INFER_DIR)/tests/repl/infer_batch_script.ml) + $(INFER_DIR)/tests/repl/infer_batch_script.mltop) .PHONY: checkCopyright checkCopyright: diff --git a/configure.ac b/configure.ac index 637ba557e..cfc0c37a1 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AC_INIT([Infer], [0.12.0], [https://github.com/facebook/infer/issues/]) -AC_CONFIG_SRCDIR([infer/src/IR/Sil.re]) +AC_CONFIG_SRCDIR([infer/src/base/IStd.ml]) # WARNING: keep in sync with above INFER_MAJOR=0 diff --git a/infer/tests/repl/infer_batch_script.ml b/infer/tests/repl/infer_batch_script.mltop similarity index 100% rename from infer/tests/repl/infer_batch_script.ml rename to infer/tests/repl/infer_batch_script.mltop