1 CFLAGS=-ansi -Wall -Werror -I .. -g -O0 --coverage
3 DEPS=../pb_decode.h ../pb_encode.h ../pb.h person.pb.h callbacks.pb.h unittests.h unittestproto.pb.h alltypes.pb.h missing_fields.pb.h
4 TESTS=test_decode1 test_encode1 decode_unittests encode_unittests
6 all: breakpoints $(TESTS) run_unittests
9 rm -f $(TESTS) person.pb* alltypes.pb* *.o *.gcda *.gcno
13 $(CC) $(CFLAGS) -c -o $@ $<
15 pb_encode.o: ../pb_encode.c $(DEPS)
16 $(CC) $(CFLAGS) -c -o $@ $<
17 pb_decode.o: ../pb_decode.c $(DEPS)
18 $(CC) $(CFLAGS) -c -o $@ $<
20 test_decode1: test_decode1.o pb_decode.o person.pb.o
21 test_decode2: test_decode2.o pb_decode.o person.pb.o
22 test_decode3: test_decode3.o pb_decode.o alltypes.pb.o
23 test_encode1: test_encode1.o pb_encode.o person.pb.o
24 test_encode2: test_encode2.o pb_encode.o person.pb.o
25 test_encode3: test_encode3.o pb_encode.o alltypes.pb.o
26 test_decode_callbacks: test_decode_callbacks.o pb_decode.o callbacks.pb.o
27 test_encode_callbacks: test_encode_callbacks.o pb_encode.o callbacks.pb.o
28 test_missing_fields: test_missing_fields.o pb_encode.o pb_decode.o missing_fields.pb.o
29 decode_unittests: decode_unittests.o pb_decode.o unittestproto.pb.o
30 encode_unittests: encode_unittests.o pb_encode.o unittestproto.pb.o
33 protoc -I. -I../generator -I/usr/include -o$@ $<
35 %.pb.c %.pb.h: %.pb ../generator/nanopb_generator.py
36 python ../generator/nanopb_generator.py $<
38 breakpoints: ../*.c *.c
39 grep -n 'return false;' $^ | cut -d: -f-2 | xargs -n 1 echo b > $@
41 coverage: run_unittests
45 run_unittests: decode_unittests encode_unittests test_encode1 test_encode2 test_encode3 test_decode1 test_decode2 test_decode3 test_encode_callbacks test_decode_callbacks test_missing_fields
48 ./decode_unittests > /dev/null
49 ./encode_unittests > /dev/null
51 [ "`./test_encode1 | ./test_decode1`" = \
52 "`./test_encode1 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
54 [ "`./test_encode2 | ./test_decode1`" = \
55 "`./test_encode2 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
57 [ "`./test_encode2 | ./test_decode2`" = \
58 "`./test_encode2 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
60 [ "`./test_encode_callbacks | ./test_decode_callbacks`" = \
61 "`./test_encode_callbacks | protoc --decode=TestMessage callbacks.proto`" ]
63 ./test_encode3 | ./test_decode3
64 ./test_encode3 | protoc --decode=AllTypes -I. -I../generator -I/usr/include alltypes.proto >/dev/null
68 run_fuzztest: test_decode2
69 bash -c 'I=1; while true; do cat /dev/urandom | ./test_decode2 > /dev/null; I=$$(($$I+1)); echo -en "\r$$I"; done'