[make] make infer/src/Makefile less phony

Reviewed By: jberdine

Differential Revision: D4319515

fbshipit-source-id: 607022c
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 475f37ea03
commit bce1a1ff2e

7
.gitignore vendored

@ -80,7 +80,6 @@ buck-out/
/infer/bin/InferUnit /infer/bin/InferUnit
/infer/bin/Typeprop /infer/bin/Typeprop
/infer/bin/infer /infer/bin/infer
/infer/bin/inferTraceBugs
/infer/src/base/Version.ml /infer/src/base/Version.ml
/infer/models/java/models/ /infer/models/java/models/
/infer/models/java/models.jar /infer/models/java/models.jar
@ -93,12 +92,6 @@ buck-out/
/infer/lib/specs/cpp_models /infer/lib/specs/cpp_models
/infer/lib/specs/objc_models /infer/lib/specs/objc_models
/infer/lib/specs/clean_models /infer/lib/specs/clean_models
/infer/lib/wrappers/c++
/infer/lib/wrappers/cc
/infer/lib/wrappers/clang
/infer/lib/wrappers/clang++
/infer/lib/wrappers/g++
/infer/lib/wrappers/gcc
/scripts/checkCopyright /scripts/checkCopyright
/infer/etc/clang_ast.dict /infer/etc/clang_ast.dict
/infer/src/toplevel.mlpack /infer/src/toplevel.mlpack

