1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 08:08:51 +00:00

style: add cstyle target to Makefile + clang-format config, don't enforce for now

This commit is contained in:
Pavol Rusnak 2018-07-17 16:54:37 +02:00
parent 324d82507e
commit 7bf30ccb37
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 18 additions and 0 deletions

3
.clang-format Normal file
View File

@ -0,0 +1,3 @@
---
BasedOnStyle: Google
IndentWidth: 4

View File

@ -73,6 +73,8 @@ test_emu: ## run selected device tests from python-trezor
pylint: ## run pylint on application sources and tests
pylint -E $(shell find src tests -name *.py)
## style commands:
style: ## run code style check on application sources and tests
flake8 $(shell find src -name *.py)
isort --check-only $(shell find src -name *.py ! -path 'src/trezor/messages/*')
@ -84,6 +86,9 @@ isort:
black:
black $(shell find src -name *.py ! -path 'src/trezor/messages/*')
cstyle: ## run code style check on low-level C code
./tools/clang-format-check $(shell find embed -type f -name *.[ch])
## build commands:
build: build_boardloader build_bootloader build_firmware build_prodtest build_unix ## build all

10
tools/clang-format-check Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
error=0
for f in $*; do
changes=$(clang-format -output-replacements-xml "$f" | grep -c '^<replacement ')
if test "$changes" -gt 0; then
echo "$f ... $changes changes needed"
error=1
fi
done
exit $error