From 933dc6e7d9fc190ad64bf61d53217c2af9465b1d Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Tue, 8 Jul 2014 17:52:49 -0700 Subject: [PATCH] Output a lint report for every source file linted; use to lint incrementally --- Makefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4d67aa3..74e4a94 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,9 @@ NONGEN_CXX_SRCS := $(shell find \ examples \ tools \ -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh") +LINT_OUTPUT_DIR := $(BUILD_DIR)/lint +LINT_EXT := lint.txt +LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, ${NONGEN_CXX_SRCS})) LINT_REPORT := $(BUILD_DIR)/cpp_lint.log FAILED_LINT_REPORT := $(BUILD_DIR)/cpp_lint.error_log # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT) @@ -173,6 +176,7 @@ ALL_BUILD_DIRS := $(sort \ $(LAYER_BUILD_DIR) $(UTIL_BUILD_DIR) $(TOOL_BUILD_DIR) \ $(TEST_BUILD_DIR) $(TEST_BIN_DIR) $(GTEST_BUILD_DIR) \ $(EXAMPLE_BUILD_DIRS) \ + $(LINT_OUTPUT_DIR) \ $(PROTO_BUILD_DIR) $(PROTO_BUILD_INCLUDE_DIR) $(PY_PROTO_BUILD_DIR) \ $(DISTRIBUTE_SUBDIRS)) @@ -287,13 +291,22 @@ linecount: lint: $(LINT_REPORT) -$(LINT_REPORT): $(NONGEN_CXX_SRCS) | $(BUILD_DIR) - @ (python ./scripts/cpp_lint.py $(NONGEN_CXX_SRCS) > $(LINT_REPORT) 2>&1 \ - && ($(RM) $(FAILED_LINT_REPORT); echo "No lint errors!")) || ( \ - mv $(LINT_REPORT) $(FAILED_LINT_REPORT); \ - grep -v "^Done processing " $(FAILED_LINT_REPORT); \ - echo "Found 1 or more lint errors; see log at $(FAILED_LINT_REPORT)"; \ - exit 1) +$(LINT_REPORT): $(LINT_OUTPUTS) + @ cat $(LINT_OUTPUTS) > $@ + @ if [ -s "$@" ]; then \ + cat $@; mv $@ $(FAILED_LINT_REPORT); \ + else \ + echo "No lint errors!"; \ + fi + +$(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % | $(LINT_OUTPUT_DIR) + @ mkdir -p $(dir $@) + @ python ./scripts/cpp_lint.py $< 2>&1 \ + | grep -v "^Done processing " \ + | grep -v "^Total errors found: 0" \ + > $@ \ + || true + @ if [ -s "$@" ]; then touch $<; cat $@; fi test: $(TEST_ALL_BIN) $(TEST_BINS) -- 2.7.4