diff --git a/.github/workflows/guidelines.yaml b/.github/workflows/guidelines.yaml index 75be2f5..771a71d 100644 --- a/.github/workflows/guidelines.yaml +++ b/.github/workflows/guidelines.yaml @@ -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: @@ -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 diff --git a/kernel/Makefile b/kernel/Makefile index cec1818..cc7a616 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -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 @@ -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'