Skip to content

Commit

Permalink
Add clang-format make targets and CI checks (#314)
Browse files Browse the repository at this point in the history
Adds a .clang-format definition and checks in CI to enforce consistent code formatting going forward.
  • Loading branch information
vroland committed May 27, 2024
1 parent e855efe commit df2f64d
Show file tree
Hide file tree
Showing 68 changed files with 5,086 additions and 5,011 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ BasedOnStyle: chromium
IndentWidth: 4
ColumnLimit: 100
AlignAfterOpenBracket: BlockIndent
IncludeBlocks: Preserve
BreakBeforeBinaryOperators: All
Cpp11BracedListStyle: false
AllowAllParametersOfDeclarationOnNextLine: true
BinPackArguments: false
BinPackParameters: false
SortIncludes: false
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ name: ESP-IDF
on: [push, pull_request]

jobs:
format-check:
runs-on: ubuntu-latest
container:
image: "espressif/idf:release-v5.2"
steps:
- uses: actions/checkout@v4
- run: |
. $IDF_PATH/export.sh
idf_tools.py install esp-clang
. $IDF_PATH/export.sh
which clang-format
make format-check
build:
runs-on: ubuntu-latest
strategy:
Expand All @@ -11,6 +24,7 @@ jobs:
version:
- release-v4.4
- release-v5.1
- release-v5.2
example:
- calibration_helper
- demo
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.pio
.vscode
build/
build.clang
sdkconfig.old
sdkconfig
**/build/
Expand All @@ -24,3 +25,4 @@ dependencies.lock
ED*.h
ES*.h
examples/private_*/
*.code-workspace
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ EXPORTED_MODES ?= 1,2,5,16,17
# Generate waveforms in room temperature range
EXPORT_TEMPERATURE_RANGE ?= 15,35

FORMATTED_FILES := $(shell find ./ -regex '.*\.\(c\|cpp\|h\|ino\)$$' \
-not -regex '.*/\(.ccls-cache\|.cache\|waveforms\|\components\|build\)/.*' \
-not -regex '.*/img_.*.h' \
-not -regex '.*/build.*' \
-not -regex '.*/\(firasans_.*.h\|opensans.*.h\|amiri.h\|alexandria.h\|dragon.h\)' \
-not -regex '.*E[DS][0-9]*[A-Za-z]*[0-9].h')

# the default headers that should come with the distribution
default: \
$(patsubst %,src/waveforms/epdiy_%.h,$(SUPPORTRED_DISPLAYS))
Expand All @@ -17,9 +24,11 @@ clean:
rm src/waveforms/eink_*.h

format:
clang-format -i $(shell find ./examples -regex '.*main.*\.\(c\|cpp\|h\|ino\)$$' \
-not -regex '.*/\(.ccls-cache\|waveforms\|\components\|build\)/.*' \
-not -regex '.*E[DS][0-9]*[A-Za-z]*[0-9].h')
clang-format --style=file -i $(FORMATTED_FILES)

format-check:
clang-format --style=file --dry-run -Werror $(FORMATTED_FILES)


src/waveforms/epdiy_%.h: src/waveforms/epdiy_%.json
python3 scripts/waveform_hdrgen.py \
Expand Down
10 changes: 7 additions & 3 deletions examples/demo/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void idf_setup() {
epd_set_rotation(EPD_ROT_LANDSCAPE);

printf(
"Dimensions after rotation, width: %d height: %d\n\n", epd_rotated_display_width(),
"Dimensions after rotation, width: %d height: %d\n\n",
epd_rotated_display_width(),
epd_rotated_display_height()
);

Expand Down Expand Up @@ -221,7 +222,8 @@ void idf_loop() {
.x = 20,
.y = 20,
.width = epd_rotated_display_width() - 40,
.height = epd_rotated_display_height() - 40};
.height = epd_rotated_display_height() - 40,
};
epd_draw_rect(border_rect, 0, fb);

cursor_x = 50;
Expand All @@ -235,7 +237,9 @@ void idf_loop() {
"➸ High-quality font rendering ✎🙋\n"
"➸ Partial update\n"
"➸ Arbitrary transitions with vendor waveforms",
&cursor_x, &cursor_y, fb
&cursor_x,
&cursor_y,
fb
);

EpdRect img_beach_area = {
Expand Down
2 changes: 1 addition & 1 deletion examples/dragon/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ EpdiyHighlevelState hl;
#endif

void idf_loop() {
EpdRect dragon_area = {.x = 0, .y = 0, .width = dragon_width, .height = dragon_height};
EpdRect dragon_area = { .x = 0, .y = 0, .width = dragon_width, .height = dragon_height };

int temperature = 25;

Expand Down
Loading

0 comments on commit df2f64d

Please sign in to comment.