From 6e1b83a20422b0bd369129cf44d52cf4553c79eb Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 2 Mar 2017 02:50:04 -0800 Subject: [PATCH] [clang] add clang models to `CLANG_DEPS` Summary: This is helpful to make sure tests are up to date wrt the models. Also made the Java deps depend on the models.jar instead of the model sources as that's what the tests will be using. In particular, updating the sources of the models will not update the results of a test unless someone rebuilds models.jar, so rerunning the tests when the models haven't been rebuilt is useless. Reviewed By: akotulski Differential Revision: D4635129 fbshipit-source-id: 75b4ab6 --- Makefile.config | 51 ++++++++++++++++++++++++-------------- infer/models/c/Makefile | 5 ++-- infer/models/cpp/Makefile | 5 ++-- infer/models/java/Makefile | 10 ++------ infer/models/objc/Makefile | 5 ++-- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Makefile.config b/Makefile.config index bb20a42fa..d0e5cd60f 100644 --- a/Makefile.config +++ b/Makefile.config @@ -64,28 +64,41 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes) JAVA_HOME=$(USER_JAVA_HOME) endif -JAVA_BUILTINS_SOURCES = $(shell find $(JAVA_BUILTINS_DIR) -name "*.java") -JAVA_MODELS_SOURCES = $(shell find $(JAVA_MODELS_DIR) -name "*.java") - -JAVA_DEPS = $(addprefix $(PYTHON_LIB_DIR)/, \ - analyze.py bucklib.py config.py issues.py jwlib.py source.py utils.py) \ - $(addprefix $(CAPTURE_LIB_DIR)/, util.py) \ - $(INFER_BIN) \ - $(INFERANALYZE_BIN) \ - $(INFERPRINT_BIN) \ - $(JAVA_BUILTINS_SOURCES) \ - $(JAVA_MODELS_SOURCES) - -CLANG_DEPS = $(addprefix $(PYTHON_LIB_DIR)/, \ - analyze.py config.py issues.py source.py utils.py) \ - $(addprefix $(CAPTURE_LIB_DIR)/, make.py util.py) \ - $(INFER_BIN) \ - $(INFERANALYZE_BIN) \ - $(INFERCLANG_BIN) \ - $(INFERPRINT_BIN) +ANDROID_JAR = $(LIB_DIR)/java/android/android-23.jar +GUAVA_JAR = $(DEPENDENCIES_DIR)/java/guava/guava-10.0.1-fork.jar +INFER_ANNOTATIONS_JAR = $(ANNOTATIONS_DIR)/annotations.jar +JACKSON_JAR = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar +JSR_305_JAR = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar JAVA_MODELS_JAR = $(LIB_DIR)/java/models.jar +JAVA_DEPS_NO_MODELS = \ + $(addprefix $(PYTHON_LIB_DIR)/, \ + analyze.py bucklib.py config.py issues.py jwlib.py source.py utils.py) \ + $(addprefix $(CAPTURE_LIB_DIR)/, util.py) \ + $(ANDROID_JAR) $(GUAVA_JAR) $(JACKSON_JAR) $(JSR_305_JAR) $(INFER_ANNOTATIONS_JAR) \ + $(INFER_BIN) $(INFERANALYZE_BIN) $(INFERPRINT_BIN) + +JAVA_DEPS = $(JAVA_DEPS_NO_MODELS) $(JAVA_MODELS_JAR) + +# markers to keep track of when clang models have been rebuilt +C_MODELS_FILE = $(SPECS_LIB_DIR)/c_models +CPP_MODELS_FILE = $(SPECS_LIB_DIR)/cpp_models +OBJC_MODELS_FILE = $(SPECS_LIB_DIR)/objc_models + +CLANG_DEPS_NO_MODELS = \ + $(addprefix $(PYTHON_LIB_DIR)/, \ + analyze.py config.py issues.py source.py utils.py) \ + $(addprefix $(CAPTURE_LIB_DIR)/, make.py util.py) \ + $(INFER_BIN) $(INFERANALYZE_BIN) $(INFERCLANG_BIN) $(INFERPRINT_BIN) + +CLANG_DEPS = $(CLANG_DEPS_NO_MODELS) $(C_MODELS_FILE) $(CPP_MODELS_FILE) \ + $(shell find $(MODELS_DIR)/cpp/include -type f) + +ifneq ($(XCODE_SELECT),no) +CLANG_DEPS += $(OBJC_MODELS_FILE) +endif + define silent_on_success $(1) >/dev/null 2>/dev/null || ($(1) && exit 1) endef diff --git a/infer/models/c/Makefile b/infer/models/c/Makefile index 388dd9199..d030938eb 100644 --- a/infer/models/c/Makefile +++ b/infer/models/c/Makefile @@ -8,14 +8,13 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -C_MODELS_FILE = $(SPECS_LIB_DIR)/c_models C_MODELS_SOURCES = $(shell find src/ -name "*.c") INFER_RESULTS = out/report.json all: install -$(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS) -# make clean in src/ in case $(CLANG_DEPS) have changed +$(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS_NO_MODELS) +# make clean in src/ to recompile all the models $(call silent_on_success,\ $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src clean all) diff --git a/infer/models/cpp/Makefile b/infer/models/cpp/Makefile index 0f0af61e3..743332b40 100644 --- a/infer/models/cpp/Makefile +++ b/infer/models/cpp/Makefile @@ -8,15 +8,14 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -CPP_MODELS_FILE = $(SPECS_LIB_DIR)/cpp_models CPP_MODELS_SOURCES = $(shell find src/ -name "*.cpp") C_MODELS_SOURCES = $(shell find src/c_src/ -name "*.c") INFER_RESULTS = out/report.json all: install -$(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS) -# make clean in src/ in case $(CLANG_DEPS) have changed +$(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS_NO_MODELS) +# make clean in src/ to recompile all the models $(call silent_on_success,\ $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src clean all) diff --git a/infer/models/java/Makefile b/infer/models/java/Makefile index 82c4b7f68..5975792cb 100644 --- a/infer/models/java/Makefile +++ b/infer/models/java/Makefile @@ -8,18 +8,12 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -ANDROID_JAR = $(LIB_DIR)/java/android/android-23.jar -GUAVA_JAR = $(DEPENDENCIES_DIR)/java/guava/guava-10.0.1-fork.jar -INFER_ANNOTATIONS_JAR = $(ANNOTATIONS_DIR)/annotations.jar -JACKSON_JAR = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar -JSR_305_JAR = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar - MODELS_OUT = models INFER_RESULTS_DIR = $(MODELS_OUT)/infer INFER_REPORT = $(INFER_RESULTS_DIR)/report.json MODELS_JAR = models.jar -JAVA_SOURCES = $(JAVA_BUILTINS_SOURCES) $(JAVA_MODELS_SOURCES) +JAVA_SOURCES = $(shell find $(JAVA_BUILTINS_DIR) $(JAVA_MODELS_DIR) -name "*.java") MODELS_CLASSPATH = $(ANDROID_JAR):$(GUAVA_JAR):$(JACKSON_JAR):$(JSR_305_JAR):$(INFER_ANNOTATIONS_JAR) @@ -33,7 +27,7 @@ clean: compile: javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(MODELS_CLASSPATH) $(JAVA_SOURCES) -$(INFER_REPORT): $(ANDROID_JAR) $(GUAVA_JAR) $(JACKSON_JAR) $(JSR_305_JAR) $(INFER_ANNOTATIONS_JAR) $(JAVA_DEPS) $(JAVA_SOURCES) +$(INFER_REPORT): $(JAVA_DEPS_NO_MODELS) $(JAVA_SOURCES) @rm -fr $(MODELS_OUT) mkdir -p $(MODELS_OUT) @rm -f $(JAVA_MODELS_JAR) diff --git a/infer/models/objc/Makefile b/infer/models/objc/Makefile index fb0b105e7..30e3f61dc 100644 --- a/infer/models/objc/Makefile +++ b/infer/models/objc/Makefile @@ -8,14 +8,13 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -OBJC_MODELS_FILE = $(SPECS_LIB_DIR)/objc_models OBJC_MODELS_SOURCES = $(shell find src/ -name "*.m" -or -name "*.c") INFER_RESULTS = out/report.json all: install -$(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS) -# make clean in src/ in case $(CLANG_DEPS) have changed +$(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS_NO_MODELS) +# make clean in src/ to recompile all the models $(call silent_on_success,\ $(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src clean all)