Skip to content

Commit

Permalink
Add linting targets for all and changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgr committed Mar 19, 2020
1 parent 6fb2261 commit 53d7a28
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,41 @@ dist_man1_MANS = $(wildcard $(srcdir)/man/*.1)
#Linting
lint: format tidy

# Run clang-format on all modified cpp/h files
format:
cpplist=`git ls-files *.cpp *.h`; \
cd $(abs_top_srcdir); \
cpplist='`git diff --diff-filter=dr --name-only *.cpp *.h` `git diff --diff-filter=dr --name-only *.cpp *.h`'; \
for file in $$cpplist; \
do \
clang-format -i $$file; \
done;

# Run clang-tidy on all modified cpp files
tidy:
cd $(abs_top_srcdir); \
cpplist="`git diff --cached --diff-filter=dr --name-only *cpp` `git diff --diff-filter=dr --name-only *cpp`"; \
cd $(abs_top_builddir)/src; \
for file in $$cpplist; \
do \
clang-tidy $(abs_top_srcdir)/$$file --quiet --extra-arg=-std=c++17 -- -I$(abs_top_builddir)/src -I. -I$(abs_top_srcdir)/src -I$(abs_top_builddir)/include -I$(abs_top_builddir) $(CXXFLAGS) ;\
done;

# Run clang-format on all cpp/h files known to git
format-all:
cd $(abs_top_srcdir); \
cpplist=`git ls-files *.cpp *.h`; \
for file in $$cpplist; \
do \
clang-format -i $$file; \
done;

# Run clang-tidy on all cpp files known to git
tidy-all:
cd $(abs_top_srcdir); \
cpplist=`git ls-files *.cpp`; \
cd $(abs_top_builddir)/src; \
for file in $$cpplist; \
do \
clang-tidy $$file --quiet --header-filter=".*" --extra-arg=-std=c++17 -- $(CXXFLAGS) ;\
clang-tidy $(abs_top_srcdir)/$$file --quiet --extra-arg=-std=c++17 -- -I$(abs_top_builddir)/src -I. -I$(abs_top_srcdir)/src -I$(abs_top_builddir)/include -I$(abs_top_builddir) $(CXXFLAGS) ;\
done;

0 comments on commit 53d7a28

Please sign in to comment.