Skip to content

Commit

Permalink
Improve make format.
Browse files Browse the repository at this point in the history
 * Use `yapf` from environment if it exists.
 * Better way to generate exclude.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
  • Loading branch information
mithro committed Dec 14, 2018
1 parent adc20bc commit 44490c2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CLANG_FORMAT ?= clang-format-5.0

.PHONY: database format clean env

IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi;
env:
virtualenv --python=python3 env
. env/bin/activate; pip install -r requirements.txt
Expand All @@ -15,11 +16,13 @@ build:
database: build
$(MAKE) -C $@

FORMAT_EXCLUDE = third_party git env build
FIND_EXCLUDE = $(foreach x,$(FORMAT_EXCLUDE),-and -not -path './$(x)/*')
format:
find . -name \*.cc -and -not -path './third_party/*' -and -not -path './.git/*' -exec $(CLANG_FORMAT) -style=file -i {} \;
find . -name \*.h -and -not -path './third_party/*' -and -not -path './.git/*' -exec $(CLANG_FORMAT) -style=file -i {} \;
find . -name \*.py -and -not -path './third_party/*' -and -not -path './.git/*' -exec yapf -p -i {} \;
find . -name \*.tcl -and -not -path './third_party/*' -and -not -path './.git/*' -exec ${XRAY_TCL_REFORMAT} {} \; 2>/dev/null
find . -name \*.cc $(FIND_EXCLUDE) -exec $(CLANG_FORMAT) -style=file -i {} \;
find . -name \*.h $(FIND_EXCLUDE) -exec $(CLANG_FORMAT) -style=file -i {} \;
$(IN_ENV) find . -name \*.py $(FIND_EXCLUDE) -exec yapf -p -i {} \;
find . -name \*.tcl $(FIND_EXCLUDE) -exec ${XRAY_TCL_REFORMAT} {} \; 2>/dev/null

clean:
$(MAKE) -C database clean
Expand Down

0 comments on commit 44490c2

Please sign in to comment.