Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clang-format make targets and CI checks #314

Merged
merged 6 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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