From 7bf30ccb378c135d0eb21b9cef581fb478b462d1 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 17 Jul 2018 16:54:37 +0200 Subject: [PATCH] style: add cstyle target to Makefile + clang-format config, don't enforce for now --- .clang-format | 3 +++ Makefile | 5 +++++ tools/clang-format-check | 10 ++++++++++ 3 files changed, 18 insertions(+) create mode 100644 .clang-format create mode 100755 tools/clang-format-check diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..e18df7341 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +--- +BasedOnStyle: Google +IndentWidth: 4 diff --git a/Makefile b/Makefile index d20dca566..2a31f49e7 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 000000000..3b7c78903 --- /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 '^