-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (103 loc) · 3.88 KB
/
Copy pathMakefile
File metadata and controls
121 lines (103 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# --- ceedless: minimal embedded test framework ---------------------------
CC ?= gcc
CSTD ?= -std=c11
WARN ?= -Wall -Wextra -Wshadow -Wpedantic -Wno-unused-function -Wno-stringop-truncation
OPT ?= -O2 -g
CFLAGS ?= $(CSTD) $(WARN) $(OPT)
INCS := -Iinclude
LDLIBS := -lm
CORE_SRC := \
src/runner.c \
src/exception.c \
src/mock.c \
src/virtual_peripheral.c \
src/trace/trace_port.c \
src/trace/trace_host.c \
src/trace/trace_uart.c \
src/trace/trace_rtt.c \
src/trace/trace_itm.c \
src/trace/trace_buffer.c \
src/peripherals/vp_spi.c \
src/peripherals/vp_uart.c \
src/peripherals/vp_gpio.c \
src/peripherals/vp_adc.c
SELFTEST_SRC := \
tests/test_main.c \
tests/test_trace_port.c \
tests/test_virtual_peripheral.c \
tests/test_runner.c \
tests/test_assertions.c \
tests/test_exception.c \
tests/test_mock.c \
tests/test_peripherals.c \
tests/test_extensions.c
EXAMPLE_SRC := \
examples/sensor_driver/sensor_driver.c \
examples/sensor_driver/test_sensor_driver.c
BUILD := build
.PHONY: all cli test example cli-test docker docker-test lint clean cortex_m
all: cli test example cli-test
# Build the Go CLI into bin/ceedless. Pure stdlib, no deps.
cli:
cd cli && go build -trimpath -ldflags "-s -w" -o ../bin/ceedless .
# Build the dev/CI container image. Run-once; cached afterwards.
docker:
docker build -t ceedless:latest .
# Run the full self-test suite inside the container.
docker-test: docker
docker run --rm -t -v $(CURDIR):/work -w /work ceedless:latest \
sh -c "make all"
$(BUILD):
@mkdir -p $(BUILD)
$(BUILD)/selftest: $(CORE_SRC) $(SELFTEST_SRC) | $(BUILD)
$(CC) $(CFLAGS) $(INCS) -DCEEDLESS_TRACE_BUFFER \
$(CORE_SRC) $(SELFTEST_SRC) -o $@ $(LDLIBS)
$(BUILD)/negative: $(CORE_SRC) tests/test_fail_main.c | $(BUILD)
$(CC) $(CFLAGS) $(INCS) -DCEEDLESS_TRACE_BUFFER \
$(CORE_SRC) tests/test_fail_main.c -o $@ $(LDLIBS)
$(BUILD)/example_sensor: $(CORE_SRC) $(EXAMPLE_SRC) | $(BUILD)
$(CC) $(CFLAGS) $(INCS) -DCEEDLESS_TRACE_HOST \
-Iexamples/sensor_driver \
$(CORE_SRC) $(EXAMPLE_SRC) -o $@ $(LDLIBS)
test: $(BUILD)/selftest $(BUILD)/negative $(BUILD)/example_sensor
@echo "================================================================"
@echo " ceedless self-tests"
@echo "================================================================"
@./$(BUILD)/selftest
@echo
@echo "================================================================"
@echo " negative path (expected to FAIL)"
@echo "================================================================"
@if ./$(BUILD)/negative; then \
echo "ERROR: negative test should have failed"; exit 1; \
else \
echo "OK: negative test failed as expected"; \
fi
@echo
@echo "================================================================"
@echo " example: sensor_driver"
@echo "================================================================"
@./$(BUILD)/example_sensor
example: $(BUILD)/example_sensor
# Smoke-test the CLI: scaffolds a project, adds a module, runs its tests.
cli-test: cli
@echo "================================================================"
@echo " ceedless CLI smoke test"
@echo "================================================================"
@rm -rf $(BUILD)/cli_demo
@mkdir -p $(BUILD)
@./bin/ceedless new $(BUILD)/cli_demo
@cd $(BUILD)/cli_demo && CEEDLESS_HOME=$(CURDIR) ../../bin/ceedless module hello && CEEDLESS_HOME=$(CURDIR) ../../bin/ceedless test
lint:
@echo "==> gofmt"
@cd cli && out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "$$out"; echo "gofmt issues found"; exit 1; fi
@echo "==> go vet"
@cd cli && go vet ./...
@echo "==> go test"
@cd cli && go test ./...
# Build & run the Cortex-M3 PIL example under QEMU. Skipped from `make all`
# because it requires arm-none-eabi-gcc + qemu-system-arm.
cortex_m:
$(MAKE) -C examples/cortex_m qemu
clean:
rm -rf $(BUILD)