From aad4f581e85f23e845a8672873ba319b7da9410e Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 13 May 2020 02:38:32 -0700 Subject: [PATCH] [deadcode] create deadcode/dune only when needed Summary: Ever since deadcode/dune stopped being a dune.in file that created the dune file on the fly, `make check` stopped working because it now tried to build the "deadcode" executable but usually all_infer_in_one_file.ml isn't around and so it fails. Only create deadcode/dune when needed to avoid dune taking deadcode/ into account on most operations. Reviewed By: ezgicicek Differential Revision: D21528811 fbshipit-source-id: 040e4c138 --- .gitignore | 1 + infer/src/deadcode/Makefile | 16 +++++++++------- infer/src/deadcode/{dune => dune.in} | 0 3 files changed, 10 insertions(+), 7 deletions(-) rename infer/src/deadcode/{dune => dune.in} (100%) diff --git a/.gitignore b/.gitignore index 4ea3f453b..12e91376d 100644 --- a/.gitignore +++ b/.gitignore @@ -180,5 +180,6 @@ infer/src/.project /infer/src/deadcode/all_mli_files_copied /infer/src/deadcode/*.ml /infer/src/deadcode/*.mli +/infer/src/deadcode/dune _opam _coverage diff --git a/infer/src/deadcode/Makefile b/infer/src/deadcode/Makefile index 41e0ecc7f..ba0a95667 100644 --- a/infer/src/deadcode/Makefile +++ b/infer/src/deadcode/Makefile @@ -163,13 +163,17 @@ $(ml_src_files_without_mli:.ml=.cmx): flatten_infer: infer.cmx inferunit.cmx InferCreateTraceViewLinks.cmx scripts/checkCopyright.cmx $(QUIET)echo "see results in $(ALL_INFER_IN_ONE_FILE_ML)" +# copy dune.in to dune only when needed to avoid dune trying to build +# all_infer_in_one_file as part of the rest of the build +dune: dune.in + $(QUIET)$(INSTALL_DATA) $< $@ + .PHONY: detect_dead_code -detect_dead_code: - $(MAKE) clean +detect_dead_code: dune # create a dummy implementation file to keep dune happy, as we are about to generate the # dune file for this directory touch $(ALL_INFER_IN_ONE_FILE_ML) $(ALL_INFER_IN_ONE_FILE_ML:.ml=.mli) -# needed to get dune generated, and the generated code for the lexers and parsers in ../_build +# needed to get the generated code for the lexers and parsers in ../_build $(MAKE) -C .. test $(MAKE) depend # Need to be sequential to avoid getting a garbled file. Need to re-include .depend as it may @@ -184,9 +188,7 @@ detect_dead_code: $(MAKE) -j 1 detect_dead_src_file # build and get dead code warnings dune build --profile test all_infer_in_one_file.bc -# be paranoid about cleaning because we do not want to include infer_in_one_file into infer by -# accident and I don't know enough dune to be positive that it won't happen - $(MAKE) clean + $(REMOVE) dune .PHONY: detect_dead_src_file detect_dead_src_file: @@ -238,5 +240,5 @@ detect_dead_src_file: .PHONY: clean clean: $(REMOVE) .depend *.ml *.mli $(ALL_ML_FILES) $(ALL_MLI_FILES) $(ALL_ML_FILES_COPIED) \ - $(ALL_MLI_FILES_COPIED) + $(ALL_MLI_FILES_COPIED) dune diff --git a/infer/src/deadcode/dune b/infer/src/deadcode/dune.in similarity index 100% rename from infer/src/deadcode/dune rename to infer/src/deadcode/dune.in