Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit 8c197a6

Browse files
committed
added makefile tasks: format, checkformat, runlint
1 parent 2333070 commit 8c197a6

File tree

7 files changed

+116
-1
lines changed

7 files changed

+116
-1
lines changed

Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,25 @@ fullclean: libclean
6060
rm -rf compiler/binutils-gdb/build
6161
rm -rf compiler/gcc/build
6262
rm -rf compiler/glibc/build
63+
64+
.PHONY: format
65+
format:
66+
$(MAKE) -C driver format
67+
$(MAKE) -C shared format
68+
$(MAKE) -C car format
69+
$(MAKE) -C control format
70+
71+
# Quality checks
72+
.PHONY: checklint
73+
runlint:
74+
$(MAKE) -C driver runlint
75+
$(MAKE) -C shared runlint
76+
$(MAKE) -C car runlint
77+
$(MAKE) -C control runlint
78+
79+
.PHONY: checkformat
80+
checkformat:
81+
$(MAKE) -C driver checkformat
82+
$(MAKE) -C shared checkformat
83+
$(MAKE) -C car checkformat
84+
$(MAKE) -C control checkformat

car/Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ MKSUBDIRS=$(addprefix ../build/obj/car/, $(SUBDIRS))
88
SRCS=$(shell cd src/ && find * -type f -name '*.cpp')
99
OBJS=$(addprefix ../build/obj/car/, $(SRCS:.cpp=.o))
1010

11+
FORMAT=clang-format
12+
FORMAT_FIX_FLAGS=-i
13+
FORMAT_CHECK_FLAGS=--dry-run --Werror
14+
LINT=clang-tidy
15+
LINT_FLAGS=--quiet
16+
1117
.PHONY:
1218
all: ../build/obj/car $(MKSUBDIRS) $(OUT)
1319

@@ -39,3 +45,18 @@ $(foreach subdir, $(SUBDIRS), $(eval $(call compile_subdir,$(subdir))))
3945
clean:
4046
rm -rf ../build/obj/car
4147
rm ../build/bin/car
48+
49+
SRC_DIR_FILES=$(shell find src -type f)
50+
51+
.PHONY: format
52+
format:
53+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(SRC_DIR_FILES)
54+
55+
# Quality checks
56+
.PHONY: checklint
57+
runlint:
58+
$(LINT) $(LINT_FLAGS) $(SRC_DIR_FILES)
59+
60+
.PHONY: checkformat
61+
checkformat:
62+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(SRC_DIR_FILES)

car/src/main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// NOLINTBEGIN: temporary code
1414
#define CALLSIGN ""
1515
#define TAG "/2"
16+
1617
// NOLINTEND
1718

