summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Shelhamer <shelhamer@imaginarynumber.net>2014-02-26 17:56:57 -0800
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2014-02-26 17:56:57 -0800
commitde4f7a419f176a49d77b2a0506c78333d988058c (patch)
tree62ee79007152be7dff3709623638d98ade9d54ba
parent1f1d82b068dc503641d47a8d0d6e1d2f59012b4d (diff)
parent52a539dcd10de805def24ba2ace904089a9f1cd0 (diff)
downloadcaffeonacl-de4f7a419f176a49d77b2a0506c78333d988058c.tar.gz
caffeonacl-de4f7a419f176a49d77b2a0506c78333d988058c.tar.bz2
caffeonacl-de4f7a419f176a49d77b2a0506c78333d988058c.zip
Merge pull request #168 from jeffdonahue/fix-lint-bugs
Fix bugs introduced by lint
-rw-r--r--Makefile20
-rw-r--r--matlab/caffe/matcaffe.cpp4
-rw-r--r--python/caffe/pycaffe.cpp5
-rwxr-xr-xscripts/cpp_lint.py2
4 files changed, 19 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index e6098caf..f8adaad0 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 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)
test: init $(TEST_BINS)
diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp
index d3bcba93..ddbacca1 100644
--- a/matlab/caffe/matcaffe.cpp
+++ b/matlab/caffe/matcaffe.cpp
@@ -12,7 +12,7 @@
#define MEX_ARGS int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs
-namespace caffe {
+using namespace caffe; // NOLINT(build/namespaces)
// The pointer to the internal caffe::Net instance
static shared_ptr<Net<float> > net_;
@@ -189,5 +189,3 @@ void mexFunction(MEX_ARGS) {
mxFree(cmd);
}
}
-
-} // namespace caffe
diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp
index 6c87d0f9..4d28ca64 100644
--- a/python/caffe/pycaffe.cpp
+++ b/python/caffe/pycaffe.cpp
@@ -20,6 +20,8 @@
#define PyArray_SetBaseObject(arr, x) (PyArray_BASE(arr) = (x))
#endif
+
+using namespace caffe; // NOLINT(build/namespaces)
using boost::python::extract;
using boost::python::len;
using boost::python::list;
@@ -27,7 +29,6 @@ using boost::python::object;
using boost::python::handle;
using boost::python::vector_indexing_suite;
-namespace caffe {
// wrap shared_ptr<Blob<float> > in a class that we construct in C++ and pass
// to Python
@@ -278,5 +279,3 @@ BOOST_PYTHON_MODULE(pycaffe) {
import_array();
}
-
-} // namespace caffe
diff --git a/scripts/cpp_lint.py b/scripts/cpp_lint.py
index 11bfefa8..f7898d8f 100755
--- a/scripts/cpp_lint.py
+++ b/scripts/cpp_lint.py
@@ -54,7 +54,7 @@ import unicodedata
_USAGE = """
-Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
+Syntax: cpp_lint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
[--counting=total|toplevel|detailed] [--root=subdir]
[--linelength=digits]
<file> [file] ...