forked from cantools/cantools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (181 loc) · 4.79 KB
/
Makefile
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
ifeq ($(origin CC), default)
CC = gcc
endif
C_SOURCES := \
tests/files/c_source/motohawk.c \
tests/files/c_source/padding_bit_order.c \
tests/files/c_source/vehicle.c \
tests/files/c_source/multiplex.c \
tests/files/c_source/multiplex_2.c \
tests/files/c_source/floating_point.c \
tests/files/c_source/no_signals.c \
tests/files/c_source/choices.c \
tests/files/c_source/signed.c \
tests/files/c_source/my_database_name.c \
tests/files/c_source/min_max_only_6_0.c \
tests/files/c_source/abs.c
C_SOURCES_BIT_FIELDS := \
tests/files/c_source/motohawk_bit_fields.c \
tests/files/c_source/floating_point_bit_fields.c \
tests/files/c_source/signed_bit_fields.c
CFLAGS_EXTRA := \
-Wduplicated-branches \
-Wduplicated-cond \
-Wjump-misses-init \
-Wlogical-op \
-Wnull-dereference \
-Wrestrict
CFLAGS_EXTRA_CLANG := \
-fsanitize=address \
-fsanitize=undefined,nullability \
-Warray-bounds-pointer-arithmetic \
-Wassign-enum \
-Wbad-function-cast \
-Wcast-align \
-Wcast-qual \
-Wchar-subscripts \
-Wcomma \
-Wcomment \
-Wconditional-uninitialized \
-Wcovered-switch-default \
-Wdate-time \
-Wdocumentation \
-Wduplicate-decl-specifier \
-Wduplicate-enum \
-Wduplicate-method-arg \
-Wduplicate-method-match \
-Wembedded-directive \
-Wempty-translation-unit \
-Wexpansion-to-defined \
-Wflexible-array-extensions \
-Wfloat-conversion \
-Wfloat-equal \
-Wfloat-overflow-conversion \
-Wfloat-zero-conversion \
-Wformat-non-iso \
-Wformat-nonliteral \
-Wformat-pedantic \
-Wfour-char-constants \
-Wgnu-anonymous-struct \
-Wgnu-array-member-paren-init \
-Wgnu-auto-type \
-Wgnu-binary-literal \
-Wgnu-case-range \
-Wgnu-complex-integer \
-Wgnu-compound-literal-initializer \
-Wgnu-conditional-omitted-operand \
-Wgnu-designator \
-Wgnu-empty-initializer \
-Wgnu-empty-struct \
-Wgnu-flexible-array-initializer \
-Wgnu-flexible-array-union-member \
-Wgnu-folding-constant \
-Wgnu-imaginary-constant \
-Wgnu-include-next \
-Wgnu-label-as-value \
-Wgnu-redeclared-enum \
-Wgnu-statement-expression \
-Wgnu-union-cast \
-Wgnu-zero-line-directive \
-Wgnu-zero-variadic-macro-arguments \
-Wheader-hygiene \
-Widiomatic-parentheses \
-Wimplicit \
-Wimplicit-fallthrough \
-Wloop-analysis \
-Wmethod-signatures \
-Wmissing-braces \
-Wmissing-field-initializers \
-Wnested-anon-types \
-Wnewline-eof \
-Wnull-pointer-arithmetic \
-Woverlength-strings \
-Wpointer-arith \
-Wsign-compare \
-Wtautological-compare \
-Wundef \
-Wuninitialized \
-Wunreachable-code \
-Wunreachable-code-aggressive \
-Wunused-comparison \
-Wunused-const-variable \
-Wunused-parameter \
-Wunused-variable \
-Wvariadic-macros \
-Wzero-as-null-pointer-constant \
-Wzero-length-array
CFLAGS := \
-std=c99 \
-Wall \
-Wextra \
-Wdouble-promotion \
-Wfloat-equal \
-Wformat=2 \
-Wshadow \
-Werror
CFLAGS += $(shell $(CC) -Werror $(CFLAGS_EXTRA) -c tests/dummy.c 2> /dev/null \
&& echo $(CFLAGS_EXTRA))
CFLAGS += $(shell $(CC) -Werror $(CFLAGS_EXTRA_CLANG) -c tests/dummy.c 2> /dev/null \
&& echo $(CFLAGS_EXTRA_CLANG))
FUZZER_CC ?= clang
FUZZER_EXE = multiplex_2_fuzzer
FUZZER_C_SOURCES = \
tests/files/c_source/multiplex_2_fuzzer.c \
tests/files/c_source/multiplex_2.c
FUZZER_CFLAGS = \
-fprofile-instr-generate \
-fcoverage-mapping \
-Itests/files/c_source \
-g -fsanitize=address,fuzzer \
-fsanitize=signed-integer-overflow \
-fno-sanitize-recover=all
FUZZER_EXECUTION_TIME ?= 30
.PHONY: test
test:
python3 setup.py test
$(MAKE) test-sdist
env PYTHONPATH=. python3 examples/hello_world.py
env PYTHONPATH=. python3 examples/dbc_io/main.py
env PYTHONPATH=. python3 examples/diagnostics/did.py
codespell -L datas -d $$(git ls-files | grep -v \.kcd | grep -v \.[hc])
$(MAKE) test-c
.PHONY: test-c-src
test-c-src:
for f in $(C_SOURCES) ; do \
$(CC) $(CFLAGS) -Wconversion -Wpedantic -std=c99 -O3 -c $$f ; \
done
for f in $(C_SOURCES_BIT_FIELDS) ; do \
$(CC) $(CFLAGS) -fpack-struct -std=c99 -O3 -c $$f ; \
done
.PHONY: test-c
test-c:
$(MAKE) test-c-src
$(MAKE) -C tests
.PHONY: test-c-clean
test-c-clean:
$(MAKE) -C tests clean
.PHONY: test-c-fuzzer
test-c-fuzzer:
$(FUZZER_CC) $(FUZZER_CFLAGS) $(FUZZER_C_SOURCES) -o $(FUZZER_EXE)
rm -f $(FUZZER_EXE).profraw
LLVM_PROFILE_FILE="$(FUZZER_EXE).profraw" \
./$(FUZZER_EXE) \
-max_total_time=$(FUZZER_EXECUTION_TIME)
llvm-profdata merge -sparse $(FUZZER_EXE).profraw -o $(FUZZER_EXE).profdata
llvm-cov show ./$(FUZZER_EXE) -instr-profile=$(FUZZER_EXE).profdata
llvm-cov report ./$(FUZZER_EXE) -instr-profile=$(FUZZER_EXE).profdata
.PHONY: test-sdist
test-sdist:
rm -rf dist
python3 setup.py sdist
cd dist && \
mkdir test && \
cd test && \
tar xf ../*.tar.gz && \
cd cantools-* && \
python3 setup.py test
.PHONY: release-to-pypi
release-to-pypi:
python3 setup.py sdist
python3 setup.py bdist_wheel --universal
twine upload dist/*