|
| 1 | +# Path to your Flipper Zero firmware directory |
| 2 | +FLIPPER_FIRMWARE_PATH ?= /home/<YOUR_PATH>/flipperzero-firmware |
| 3 | +PWD = $(shell pwd) |
| 4 | + |
| 5 | +CC = gcc |
| 6 | +CFLAGS = -Wall -Wextra -std=c11 -I. |
| 7 | + |
| 8 | +.PHONY: all help test prepare fap clean clean_firmware format linter |
| 9 | + |
| 10 | +all: test |
| 11 | + |
| 12 | +help: |
| 13 | + @echo "Available commands:" |
| 14 | + @echo " make test - Run unit tests for the logic" |
| 15 | + @echo " make prepare - Link this app to the Flipper firmware source" |
| 16 | + @echo " make fap - Clean firmware build and build the Flipper Zero application" |
| 17 | + @echo " make format - Run clang-format to format code" |
| 18 | + @echo " make linter - Run cppcheck to analyze code" |
| 19 | + @echo " make clean - Remove local compiled files" |
| 20 | + @echo " make clean_firmware - Remove firmware build directory" |
| 21 | + |
| 22 | +format: |
| 23 | + clang-format -i *.c *.h tests/*.c |
| 24 | + |
| 25 | +linter: |
| 26 | + cppcheck --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=missingInclude . |
| 27 | + |
| 28 | +test: logic.o tests/test_logic.o |
| 29 | + $(CC) $(CFLAGS) -o test_logic logic.o tests/test_logic.o |
| 30 | + ./test_logic |
| 31 | + |
| 32 | +prepare: |
| 33 | + @if [ -d "$(FLIPPER_FIRMWARE_PATH)" ]; then \ |
| 34 | + mkdir -p $(FLIPPER_FIRMWARE_PATH)/applications_user; \ |
| 35 | + ln -sfn $(PWD) $(FLIPPER_FIRMWARE_PATH)/applications_user/sub_duplicate_finder; \ |
| 36 | + echo "App linked to $(FLIPPER_FIRMWARE_PATH)/applications_user/sub_duplicate_finder"; \ |
| 37 | + else \ |
| 38 | + echo "Error: Flipper firmware path not found at $(FLIPPER_FIRMWARE_PATH)."; \ |
| 39 | + fi |
| 40 | + |
| 41 | +clean_firmware: |
| 42 | + @if [ -d "$(FLIPPER_FIRMWARE_PATH)/build" ]; then \ |
| 43 | + echo "Cleaning firmware build directory..."; \ |
| 44 | + rm -rf $(FLIPPER_FIRMWARE_PATH)/build; \ |
| 45 | + fi |
| 46 | + |
| 47 | +fap: prepare clean_firmware clean |
| 48 | + @if [ -d "$(FLIPPER_FIRMWARE_PATH)" ]; then \ |
| 49 | + cd $(FLIPPER_FIRMWARE_PATH) && ./fbt fap_sub_dup_finder; \ |
| 50 | + fi |
| 51 | + |
| 52 | +logic.o: logic.c logic.h |
| 53 | + $(CC) $(CFLAGS) -c logic.c |
| 54 | + |
| 55 | +tests/test_logic.o: tests/test_logic.c logic.h |
| 56 | + $(CC) $(CFLAGS) -c tests/test_logic.c -o tests/test_logic.o |
| 57 | + |
| 58 | +clean: |
| 59 | + rm -f *.o tests/*.o test_logic |
0 commit comments