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
|
# Demo of protobufs.
# To run this, you must install protobufs first. The easiest way is:
# sudo apt install protobuf-compiler
# Or you can get the latest source and buid it:
# https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
# The demo is run by:
# make test
# Assumption: protoc and swipl are in your $PATH ... you can override
# these by setting PROTOC= or SWIPL= when envoking "make".
# If you're having problems with the gcc flags, you might need to set
# PKGCONFIG_PATH. For example, if you install the protobuf compiler in
# $HOME/.local (when building with ./configure --prefix=$HOME/.local),
# then set PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig and possibly
# also set LD_LIBRARY_PATH=$HOME/.local/lib or change the rule for
# "foo" to be: $(CXX) -static -o $@ ...
# This demo was tested on Ubuntu 20.04.2 with protoc versions 3.6.1
# (installed using `sudo apt install protobuf-compiler`) and 3.17.3
# (from the sources).
# Many of the rules at the end of this Makefile are for development
# and will eventually be removed.
# Naming conventions - see README.md section "descriptor.proto and friends"
include ../bootstrap/common.mk
.DELETE_ON_ERROR: # Any non-zero return code deletes the target file(s)
.PHONY: FORCE check clean test_all interop_test
.PHONY: test_all test_basic_usage test_send_command test_send_precompiled_command
.DEFAULT_GOAL=test
test: check test_basic_usage test_send_command test_send_precompiled_command
# These files don't need to be kept, but can be useful for debugging:
.PRECIOUS: %.pb.cc %.pb.h %_pb2.py
# Protobuf code generator for C++
%.pb.cc %.pb.h: %.proto
$(PROTOC) $(PROTOC_I) --cpp_out=. $<
foo.o: pb_vector.pb.h foo.cpp
# foo: foo.cpp pb_vector.pb.cc pb_vector.pb.h
foo: pb_vector.pb.o foo.o
@# To run, you might require setting LD_LIBRARY_PATH or specify -static
@# or for non-static: -Wl,-rpath=$(PROTOC_LIB)
@# $(CXX) -Wl,-rpath=$(PROTOC_LIB) -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
@# $(CXX) -static -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
tmp99.tmp: vector_demo.pl ../eventually_implies.pl
$(SWIPL) -s vector_demo.pl -g make_tmp99 --
check: foo tmp99.tmp FORCE
./foo <tmp99.tmp
$(PROTOC) --decode_raw <tmp99.tmp
$(PROTOC) --decode=Vector pb_vector.proto <tmp99.tmp
# Run the basic_usage example
test_basic_usage: vector_demo.pl FORCE
$(SWIPL) -g test_basic_usage -g halt vector_demo.pl
test_send_command: vector_demo.pl FORCE
$(SWIPL) -g test_send_command -g halt vector_demo.pl
test_send_precompiled_command: vector_demo.pl FORCE
$(SWIPL) -g test_send_precompiled_command -g halt vector_demo.pl
clean:
@# TODO: special handling for descriptor.* files
$(RM) -r foo *.tmp *.o *.pb.cc *.pb.h *_pb2.py
git clean -dxf # Should find nothing.
# Assume you've cloned git@github.com:protocolbuffers/protobuf.git (fetch) to $(HOME)/src.
# Note that ../golden_message.2.5.0 is the same as $(HOME)/src/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_message
dump_golden:
$(PROTOC) $(PROTOC_I) \
--decode=protobuf_unittest.TestAllTypes \
google/protobuf/unittest.proto \
<../golden_message.2.5.0
interop_test:
@# "ctest -V -R protobufs" is envoked by "test_protobufs"
cd ../../../build && ninja && ctest -V -R protobufs
$(MAKE) -C ../interop test
.PHONY: testx
testx:
cd ../../../build && ninja
make SWIPL=$(HOME)/src/swipl-devel/build/src/swipl $(HOME)/src/swipl-devel/packages/protobufs/demo test_all
|