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

Update clang checks not to depend on build #54

Merged
merged 7 commits into from
Mar 2, 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
16 changes: 2 additions & 14 deletions .github/workflows/guidelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ jobs:
tar -xf riscv32-glibc-ubuntu-22.04-nightly.tar.gz
echo "${PWD}/riscv/bin" >> $GITHUB_PATH

- name: Build
run: CMAKE_BUILD_TYPE=Debug make clean build

- name: Run clang-format
run: |
echo "scan the following files:"
jq -r '.[].file' kernel/build/compile_commands.json | grep '\.[ch]$'
echo "analysis results:"
clang-format-18 --dry-run $(jq -r '.[].file' kernel/build/compile_commands.json | grep '\.[ch]$')
make clang-format-check


static-analysis:
Expand Down Expand Up @@ -70,12 +64,6 @@ jobs:
tar -xf riscv32-glibc-ubuntu-22.04-nightly.tar.gz
echo "${PWD}/riscv/bin" >> $GITHUB_PATH

- name: Build
run: CMAKE_BUILD_TYPE=Debug make clean build

- name: Run clang-tidy
run: |
echo "scan the following files:"
jq -r '.[].file' kernel/build/compile_commands.json | grep '\.[ch]$'
echo "analysis results:"
cd kernel; clang-tidy-18 -p build $(jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$') --warnings-as-errors="*"
make clang-tidy-check
35 changes: 19 additions & 16 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@ MAKEFLAGS += --silent
IDF_PATH ?= $(shell pwd)/../esp-idf
SHELL := /usr/bin/env bash
PORT ?= $(shell find /dev/ -name ttyUSB* -or -name ttyACM* | head -1)
OUTPUT ?= "$(shell pwd)/firmware"
BUILDDIR ?= "build"
OUTPUT ?= $(shell pwd)/firmware
BUILDDIR ?= build
BADGER_RAMFS_ROOT ?= ../files/root

.PHONY: all clean-tools clean build flash monitor test clang-format-check clang-tidy-check openocd gdb
.PHONY: all clean-tools clean configure build flash monitor test clang-format-check clang-tidy-check openocd gdb

all: build flash monitor

build:
mkdir -p "$(BUILDDIR)"
../tools/ramfs-gen.py '$(BADGER_RAMFS_ROOT)' build/fs_root.c init_ramfs
cmake -B "$(BUILDDIR)" "-DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE:-Debug}"
cmake --build "$(BUILDDIR)"
cmake --install "$(BUILDDIR)" --prefix "$(OUTPUT)"
configure:
mkdir -p '$(BUILDDIR)'
touch '$(BUILDDIR)/fs_root.c'
cmake -B '$(BUILDDIR)' "-DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE:-Debug}"

clang-format-check: build
build: configure
../tools/ramfs-gen.py '$(BADGER_RAMFS_ROOT)' '$(BUILDDIR)/fs_root.c' init_ramfs
cmake --build '$(BUILDDIR)'
cmake --install '$(BUILDDIR)' --prefix '$(OUTPUT)'

clang-format-check: configure
echo "clang-format check the following files:"
jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$'
echo "analysis results:"
clang-format --dry-run $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$')
clang-format-18 --dry-run $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$')

clang-tidy-check: build
clang-tidy-check: configure
echo "clang-tidy check the following files:"
jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$'
echo "analysis results:"
clang-tidy -p build $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$') --warnings-as-errors="*"
clang-tidy-18 -p build $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$') --warnings-as-errors="*"

openocd:
openocd -c 'set ESP_RTOS "none"' -f board/esp32c6-builtin.cfg
Expand All @@ -43,12 +46,12 @@ clean:
rm -rf "$(BUILDDIR)"

flash: build
esptool.py -b 921600 --port "$(PORT)" \
esptool.py -b 921600 --port '$(PORT)' \
write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB \
0x0 port/esp32c6/bootloader.bin \
0x10000 "$(OUTPUT)/badger-os.bin" \
0x10000 '$(OUTPUT)/badger-os.bin' \
0x8000 port/esp32c6/partition-table.bin

monitor:
echo -e "\033[1mType ^A^X to exit.\033[0m"
picocom -q -b 115200 $(PORT) | ../tools/address-filter.py "$(OUTPUT)/badger-os.elf"; echo -e '\033[0m'
picocom -q -b 115200 '$(PORT)' | ../tools/address-filter.py '$(OUTPUT)/badger-os.elf'; echo -e '\033[0m'
Loading