1819
int main() {

control/Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ MKSUBDIRS=$(addprefix ../build/obj/control/, $(SUBDIRS))
88
SRCS=$(shell cd src/ && find * -type f -name '*.cpp')
99
OBJS=$(addprefix ../build/obj/control/, $(SRCS:.cpp=.o))
1010

11+
FORMAT=clang-format
12+
FORMAT_FIX_FLAGS=-i
13+
FORMAT_CHECK_FLAGS=--dry-run --Werror
14+
LINT=clang-tidy
15+
LINT_FLAGS=--quiet
16+
1117
.PHONY:
1218
all: ../build/obj/control $(MKSUBDIRS) $(OUT)
1319

@@ -39,3 +45,18 @@ $(foreach subdir, $(SUBDIRS), $(eval $(call compile_subdir,$(subdir))))
3945
clean:
4046
rm -rf ../build/obj/control
4147
rm ../build/bin/control
48+
49+
SRC_DIR_FILES=$(shell find src -type f)
50+
51+
.PHONY: format
52+
format:
53+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(SRC_DIR_FILES)
54+
55+
# Quality checks
56+
.PHONY: checklint
57+
runlint:
58+
$(LINT) $(LINT_FLAGS) $(SRC_DIR_FILES)
59+
60+
.PHONY: checkformat
61+
checkformat:
62+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(SRC_DIR_FILES)

driver/Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ MKSUBDIRS=$(addprefix ../build/obj/driver/, $(SUBDIRS_CAR))
99
SRCS=$(shell cd src/ && find * -type f -name '*.cpp')
1010
OBJS=$(addprefix ../build/obj/driver/, $(SRCS:.cpp=.o))
1111

12+
FORMAT=clang-format
13+
FORMAT_FIX_FLAGS=-i
14+
FORMAT_CHECK_FLAGS=--dry-run --Werror
15+
LINT=clang-tidy
16+
LINT_FLAGS=--quiet
17+
1218
.PHONY:
1319
all: ../build/obj/driver $(MKSUBDIRS) $(OUT) headers
1420

@@ -44,3 +50,22 @@ $(foreach subdir, $(SUBDIRS), $(eval $(call compile_subdir,$(subdir))))
4450
clean:
4551
rm -rf ../build/obj/driver
4652
rm ../build/lib/libdriver.a
53+
54+
SRC_DIR_FILES=$(shell find src -type f)
55+
INC_DIR_FILES=$(shell find include -type f)
56+
57+
.PHONY: format
58+
format:
59+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(INC_DIR_FILES)
60+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(SRC_DIR_FILES)
61+
62+
# Quality checks
63+
.PHONY: checklint
64+
runlint:
65+
$(LINT) $(LINT_FLAGS) $(INC_DIR_FILES)
66+
$(LINT) $(LINT_FLAGS) $(SRC_DIR_FILES)
67+
68+
.PHONY: checkformat
69+
checkformat:
70+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(INC_DIR_FILES)
71+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(SRC_DIR_FILES)

driver/src/pwm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// 500 Hz PWM -> 2000us / period
1414
constexpr uint32_t TOTAL_TIME = 2000;
15-
constexpr uint32_t TIME_PER_PERCENT (TOTAL_TIME / 100);
15+
constexpr uint32_t TIME_PER_PERCENT = TOTAL_TIME / 100;
1616

1717
pwm_worker::pwm_worker(const gpiod::chip &chip, uint32_t pin)
1818
: line(chip.get_line(pin)) {

shared/Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ MKSUBDIRS=$(addprefix ../build/obj/shared/, $(SUBDIRS_CAR))
99
SRCS=$(shell cd src/ && find * -type f -name '*.cpp')
1010
OBJS=$(addprefix ../build/obj/shared/, $(SRCS:.cpp=.o))
1111

12+
FORMAT=clang-format
13+
FORMAT_FIX_FLAGS=-i
14+
FORMAT_CHECK_FLAGS=--dry-run --Werror
15+
LINT=clang-tidy
16+
LINT_FLAGS=--quiet
17+
1218
.PHONY:
1319
all: ../build/obj/shared $(MKSUBDIRS) $(OUT) headers
1420

@@ -44,3 +50,22 @@ $(foreach subdir, $(SUBDIRS), $(eval $(call compile_subdir,$(subdir))))
4450
clean:
4551
rm -rf ../build/obj/shared
4652
rm ../build/lib/libshared.a
53+
54+
SRC_DIR_FILES=$(shell find src -type f)
55+
INC_DIR_FILES=$(shell find include -type f)
56+
57+
.PHONY: format
58+
format:
59+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(INC_DIR_FILES)
60+
$(FORMAT) $(FORMAT_FIX_FLAGS) $(SRC_DIR_FILES)
61+
62+
# Quality checks
63+
.PHONY: checklint
64+
runlint:
65+
$(LINT) $(LINT_FLAGS) $(INC_DIR_FILES)
66+
$(LINT) $(LINT_FLAGS) $(SRC_DIR_FILES)
67+
68+
.PHONY: checkformat
69+
checkformat:
70+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(INC_DIR_FILES)
71+
$(FORMAT) $(FORMAT_CHECK_FLAGS) $(SRC_DIR_FILES)

0 commit comments

Comments
 (0)