diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..e18df73410 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +--- +BasedOnStyle: Google +IndentWidth: 4 diff --git a/Makefile b/Makefile index d20dca566f..2a31f49e71 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tools/clang-format-check b/tools/clang-format-check new file mode 100755 index 0000000000..3b7c789035 --- /dev/null +++ b/tools/clang-format-check @@ -0,0 +1,10 @@ +#!/bin/sh +error=0 +for f in $*; do + changes=$(clang-format -output-replacements-xml "$f" | grep -c '^