@ -38,31 +38,14 @@ DIRECT_TESTS += objc_frontend_test objc_errors_test objc_linters_test objcpp_fro
endif endif
.PHONY: all .PHONY: all
all: infer inferTraceBugs all: infer
# executable names that should point to InferClang to trigger capture
INFERCLANG_WRAPPERS_BASENAMES = c++ cc clang clang++ g++ gcc
INFERCLANG_WRAPPERS_PATHS = $(foreach cc,$(INFERCLANG_WRAPPERS_BASENAMES),$(LIB_DIR)/wrappers/$(cc))
$(INFERCLANG_WRAPPERS_PATHS): Makefile
$(REMOVE) $@ && \
cd $(@D) && \
$(LN_S) ../../bin/InferClang $(@F)
$(BIN_DIR):
$(MKDIR_P) $@
$(INFERTRACEBUGS_BIN_RELPATH): Makefile $(BIN_DIR)
$(REMOVE) $@ && \
cd $(@D) && \
$(LN_S) ../lib/python/$(@F) $(@F)
.PHONY: src_build .PHONY: src_build
src_build: src_build:
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
$(MAKE) -C facebook @$(MAKE) -C facebook
endif endif
$(MAKE) -C $(SRC_DIR) infer @$(MAKE) -C $(SRC_DIR) infer
ifeq ($(BUILD_C_ANALYZERS),yes) ifeq ($(BUILD_C_ANALYZERS),yes)
src_build: clang_plugin src_build: clang_plugin
endif endif
@ -70,31 +53,28 @@ endif
.PHONY: infer .PHONY: infer
infer: src_build infer: src_build
ifeq ($(BUILD_JAVA_ANALYZERS),yes) ifeq ($(BUILD_JAVA_ANALYZERS),yes)
$(MAKE) -C $(ANNOTATIONS_DIR) @$(MAKE) -C $(ANNOTATIONS_DIR)
endif
$(MAKE) -C $(MODELS_DIR) all
ifeq ($(BUILD_C_ANALYZERS),yes)
infer: $(INFERCLANG_WRAPPERS_PATHS)
endif endif
@$(MAKE) -C $(MODELS_DIR) all
.PHONY: clang_setup .PHONY: clang_setup
clang_setup: clang_setup:
export CC="$(CC)" CFLAGS="$(CFLAGS)"; \ @export CC="$(CC)" CFLAGS="$(CFLAGS)"; \
export CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)"; \ export CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)"; \
export CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)"; \ export CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)"; \
$(FCP_DIR)/clang/setup.sh $(INFER_FCP_SETUP_OPTS) $(FCP_DIR)/clang/setup.sh $(INFER_FCP_SETUP_OPTS) > /dev/null
.PHONY: clang_plugin .PHONY: clang_plugin
clang_plugin: clang_setup clang_plugin: clang_setup
ifeq ($(IS_RELEASE_TREE),no) ifeq ($(IS_RELEASE_TREE),no)
$(MAKE) -C $(FCP_DIR)/libtooling all \ @$(MAKE) -C $(FCP_DIR)/libtooling all \
CC=$(CC) CXX=$(CXX) \ CC=$(CC) CXX=$(CXX) \
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \
LOCAL_CLANG=$(CLANG_PREFIX)/bin/clang \ LOCAL_CLANG=$(CLANG_PREFIX)/bin/clang \
CLANG_PREFIX=$(CLANG_PREFIX) \ CLANG_PREFIX=$(CLANG_PREFIX) \
CLANG_INCLUDES=$(CLANG_INCLUDES) CLANG_INCLUDES=$(CLANG_INCLUDES)
$(MAKE) -C $(FCP_DIR)/clang-ocaml all \ @$(MAKE) -C $(FCP_DIR)/clang-ocaml all \
build/clang_ast_proj.ml build/clang_ast_proj.mli \ build/clang_ast_proj.ml build/clang_ast_proj.mli \
CC=$(CC) CXX=$(CXX) \ CC=$(CC) CXX=$(CXX) \
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
@ -104,29 +84,16 @@ ifeq ($(IS_RELEASE_TREE),no)
CLANG_INCLUDES=$(CLANG_INCLUDES) CLANG_INCLUDES=$(CLANG_INCLUDES)
endif endif
.PHONY: inferTraceBugs
inferTraceBugs: $(INFERTRACEBUGS_BIN_RELPATH)
.PHONY: test_this_build
test_this_build: clang_plugin
ifeq ($(IS_FACEBOOK_TREE),yes)
$(MAKE) -C facebook
endif
$(MAKE) -C $(SRC_DIR) test_build
.PHONY: test_oss_build
test_oss_build: clang_plugin
$(MAKE) -C $(SRC_DIR) EXTRA_DEPS=opensource TEST_BUILD_DIR=$(BUILD_DIR)/opensource test_build
.PHONY: test_build .PHONY: test_build
test_build: test_this_build test_build: clang_plugin
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
test_build: test_oss_build @$(MAKE) -C facebook
endif endif
@$(MAKE) -C $(SRC_DIR) test_build
.PHONY: ocaml_unit_test .PHONY: ocaml_unit_test
ocaml_unit_test: test_this_build ocaml_unit_test: test_build
$(TEST_BUILD_DIR)/unit/inferunit.byte $(call silent_on_success,$(TEST_BUILD_DIR)/unit/inferunit.byte)
DIRECT_TESTS_REPLACE = $(patsubst %_frontend_test,%_frontend_replace,$(filter %_frontend_test,$(DIRECT_TESTS))) DIRECT_TESTS_REPLACE = $(patsubst %_frontend_test,%_frontend_replace,$(filter %_frontend_test,$(DIRECT_TESTS)))
@ -138,7 +105,7 @@ define gen_direct_test_rule
$(1): infer $(1): infer
($(MAKE) -C \ ($(MAKE) -C \
$(INFER_DIR)/tests/codetoanalyze/$(shell printf $(1) | cut -f 1 -d _)/$(shell printf $(1) | cut -f 2 -d _) \ $(INFER_DIR)/tests/codetoanalyze/$(shell printf $(1) | cut -f 1 -d _)/$(shell printf $(1) | cut -f 2 -d _) \
$(shell printf $(1) | cut -f 3 -d _) \ test \
3>&1 1>&2- 2>&3- ) \ 3>&1 1>&2- 2>&3- ) \
| grep -v "warning: ignoring old commands for target" \ | grep -v "warning: ignoring old commands for target" \
| grep -v "warning: overriding commands for target" \ | grep -v "warning: overriding commands for target" \
@ -146,7 +113,7 @@ $(1): infer
.PHONY: $(1)_clean .PHONY: $(1)_clean
$(1)_clean: $(1)_clean:
$(MAKE) -C \ @$(MAKE) -C \
$(INFER_DIR)/tests/codetoanalyze/$(shell printf $(1) | cut -f 1 -d _)/$(shell printf $(1) | cut -f 2 -d _) \ $(INFER_DIR)/tests/codetoanalyze/$(shell printf $(1) | cut -f 1 -d _)/$(shell printf $(1) | cut -f 2 -d _) \
clean clean
endef endef
@ -161,11 +128,15 @@ direct_tests: $(DIRECT_TESTS)
define gen_build_system_test_rule define gen_build_system_test_rule
.PHONY: build_$(1)_test .PHONY: build_$(1)_test
build_$(1)_test: infer build_$(1)_test: infer
$(MAKE) -C $(INFER_DIR)/tests/build_systems/$(1) test @($(MAKE) -C $(INFER_DIR)/tests/build_systems/$(1) test \
3>&1 1>&2- 2>&3- ) \
| grep -v "warning: ignoring old commands for target" \
| grep -v "warning: overriding commands for target" \
; exit $$$${PIPESTATUS[0]}
.PHONY: build_$(1)_clean .PHONY: build_$(1)_clean
build_$(1)_clean: build_$(1)_clean:
$(MAKE) -C $(INFER_DIR)/tests/build_systems/$(1) clean @$(MAKE) -C $(INFER_DIR)/tests/build_systems/$(1) clean
endef endef
$(foreach test,$(BUILD_SYSTEMS_TESTS), $(eval $(call gen_build_system_test_rule,$(test)))) $(foreach test,$(BUILD_SYSTEMS_TESTS), $(eval $(call gen_build_system_test_rule,$(test))))
@ -199,17 +170,17 @@ check_missing_mli:
test -f "$$x"i || echo Missing "$$x"i; done test -f "$$x"i || echo Missing "$$x"i; done
.PHONY: toplevel .PHONY: toplevel
toplevel: infer toplevel: clang_plugin
$(MAKE) -C $(SRC_DIR) toplevel @$(MAKE) -C $(SRC_DIR) toplevel
.PHONY: inferScriptMode_test .PHONY: inferScriptMode_test
inferScriptMode_test: toplevel inferScriptMode_test: test_build
$(call silent_on_success,\ $(call silent_on_success,\
INFER_REPL_BINARY=ocaml $(SCRIPT_DIR)/infer_repl $(INFER_DIR)/tests/repl/infer_batch_script.ml) INFER_REPL_BINARY=ocaml $(SCRIPT_DIR)/infer_repl $(INFER_DIR)/tests/repl/infer_batch_script.ml)
.PHONY: checkCopyright .PHONY: checkCopyright
checkCopyright: checkCopyright:
$(MAKE) -C $(SRC_DIR) checkCopyright @$(MAKE) -C $(SRC_DIR) checkCopyright
.PHONY: run-test .PHONY: run-test
run-test: test_build ocaml_unit_test buck_test inferTraceBugs_test inferScriptMode_test checkCopyright run-test: test_build ocaml_unit_test buck_test inferTraceBugs_test inferScriptMode_test checkCopyright
@ -224,7 +195,7 @@ else
endif endif
.PHONY: quick-test .PHONY: quick-test
quick-test: test_this_build ocaml_unit_test quick-test: test_build ocaml_unit_test
.PHONY: test-replace .PHONY: test-replace
test-replace: test-replace:
@ -239,7 +210,6 @@ test-replace:
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
$(REMOVE_DIR) $(DESTDIR)$(libdir)/infer/ $(REMOVE_DIR) $(DESTDIR)$(libdir)/infer/
$(REMOVE) $(DESTDIR)$(bindir)/inferTraceBugs
$(REMOVE) $(DESTDIR)$(bindir)/infer $(REMOVE) $(DESTDIR)$(bindir)/infer
.PHONY: test_clean .PHONY: test_clean
@ -247,7 +217,7 @@ test_clean: $(foreach test,$(DIRECT_TESTS),$(test)_clean) \
$(foreach test,$(BUILD_SYSTEMS_TESTS),build_$(test)_clean) $(foreach test,$(BUILD_SYSTEMS_TESTS),build_$(test)_clean)
.PHONY: install .PHONY: install
install: infer inferTraceBugs install: infer
# create directory structure # create directory structure
test -d $(DESTDIR)$(bindir) || \ test -d $(DESTDIR)$(bindir) || \
$(MKDIR_P) $(DESTDIR)$(bindir) $(MKDIR_P) $(DESTDIR)$(bindir)
@ -300,10 +270,12 @@ ifeq ($(BUILD_C_ANALYZERS),yes)
@for i in $$(find infer/lib/clang_wrappers/*); do \ @for i in $$(find infer/lib/clang_wrappers/*); do \
$(INSTALL_PROGRAM) -C $$i $(DESTDIR)$(libdir)/infer/$$i; \ $(INSTALL_PROGRAM) -C $$i $(DESTDIR)$(libdir)/infer/$$i; \
done done
# only for files that point to InferClang
(cd $(DESTDIR)$(libdir)/infer/infer/lib/wrappers/ && \ (cd $(DESTDIR)$(libdir)/infer/infer/lib/wrappers/ && \
$(REMOVE) $(INFERCLANG_WRAPPERS_BASENAMES) && \ $(foreach cc,$(shell find $(LIB_DIR)/wrappers -type l), \
$(foreach cc,$(INFERCLANG_WRAPPERS_BASENAMES), \ [ $(cc) -ef $(INFERCLANG_BIN) ] && \
$(LN_S) ../../bin/InferClang $(cc);)) $(REMOVE) $(notdir $(cc)) && \
$(LN_S) ../../bin/InferClang $(notdir $(cc));))
@for i in $$(find infer/lib/specs/*); do \ @for i in $$(find infer/lib/specs/*); do \
$(INSTALL_DATA) -C $$i $(DESTDIR)$(libdir)/infer/$$i; \ $(INSTALL_DATA) -C $$i $(DESTDIR)$(libdir)/infer/$$i; \
done done
@ -349,26 +321,24 @@ endif
$(LN_S) $(libdir)/infer/infer/lib/python/inferTraceBugs inferTraceBugs) $(LN_S) $(libdir)/infer/infer/lib/python/inferTraceBugs inferTraceBugs)
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
$(MAKE) -C facebook install @$(MAKE) -C facebook install
endif endif
.PHONY: clean .PHONY: clean
clean: test_clean clean: test_clean
ifeq ($(IS_RELEASE_TREE),no) ifeq ($(IS_RELEASE_TREE),no)
ifeq ($(BUILD_C_ANALYZERS),yes) ifeq ($(BUILD_C_ANALYZERS),yes)
$(MAKE) -C $(FCP_DIR) clean @$(MAKE) -C $(FCP_DIR) clean
$(MAKE) -C $(FCP_DIR)/clang-ocaml clean @$(MAKE) -C $(FCP_DIR)/clang-ocaml clean
$(REMOVE) $(INFERCLANG_WRAPPERS_PATHS)
endif endif
endif endif
$(MAKE) -C $(SRC_DIR) clean @$(MAKE) -C $(SRC_DIR) clean
$(MAKE) -C $(ANNOTATIONS_DIR) clean @$(MAKE) -C $(ANNOTATIONS_DIR) clean
$(MAKE) -C $(MODELS_DIR) clean @$(MAKE) -C $(MODELS_DIR) clean
$(REMOVE) $(INFERTRACEBUGS_BIN_RELPATH)
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
$(MAKE) -C facebook clean @$(MAKE) -C facebook clean
endif endif
$(MAKE) -C $(DEPENDENCIES_DIR)/ocamldot clean @$(MAKE) -C $(DEPENDENCIES_DIR)/ocamldot clean
find $(INFER_DIR)/tests -name '*.o' -or -name '*.o.sh' -delete find $(INFER_DIR)/tests -name '*.o' -or -name '*.o.sh' -delete
.PHONY: conf-clean .PHONY: conf-clean

@ -61,7 +61,7 @@ REMOVE = rm -vf
REMOVE_DIR = rm -rvf REMOVE_DIR = rm -rvf
RSYNC_A = rsync -aq RSYNC_A = rsync -aq
endif endif
COPY = cp -f -p COPY = cp -f
COPY_DIR = cp -Rf COPY_DIR = cp -Rf
ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd) ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd)

@ -0,0 +1 @@
../lib/python/inferTraceBugs

@ -0,0 +1 @@
../../bin/InferClang

@ -0,0 +1 @@
../../bin/InferClang

@ -0,0 +1 @@
../../bin/InferClang

@ -0,0 +1 @@
../../bin/InferClang

@ -0,0 +1 @@
../../bin/InferClang

@ -0,0 +1 @@
../../bin/InferClang

@ -26,24 +26,24 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes)
all: java all: java
endif endif
.PHONY: java clang clean $(CLANG_SUBDIRS) .PHONY: java clang clean clean_specs $(CLANG_SUBDIRS)
clean_specs: clean_specs:
$(REMOVE) $(SPECS_LIB_DIR)/*.specs $(REMOVE) $(SPECS_LIB_DIR)/*.specs
$(CLANG_SUBDIRS): $(CLANG_SUBDIRS):
$(MAKE) -C $@ install @$(MAKE) -C $@ install
clang: clean_specs clang:
$(MAKE) $(CLANG_SUBDIRS) @$(MAKE) $(CLANG_SUBDIRS)
java: clean_specs java:
$(MAKE) -C $@ install @$(MAKE) -C $@ install
clean: clean_specs clean: clean_specs
$(MAKE) -C $(JAVA_MODELS_DIR) clean @$(MAKE) -C $(JAVA_MODELS_DIR) clean
$(MAKE) -C $(C_MODELS_DIR) clean @$(MAKE) -C $(C_MODELS_DIR) clean
$(MAKE) -C $(CPP_MODELS_DIR) clean @$(MAKE) -C $(CPP_MODELS_DIR) clean
ifneq (no, $(XCODE_SELECT)) ifneq (no, $(XCODE_SELECT))
$(MAKE) -C $(OBJC_MODELS_DIR) clean @$(MAKE) -C $(OBJC_MODELS_DIR) clean
endif endif

@ -10,20 +10,24 @@ include $(ROOT_DIR)/Makefile.config
C_MODELS_FILE = $(SPECS_LIB_DIR)/c_models C_MODELS_FILE = $(SPECS_LIB_DIR)/c_models
C_MODELS_SOURCES = $(shell find src/ -name "*.c") C_MODELS_SOURCES = $(shell find src/ -name "*.c")
INFER_RESULTS = out/report.json
all: $(C_MODELS_FILE) all: install
$(C_MODELS_FILE): $(C_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
$(MAKE) -C src clean @$(MAKE) -C src clean
$(INFER_BIN) -o out/ --models-mode --no-failures-allowed -- $(MAKE) -C src $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src
touch $(C_MODELS_FILE)
$(C_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)
@touch $@
install: $(C_MODELS_FILE) install: $(C_MODELS_FILE)
$(INSTALL_DATA) -C out/specs/*.specs $(SPECS_LIB_DIR)
clean: clean:
@rm -f $(C_MODELS_FILE) $(REMOVE) $(C_MODELS_FILE)
$(MAKE) -C src clean $(REMOVE_DIR) $(dir $(INFER_RESULTS))
@$(MAKE) -C src clean
.PHONY: all clean install .PHONY: all clean install

@ -11,20 +11,24 @@ include $(ROOT_DIR)/Makefile.config
CPP_MODELS_FILE = $(SPECS_LIB_DIR)/cpp_models CPP_MODELS_FILE = $(SPECS_LIB_DIR)/cpp_models
CPP_MODELS_SOURCES = $(shell find src/ -name "*.cpp") CPP_MODELS_SOURCES = $(shell find src/ -name "*.cpp")
C_MODELS_SOURCES = $(shell find src/c_src/ -name "*.c") C_MODELS_SOURCES = $(shell find src/c_src/ -name "*.c")
INFER_RESULTS = out/report.json
all: $(CPP_MODELS_FILE) all: install
$(CPP_MODELS_FILE): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
$(MAKE) -C src clean @$(MAKE) -C src clean
$(INFER_BIN) -o out/ --models-mode --no-failures-allowed --cxx -- $(MAKE) -C src $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src
touch $(CPP_MODELS_FILE)
$(CPP_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)
@touch $@
install: $(CPP_MODELS_FILE) install: $(CPP_MODELS_FILE)
$(INSTALL_DATA) -C out/specs/*.specs $(SPECS_LIB_DIR)
clean: clean:
@rm -f $(CPP_MODELS_FILE) $(REMOVE) $(CPP_MODELS_FILE)
$(MAKE) -C src clean $(REMOVE_DIR) $(dir $(INFER_RESULTS))
@$(MAKE) -C src clean
.PHONY: all clean install .PHONY: all clean install

@ -10,20 +10,25 @@ include $(ROOT_DIR)/Makefile.config
OBJC_MODELS_FILE = $(SPECS_LIB_DIR)/objc_models OBJC_MODELS_FILE = $(SPECS_LIB_DIR)/objc_models
OBJC_MODELS_SOURCES = $(shell find src/ -name "*.m" -or -name "*.c") OBJC_MODELS_SOURCES = $(shell find src/ -name "*.m" -or -name "*.c")
INFER_RESULTS = out/report.json
all: $(OBJC_MODELS_FILE) all: install
$(OBJC_MODELS_FILE): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
$(MAKE) -C src clean @$(MAKE) -C src clean
$(INFER_BIN) -o out/ --models-mode --no-failures-allowed -- $(MAKE) -C src $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src
touch $(OBJC_MODELS_FILE) touch $(OBJC_MODELS_FILE)
$(OBJC_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)
@touch $@
install: $(OBJC_MODELS_FILE) install: $(OBJC_MODELS_FILE)
$(INSTALL_DATA) -C out/specs/*.specs $(SPECS_LIB_DIR)
clean: clean:
@rm -f $(OBJC_MODELS_FILE) $(REMOVE) $(OBJC_MODELS_FILE)
$(MAKE) -C src clean $(REMOVE_DIR) $(dir $(INFER_RESULTS))
@$(MAKE) -C src clean
.PHONY: all clean install .PHONY: all clean install

@ -133,7 +133,6 @@ OCAMLBUILD_ALL = $(OCAMLBUILD_BASE) $(JAVA_OCAMLBUILD_OPTIONS)
# list of ocamlbuild targets common to all build targets -- native version # list of ocamlbuild targets common to all build targets -- native version
INFER_BASE_TARGETS = \ INFER_BASE_TARGETS = \
$(C_STUBS_OBJ) \
$(INFER_MAIN).native \ $(INFER_MAIN).native \
$(INFERANALYZE_MAIN).native \ $(INFERANALYZE_MAIN).native \
$(INFERPRINT_MAIN).native \ $(INFERPRINT_MAIN).native \
@ -157,15 +156,34 @@ INFER_CONFIG_TARGETS += $(INFERCLANG_MAIN).native
DEPENDENCIES += clang DEPENDENCIES += clang
endif endif
OCAML_BASE_SOURCES = \
$(wildcard $(DEPENDENCIES:=/[a-zA-Z]*.ml) $(DEPENDENCIES:=/[a-zA-Z]*.mli) \
$(DEPENDENCIES:=/[a-zA-Z]*.mll) $(DEPENDENCIES:=/[a-zA-Z]*.mly) \
$(DEPENDENCIES:=/[a-zA-Z]*.re) $(DEPENDENCIES:=/[a-zA-Z]*.rei)) \
$(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS)
OCAML_SOURCES = $(OCAML_BASE_SOURCES)
ifeq ($(BUILD_C_ANALYZERS),yes)
OCAML_SOURCES += $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
endif
OCAML_ALL_SOURCES = $(OCAML_BASE_SOURCES) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
export OCAMLFIND_IGNORE_DUPS_IN=$(shell ocamlc -where)/compiler-libs export OCAMLFIND_IGNORE_DUPS_IN=$(shell ocamlc -where)/compiler-libs
.PHONY: all .PHONY: all
all: infer all: infer
.PHONY: infer # single out infer.native as the source of truth for make, knowing that in fact several targets are
infer: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) # produced by the build
$(INFER_BUILD_DIR)/$(INFER_MAIN).native: base/Version.ml $(BUILD_DIR) $(OCAML_SOURCES)
$(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) $(INFER_CONFIG_TARGETS) $(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) $(INFER_CONFIG_TARGETS)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(INFER_BIN) # let make know that the target is up-to-date even if ocamlbuild cached it
@touch $@
$(BIN_DIR): Makefile
$(MKDIR_P) $@
@touch $@
$(INFER_BIN): $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(BIN_DIR)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERANALYZE_MAIN).native $(INFERANALYZE_BIN) $(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERANALYZE_MAIN).native $(INFERANALYZE_BIN)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERPRINT_MAIN).native $(INFERPRINT_BIN) $(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERPRINT_MAIN).native $(INFERPRINT_BIN)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERUNIT_MAIN).native $(INFERUNIT_BIN) $(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERUNIT_MAIN).native $(INFERUNIT_BIN)
@ -174,16 +192,22 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes)
endif endif
ifeq ($(BUILD_C_ANALYZERS),yes) ifeq ($(BUILD_C_ANALYZERS),yes)
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERCLANG_MAIN).native $(INFERCLANG_BIN) $(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFERCLANG_MAIN).native $(INFERCLANG_BIN)
cd $(INFER_BUILD_DIR) && $(LN_S) -f InferClang InferClang++ && cd -
endif endif
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(INFER_MAIN).native $(INFER_BIN)
.PHONY: infer
infer: $(INFER_BIN)
ifeq ($(BUILD_C_ANALYZERS),yes) ifeq ($(BUILD_C_ANALYZERS),yes)
infer: $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) $(CLANG_BINIOU_DICT) infer: $(CLANG_BINIOU_DICT)
endif endif
.PHONY: byte $(INFER_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES)
byte: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
$(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) $(INFER_ALL_TARGETS:.native=.byte) $(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) $(INFER_ALL_TARGETS:.native=.byte)
@touch $@
.PHONY: byte
byte: $(INFER_BUILD_DIR)/$(INFER_MAIN).byte
# to build only the single module <Module> (and its dependencies) with extra flags execute: # to build only the single module <Module> (and its dependencies) with extra flags execute:
# make MFLAGS=<flags> M=<Module>.cm{o,x} module # make MFLAGS=<flags> M=<Module>.cm{o,x} module
@ -193,16 +217,19 @@ M=
MFLAGS= MFLAGS=
.PHONY: module .PHONY: module
module: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) module: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES)
$(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) \ $(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) \
$(MFLAGS) \ $(MFLAGS) \
$(M) $(M)
.PHONY: test_build $(TEST_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES) toplevel.mlpack
test_build: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
$(OCAMLBUILD_ALL) -build-dir $(TEST_BUILD_DIR) \ $(OCAMLBUILD_ALL) -build-dir $(TEST_BUILD_DIR) \
-cflags -warn-error,$(OCAML_FATAL_WARNINGS) \ -cflags -warn-error,$(OCAML_FATAL_WARNINGS) \
$(INFER_ALL_TARGETS:.native=.byte) $(INFER_ALL_TARGETS:.native=.byte) toplevel.cmo
@touch $@
.PHONY: test_build
test_build: $(TEST_BUILD_DIR)/$(INFER_MAIN).byte
# to generate interface file.mli from implementation file.ml execute: # to generate interface file.mli from implementation file.ml execute:
# make M=file mli # make M=file mli
@ -243,35 +270,42 @@ mod_dep.pdf: mod_dep.dot
dsort: dsort:
@ocamldep.opt -sort $(inc_flags) -ml-synonym .re -mli-synonym .rei $(ml_src_files) -pp refmt $(re_src_files) @ocamldep.opt -sort $(inc_flags) -ml-synonym .re -mli-synonym .rei $(ml_src_files) -pp refmt $(re_src_files)
roots_grep_regex:=$(foreach root,$(roots),-e $(root)$$) define to_ocaml_module
dirs_find_regex:=$(foreach dir, $(DEPENDENCIES),-path "./$(dir)/*" -o) $(shell \
echo $(basename $(1)) \
| awk 'BEGIN { FS = "/"; OFS = "/" } ; {$$NF=toupper(substr($$NF,1,1))substr($$NF,2); print $$0}')
endef
.PHONY: toplevel toplevel.mlpack: base/Version.ml $(OCAML_ALL_SOURCES)
toplevel: init $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) # We need to pack all the infer modules into another module to avoid name clashes with some
# We need to pack all infer modules into another module to avoid name clashes # of them coming from ocaml libraries (Ident for example). To do that, we generate a .mlpack
# with some of them coming from ocaml libraries (Ident for example). # file containing namespaced modules.
# To do that, we generate .mlpack file with source files. Steps: # 1. we filter out roots because they execute code upon loading
# 1. find all interesting .re and .ml files - they need to be in one of # 2. each source file is converted to a module by capitalizing its first letter
# directories listed in $(DEPENDENCIES) # 3. we `echo` each module individually to avoid too long a command line
# 2. remove './' from the beginning of each line # 4. prevent race conditions by using a temp file
# 3. remove extension from all files $(eval $@_tmp := $(shell mktemp $@.tmp.XXXX))
# 4. make first letter of filename uppercase to produce valid ocaml module $(foreach module,\
# 5. filter out root modules since they run code when loading the module. $(filter-out $(foreach root,$(roots),%/$(root)),\
find . \( -name "*.ml" -o -name "*.mly" -o -name "*.mll" -o -name "*.re" \) \ $(foreach source,\
\( $(dirs_find_regex) -false \) \ $(filter-out unit/% facebook/scripts/eradicate_stats.ml,$(OCAML_ALL_SOURCES)),\
-not \( -path "./unit/*" -o -path "./facebook/scripts/eradicate_stats.ml" -o -name ".#*" \) \ $(call to_ocaml_module,$(source)))),\
| cut -c 3- \ $(shell echo $(module) >> $($@_tmp)))
| rev | cut -f 2- -d '.' | rev \ mv $($@_tmp) $@
| awk 'BEGIN { FS = "/"; OFS = "/" } ; {$$NF=toupper(substr($$NF,1,1))substr($$NF,2); print $$0}' \
| grep -v $(roots_grep_regex) > toplevel.mlpack $(INFER_BUILD_DIR)/toplevel.cmo: toplevel.mlpack $(BUILD_DIR)
$(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) toplevel.cmo $(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) toplevel.cmo
@touch $@
.PHONY: toplevel
toplevel: $(INFER_BUILD_DIR)/toplevel.cmo
.PHONY: checkCopyright .PHONY: checkCopyright
checkCopyright: $(CHECKCOPYRIGHT_BIN) checkCopyright: $(CHECKCOPYRIGHT_BIN)
$(CHECKCOPYRIGHT_BIN): sanitize $(BUILD_DIR) $(CHECKCOPYRIGHT_MAIN).ml $(CHECKCOPYRIGHT_BIN): $(BUILD_DIR) $(CHECKCOPYRIGHT_MAIN).ml
rebuild -quiet -r -j $(NCPU) -build-dir $(INFER_BUILD_DIR) -pkgs core,str -tag thread -use-ocamlfind $(CHECKCOPYRIGHT_MAIN).native rebuild -quiet -r -j $(NCPU) -build-dir $(BUILD_DIR)/checkCopyright -pkgs core,str -tag thread -use-ocamlfind $(CHECKCOPYRIGHT_MAIN).native
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/$(CHECKCOPYRIGHT_MAIN).native $(CHECKCOPYRIGHT_BIN) $(INSTALL_PROGRAM) $(BUILD_DIR)/checkCopyright/$(CHECKCOPYRIGHT_MAIN).native $(CHECKCOPYRIGHT_BIN)
define gen_atdgen_rules define gen_atdgen_rules
# generate files using atdgen # generate files using atdgen
@ -318,18 +352,8 @@ $(CLANG_BINIOU_DICT): $(CLANG_ATDGEN_STUB_ATD)
| sort | uniq \ | sort | uniq \
> $@ > $@
.PHONY: init base/Version.ml: base/Version.ml.in Makefile
init: sanitize version $(BUILD_DIR) TMPFILE=$$(mktemp $@.tmp.XXXX); \
.PHONY: sanitize
sanitize:
ifneq ($(wildcard $(BUILD_DIR)/sanitize.sh),)
$(BUILD_DIR)/sanitize.sh
endif
.PHONY: version
version: base/Version.ml.in Makefile
TMPFILE=$$(mktemp base/Version.ml.tmp.XXXX); \
INFER_GIT_COMMIT=$$(git --work-tree=$(ROOT_DIR) --git-dir=$(ROOT_DIR)/.git rev-parse --short HEAD || printf "unknown"); \ INFER_GIT_COMMIT=$$(git --work-tree=$(ROOT_DIR) --git-dir=$(ROOT_DIR)/.git rev-parse --short HEAD || printf "unknown"); \
INFER_GIT_BRANCH=$$(git --work-tree=$(ROOT_DIR) --git-dir=$(ROOT_DIR)/.git rev-parse --abbrev-ref HEAD || printf "unknown"); \ INFER_GIT_BRANCH=$$(git --work-tree=$(ROOT_DIR) --git-dir=$(ROOT_DIR)/.git rev-parse --abbrev-ref HEAD || printf "unknown"); \
sed \ sed \
@ -340,8 +364,7 @@ version: base/Version.ml.in Makefile
-e "s|@INFER_GIT_COMMIT[@]|$$INFER_GIT_COMMIT|g" \ -e "s|@INFER_GIT_COMMIT[@]|$$INFER_GIT_COMMIT|g" \
-e "s|@INFER_GIT_BRANCH[@]|$$INFER_GIT_BRANCH|g" \ -e "s|@INFER_GIT_BRANCH[@]|$$INFER_GIT_BRANCH|g" \
$< > "$$TMPFILE"; \ $< > "$$TMPFILE"; \
$(INSTALL_DATA) -C "$$TMPFILE" base/Version.ml; \ mv "$$TMPFILE" $@
rm -f "$$TMPFILE"
$(BUILD_DIR): $(BUILD_DIR):
$(MKDIR_P) $(BUILD_DIR) $(MKDIR_P) $(BUILD_DIR)
@ -352,6 +375,8 @@ test_clean:
.PHONY: clean .PHONY: clean
clean: clean:
$(REMOVE) $(INFER_ALL_TARGETS)
$(REMOVE) toplevel.mlpack
$(REMOVE_DIR) $(BUILD_DIR) $(REMOVE_DIR) $(BUILD_DIR)
$(REMOVE) $(ETC_DIR)/clang_ast.dict $(REMOVE) $(ETC_DIR)/clang_ast.dict
$(REMOVE) base/Version.ml $(REMOVE) base/Version.ml

@ -27,21 +27,25 @@ compile:
clang $(CLANG_OPTIONS) $(SOURCES) clang $(CLANG_OPTIONS) $(SOURCES)
capture: capture:
$(call silent_on_success,\
$(INFER_BIN) $(INFER_OPTIONS) --project-root $(ROOT) \ $(INFER_BIN) $(INFER_OPTIONS) --project-root $(ROOT) \
--icfg-dotty-outfile $(ROOT)/main.cpp.test.dot -- \ --icfg-dotty-outfile $(ROOT)/main.cpp.test.dot -- \
clang $(CLANG_OPTIONS) $(ROOT)/main.cpp clang $(CLANG_OPTIONS) $(ROOT)/main.cpp)
$(call silent_on_success,\
$(INFER_BIN) $(INFER_OPTIONS) --project-root $(SYM_ROOT) \ $(INFER_BIN) $(INFER_OPTIONS) --project-root $(SYM_ROOT) \
--icfg-dotty-outfile $(SYM_ROOT)/main_symlink.cpp.test.dot -- \ --icfg-dotty-outfile $(SYM_ROOT)/main_symlink.cpp.test.dot -- \
clang $(CLANG_OPTIONS) $(SYM_ROOT)/main.cpp clang $(CLANG_OPTIONS) $(SYM_ROOT)/main.cpp)
cd $(ROOT) && $(INFER_BIN) $(INFER_OPTIONS) \ cd $(ROOT) && \
--icfg-dotty-outfile main_default_root.cpp.test.dot -- \ $(call silent_on_success,\
clang $(CLANG_OPTIONS) main.cpp $(INFER_BIN) $(INFER_OPTIONS) --icfg-dotty-outfile main_default_root.cpp.test.dot -- \
clang $(CLANG_OPTIONS) main.cpp)
cd $(SYM_ROOT) && $(INFER_BIN) $(INFER_OPTIONS) \ cd $(SYM_ROOT) && \
--icfg-dotty-outfile main_default_symlink.cpp.test.dot -- \ $(call silent_on_success,\
clang $(CLANG_OPTIONS) main.cpp $(INFER_BIN) $(INFER_OPTIONS) --icfg-dotty-outfile main_default_symlink.cpp.test.dot -- \
clang $(CLANG_OPTIONS) main.cpp)
# test_extra needs to be separate target. Otherwise commands from test # test_extra needs to be separate target. Otherwise commands from test
# target in common Makefile won't run # target in common Makefile won't run

@ -19,4 +19,4 @@ compile:
clang $(CLANG_OPTIONS) $(SOURCES) clang $(CLANG_OPTIONS) $(SOURCES)
capture: capture:
$(INFER_BIN) -a capture --frontend-tests --cxx --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES) $(call silent_on_success,$(INFER_BIN) -a capture --frontend-tests --cxx --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES))

@ -20,4 +20,4 @@ compile:
clang $(CLANG_OPTIONS) $(SOURCES) clang $(CLANG_OPTIONS) $(SOURCES)
capture: capture:
$(INFER_BIN) -a capture --frontend-tests --cxx --headers --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES) $(call silent_on_success,$(INFER_BIN) -a capture --frontend-tests --cxx --headers --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES))

@ -88,5 +88,5 @@ compile:
clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC) clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC)
capture: capture:
$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES_NOARC) $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES_NOARC))
$(INFER_BIN) -a capture --cxx --frontend-tests --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC) $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC))

@ -24,4 +24,4 @@ compile:
clang $(CLANG_OPTIONS) $(SOURCES) clang $(CLANG_OPTIONS) $(SOURCES)
capture: capture:
$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES) $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES))

@ -2,7 +2,12 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR=$SCRIPT_DIR/../infer/_build/infer # _build/infer is first so that it takes precedence. This way if someone explicitly builds the
# toplevel (`make toplevel`) they get the expected version of infer. The _build/test toplevel is
# built during `make test` which is probably run less often, hence why it doesn't take
# precedence. Of course this cannot be perfect so caution is advised.
TOPLEVEL_INCLUDES="-I $SCRIPT_DIR/../infer/_build/infer -I $SCRIPT_DIR/../infer/_build/test"
# to build new toplevel, run `make toplevel` # to build new toplevel, run `make toplevel`
# -init option is used only in interactive mode # -init option is used only in interactive mode
# in batch mode, scripts need to import toplevel_init themselves # in batch mode, scripts need to import toplevel_init themselves
@ -17,4 +22,4 @@ BUILD_DIR=$SCRIPT_DIR/../infer/_build/infer
if [ -z "$INFER_REPL_BINARY" ]; then if [ -z "$INFER_REPL_BINARY" ]; then
INFER_REPL_BINARY="utop" INFER_REPL_BINARY="utop"
fi fi
$INFER_REPL_BINARY -init $SCRIPT_DIR/toplevel_init -I $BUILD_DIR -I $SCRIPT_DIR $@ $INFER_REPL_BINARY -init $SCRIPT_DIR/toplevel_init $TOPLEVEL_INCLUDES -I $SCRIPT_DIR $@

Loading…
Cancel
Save