summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJeff Donahue <jeff.donahue@gmail.com>2014-02-26 00:41:19 -0800
committerJeff Donahue <jeff.donahue@gmail.com>2014-02-26 16:54:25 -0800
commit5fdf55c437f7f94948af7d361a80e5b3d6d22e63 (patch)
treeecb41446d2ac57d9d2afc28a0d40956f92e7f7e5 /Makefile
parent1f1d82b068dc503641d47a8d0d6e1d2f59012b4d (diff)
downloadcaffe-5fdf55c437f7f94948af7d361a80e5b3d6d22e63.tar.gz
caffe-5fdf55c437f7f94948af7d361a80e5b3d6d22e63.tar.bz2
caffe-5fdf55c437f7f94948af7d361a80e5b3d6d22e63.zip
make lint will not rerun if successful and no source files have been
changed; saves output to build/cpp_lint.log (or build/cpp_lint.error_log on failure)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 15 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index e6098caf..0d22f54c 100644
--- a/Makefile
+++ b/Makefile
@@ -32,8 +32,8 @@ TOOL_SRCS := $(shell find tools -name "*.cpp")
EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
# PROTO_SRCS are the protocol buffer definitions
PROTO_SRCS := $(wildcard src/$(PROJECT)/proto/*.proto)
-# NONGEN_CXX_SRCS includes all source/header files except those generated by
-# proto.
+# NONGEN_CXX_SRCS includes all source/header files except those generated
+# automatically (e.g., by proto).
NONGEN_CXX_SRCS := $(shell find \
src/$(PROJECT) \
include/$(PROJECT) \
@@ -42,6 +42,8 @@ NONGEN_CXX_SRCS := $(shell find \
examples \
tools \
-regex ".*\.\(cpp\|hpp\|cu\|cuh\)")
+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)
PY$(PROJECT)_SRC := python/$(PROJECT)/py$(PROJECT).cpp
PY$(PROJECT)_SO := python/$(PROJECT)/py$(PROJECT).so
@@ -105,7 +107,7 @@ PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))
##############################
# Define build targets
##############################
-.PHONY: all init test clean linecount tools examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
+.PHONY: all init test clean linecount lint tools examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
all: init $(NAME) $(STATIC_NAME) tools examples
@echo $(CXX_OBJS)
@@ -120,8 +122,16 @@ init:
linecount: clean
cloc --read-lang-def=$(PROJECT).cloc src/$(PROJECT)/
-lint:
- ./scripts/cpp_lint.py $(NONGEN_CXX_SRCS)
+lint: $(LINT_REPORT)
+
+$(LINT_REPORT): $(NONGEN_CXX_SRCS)
+ @ mkdir -p $(BUILD_DIR)
+ @ (python ./scripts/cpp_lint.py $(NONGEN_CXX_SRCS) > $(LINT_REPORT) 2>&1 \
+ && (rm -f $(FAILED_LINT_REPORT); echo "No linter errors!")) || ( \
+ mv $(LINT_REPORT) $(FAILED_LINT_REPORT); \
+ grep -v "^Done processing " $(FAILED_LINT_REPORT); \
+ echo "Found 1 or more linter errors; see log at $(FAILED_LINT_REPORT)"; \
+ exit 1)
test: init $(TEST_BINS)