summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile553
1 files changed, 217 insertions, 336 deletions
diff --git a/Makefile b/Makefile
index edc9fe5..1a985af 100644
--- a/Makefile
+++ b/Makefile
@@ -18,41 +18,47 @@
.PHONY: all lib clean tests test benchmarks benchmark descriptorgen
.PHONY: clean_leave_profile
-# Default rule: just build libupb.
-default: lib
+# Prevents the deletion of intermediate files.
+.SECONDARY:
+
+UPB_MODULES = upb upb.pb upb.descriptor
+UPB_LIBS = $(patsubst %,lib/lib%.a,$(UPB_MODULES))
+UPB_PICLIBS = $(patsubst %,lib/lib%_pic.a,$(UPB_MODULES))
+
+# Default rule: build all upb libraries (but no bindings)
+default: $(UPB_LIBS)
# All: build absolutely everything
all: lib tests benchmarks tools/upbc lua python
testall: test pythontest
-# User-specified CFLAGS.
-USER_CFLAGS=
-USER_CXXFLAGS=
+# Set this to have user-specific flags (especially things like -O0 and -g).
+USER_CPPFLAGS=
-# If the user doesn't specify an -O setting, we default to -O3, except
-# for def which gets -Os.
-ifeq (, $(findstring -O, $(USER_CFLAGS)))
- USER_CFLAGS += -O3
- DEF_OPT = -Os
-endif
-
-ifneq (, $(findstring DUPB_USE_JIT_X64, $(USER_CFLAGS)))
- USE_JIT=true
-endif
+# Build with "make WITH_JIT=yes" (or anything besides "no") to enable the JIT.
+WITH_JIT=no
# Basic compiler/flag setup.
CC=cc
CXX=c++
-CFLAGS=-std=gnu99
-CXXFLAGS=$(USER_CXXFLAGS)
-INCLUDE=-Itests -I.
-CPPFLAGS=$(INCLUDE) -DNDEBUG -Wall -Wextra -Wno-sign-compare -Wno-unused-private-field $(USER_CFLAGS)
+CFLAGS=-std=c99
+CXXFLAGS=-Wno-unused-private-field $(USER_CXXFLAGS)
+INCLUDE=-I.
+CPPFLAGS=$(INCLUDE) -DNDEBUG -Wall -Wextra -Wno-sign-compare $(USER_CPPFLAGS)
LDLIBS=-lpthread upb/libupb.a
LUA=lua # 5.1 and 5.2 should both be supported
+ifneq ($(WITH_JIT), no)
+ USE_JIT=true
+ CPPFLAGS += -DUPB_USE_JIT_X64
+endif
+
# Build with "make Q=" to see all commands that are being executed.
Q=@
+# Function to expand a wildcard pattern recursively.
+rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d)))
+
ifeq ($(Q), @)
E=@echo
else
@@ -68,23 +74,55 @@ install:
# Unfortuantely we can't easily generate deps for benchmarks or tests because
# of the scheme we use that compiles the same source file multiple times with
# different -D options, which can include different header files.
-ALLSRC=$(shell find . -name '*.c' -print | grep -v perf-tmp)
-deps: Makefile $(ALLSRC)
+dep:
$(E) Regenerating dependencies for upb/...
@set -e
@rm -f deps
- @for file in $(ALLSRC); do \
+ @for file in $$(find . -name '*.c'); do \
gcc -MM $$file -MT $${file%.*}.o $(CPPFLAGS) -I. >> deps 2> /dev/null; \
done
-# Source files. ###############################################################
+clean_leave_profile:
+ rm -rf obj lib
+ rm -f benchmark/google_messages.proto.pb benchmark/google_messages.pb.* benchmarks/b.* benchmarks/*.pb*
+ rm -f $(TESTS) tests/testmain.o tests/t.*
+ rm -f tests/test.proto.pb
+ rm -f upb/descriptor.pb
+ rm -rf tools/upbc deps
+ rm -rf upb/bindings/python/build
+ rm -f upb/bindings/ruby/Makefile
+ rm -f upb/bindings/ruby/upb.so
+ rm -f upb/bindings/ruby/mkmf.log
+ find . | grep dSYM | xargs rm -rf
+
+clean: clean_leave_profile
+ rm -rf $(call rwildcard,,*.gcno) $(call rwildcard,,*.gcda)
+
+# A little bit of Make voodoo: you can call this from the deps of a patterned
+# rule like so:
+#
+# all: lib/libfoo.bar.a
+#
+# foo_bar_SRCS = a.c b.c
+#
+# # This will expand into a.o b.o
+# lib/lib%.a: $(call make_objs,o)
+# gcc -c -o $@ $^
+#
+# SECONDEXPANSION: flips on a bit essentially that allows this "seconary
+# expansion": it must appear before anything that uses make_objs.
+.SECONDEXPANSION:
+to_srcs = $(subst .,_,$(1)_SRCS)
+pc = %
+make_objs = $$(patsubst upb/$$(pc).c,obj/$$(pc).$(1),$$($$(call to_srcs,$$*)))
+make_objs_cc = $$(patsubst upb/$$(pc).cc,obj/$$(pc).$(1),$$($$(call to_srcs,$$*)))
+
-# The core library.
-CORE= \
+# Core libraries (ie. not bindings). ###############################################################
+
+upb_SRCS = \
upb/def.c \
- upb/descriptor/reader.c \
- upb/descriptor/descriptor.upb.c \
upb/handlers.c \
upb/refcounted.c \
upb/shim/shim.c \
@@ -92,104 +130,67 @@ CORE= \
upb/table.c \
upb/upb.c \
-GOOGLEPB= \
- upb/bindings/googlepb/bridge.cc \
- upb/bindings/googlepb/proto2.cc \
+upb_descriptor_SRCS = \
+ upb/descriptor/reader.c \
+ upb/descriptor/descriptor.upb.c \
-# Library for the protocol buffer format (both text and binary).
-PB= \
+upb_pb_SRCS = \
upb/pb/decoder.c \
upb/pb/compile_decoder.c \
upb/pb/glue.c \
upb/pb/varint.c \
upb/pb/textprinter.c \
+# If the JIT is enabled we include its source.
+# If Lua is present we can use DynASM to regenerate the .h file.
+ifdef USE_JIT
+upb_pb_SRCS += upb/pb/compile_decoder_x64.c
+obj/pb/compile_decoder_x64.o obj/pb/compile_decoder_x64.lo: upb/pb/compile_decoder_x64.h
-# Rules. #######################################################################
-
-clean_leave_profile:
- rm -rf $(LIBUPB) $(LIBUPB_PIC)
- rm -rf $(call rwildcard,,*.o) $(call rwildcard,,*.lo) $(call rwildcard,,*.dSYM)
- rm -rf upb/pb/decoder_x64.h
- rm -rf benchmark/google_messages.proto.pb benchmark/google_messages.pb.* benchmarks/b.* benchmarks/*.pb*
- rm -rf upb/pb/jit_debug_elf_file.o
- rm -rf upb/pb/jit_debug_elf_file.h
- rm -rf $(TESTS) tests/t.*
- rm -rf upb/descriptor.pb
- rm -rf tools/upbc deps
- rm -rf upb/bindings/lua/upb.so
- rm -rf upb/bindings/python/build
- rm -rf upb/bindings/ruby/Makefile
- rm -rf upb/bindings/ruby/upb.so
+upb/pb/compile_decoder_x64.h: upb/pb/compile_decoder_x64.dasc
+ $(E) DYNASM $<
+ $(Q) $(LUA) dynasm/dynasm.lua upb/pb/compile_decoder_x64.dasc > upb/pb/compile_decoder_x64.h || (rm upb/pb/compile_decoder_x64.h ; false)
+endif
-clean: clean_leave_profile
- rm -rf $(call rwildcard,,*.gcno) $(call rwildcard,,*.gcda)
+upb_json_SRCS = \
+ upb/json/typed_printer.c
-# Core library (libupb.a).
-SRC=$(CORE) $(PB) $(GOOGLEPB)
-LIBUPB=upb/libupb.a
-LIBUPB_PIC=upb/libupb_pic.a
-lib: $(LIBUPB)
+# If the user doesn't specify an -O setting, we use -O3 for critical-path
+# code and -Os for the rest.
+ifeq (, $(findstring -O, $(USER_CFLAGS)))
+OPT = -O3
+lib/libupb.a : OPT = -Os
+lib/libupb.descriptor.a : OPT = -Os
+endif
+$(UPB_PICLIBS): lib/lib%_pic.a: $(call make_objs,lo)
+ $(E) AR $@
+ $(Q) mkdir -p lib && ar rcs $@ $^
-OBJ=$(patsubst %.c,%.o,$(SRC)) $(patsubst %.cc,%.o,$(SRC))
-PICOBJ=$(patsubst %.c,%.lo,$(SRC)) $(patsubst %.cc,%.lo,$(SRC))
+$(UPB_LIBS): lib/lib%.a: $(call make_objs,o)
+ $(E) AR $@
+ $(Q) mkdir -p lib && ar rcs $@ $^
-ifdef USE_JIT
-PB += upb/pb/compile_decoder_x64.c
-upb/pb/compile_decoder_x64.o upb/pb/compile_decoder_x64.lo: upb/pb/compile_decoder_x64.h
-endif
-$(LIBUPB): $(OBJ)
- $(E) AR $(LIBUPB)
- $(Q) ar rcs $(LIBUPB) $(OBJ)
-$(LIBUPB_PIC): $(PICOBJ)
- $(E) AR $(LIBUPB_PIC)
- $(Q) ar rcs $(LIBUPB_PIC) $(PICOBJ)
-
-%.o : %.c
+obj/%.o: upb/%.c | $$(@D)/.
$(E) CC $<
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+ $(Q) $(CC) $(OPT) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
-%.o : %.cc
+obj/%.o: upb/%.cc | $$(@D)/.
$(E) CXX $<
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
+ $(Q) $(CXX) $(OPT) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
-%.lo : %.c
+obj/%.lo: upb/%.c | $$(@D)/.
$(E) 'CC -fPIC' $<
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< -fPIC
+ $(Q) $(CC) $(OPT) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -fPIC
-%.o : %.cc
+obj/%.lo: upb/%.cc | $$(@D)/.
$(E) CXX $<
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -fPIC
+ $(Q) $(CXX) $(OPT) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< -fPIC
-# Override the optimization level for def.o, because it is not in the
-# critical path but gets very large when -O3 is used.
-upb/def.o: upb/def.c
- $(E) CC $<
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(DEF_OPT) -c -o $@ $<
-
-upb/def.lo: upb/def.c
- $(E) 'CC -fPIC' $<
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(DEF_OPT) -c -o $@ $< -fPIC
-
-upb/pb/compile_decoder_x64.h: upb/pb/compile_decoder_x64.dasc
- $(E) DYNASM $<
- $(Q) $(LUA) dynasm/dynasm.lua upb/pb/compile_decoder_x64.dasc > upb/pb/compile_decoder_x64.h || (rm upb/pb/compile_decoder_x64.h ; false)
-
-ifneq ($(shell uname), Darwin)
-upb/pb/jit_debug_elf_file.o: upb/pb/jit_debug_elf_file.s
- $(E) GAS $<
- $(Q) gcc -c upb/pb/jit_debug_elf_file.s -o upb/pb/jit_debug_elf_file.o
-
-upb/pb/jit_debug_elf_file.h: upb/pb/jit_debug_elf_file.o
- $(E) XXD $<
- $(Q) xxd -i < upb/pb/jit_debug_elf_file.o > upb/pb/jit_debug_elf_file.h
-upb/pb/compile_decoder_x64.h: upb/pb/jit_debug_elf_file.h
-endif
-
-# Function to expand a wildcard pattern recursively.
-rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d)))
+# Note: mkdir -p is technically susceptible to races when used with make -j.
+%/.:
+ $(Q) mkdir -p $@
# Regenerating the auto-generated files in upb/.
upb/descriptor.pb: upb/descriptor.proto
@@ -210,285 +211,165 @@ examples/msg: examples/msg.c $(LIBUPB)
# Tests. #######################################################################
-tests/test.proto.pb: tests/test.proto
- @# TODO: replace with upbc
- protoc tests/test.proto -otests/test.proto.pb
+# This section contains only the tests that don't depend on any external
+# libraries.
-SIMPLE_TESTS= \
- tests/test_def \
+C_TESTS = \
tests/pb/test_varint \
- tests/test_handlers
+ tests/test_def \
+ tests/test_handlers \
-SIMPLE_CXX_TESTS= \
+CC_TESTS = \
tests/pb/test_decoder \
- tests/test_cpp
-
-
-VARIADIC_TESTS= \
- tests/t.test_vs_proto2.googlemessage1 \
- tests/t.test_vs_proto2.googlemessage2 \
+ tests/test_cpp \
+ tests/test_table \
-TESTS=$(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS) $(VARIADIC_TESTS) tests/test_table
-
-tests: $(TESTS) $(INTERACTIVE_TESTS)
-$(TESTS): $(LIBUPB)
-tests/test_def: tests/test.proto.pb
+TESTS=$(C_TESTS) $(CC_TESTS)
+tests: $(TESTS)
tests/testmain.o: tests/testmain.cc
$(E) CXX $<
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-$(SIMPLE_TESTS): tests/testmain.o
-$(SIMPLE_TESTS): % : %.c
+$(C_TESTS): % : %.c tests/testmain.o $$(LIBS)
$(E) CC $<
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/testmain.o $< $(LIBUPB)
+ $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ tests/testmain.o $< $(LIBS)
-$(SIMPLE_CXX_TESTS): tests/testmain.o
-$(SIMPLE_CXX_TESTS): % : %.cc
+$(CC_TESTS): % : %.cc tests/testmain.o $$(LIBS)
$(E) CXX $<
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ tests/testmain.o $< $(LIBUPB)
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -Wno-deprecated -o $@ tests/testmain.o $< $(LIBS)
+
+# Several of these tests don't actually test these libs, but use them
+# incidentally to load a descriptor
+LOAD_DESCRIPTOR_LIBS = lib/libupb.pb.a lib/libupb.descriptor.a
+
+# Specify which libs each test depends on.
+tests/pb/test_varint: LIBS = lib/libupb.pb.a lib/libupb.a
+tests/test_def: LIBS = $(LOAD_DESCRIPTOR_LIBS) lib/libupb.a
+tests/test_handlers: LIBS = lib/libupb.descriptor.a lib/libupb.a
+tests/pb/test_decoder: LIBS = lib/libupb.pb.a lib/libupb.a
+tests/test_cpp: LIBS = $(LOAD_DESCRIPTOR_LIBS) lib/libupb.a
+tests/test_table: LIBS = lib/libupb.a
+
+tests/test_def: tests/test.proto.pb
+
+tests/test.proto.pb: tests/test.proto
+ @# TODO: add .proto file parser to upb so this isn't necessary.
+ protoc tests/test.proto -otests/test.proto.pb
+
+VARIADIC_TESTS= \
+ tests/t.test_vs_proto2.googlemessage1 \
+ tests/t.test_vs_proto2.googlemessage2 \
+
+ifeq ($(RUN_UNDER), valgrind)
+RUN_UNDER=valgrind --leak-check=full --error-exitcode=1 --track-origins=yes
+endif
-#VALGRIND=valgrind --leak-check=full --error-exitcode=1 --track-origins=yes
-VALGRIND=
test: tests
@set -e # Abort on error.
- @for test in $(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS); do \
+ @find tests -perm -u+x -type f | while read test; do \
if [ -x ./$$test ] ; then \
- echo !!! $(VALGRIND) ./$$test; \
- $(VALGRIND) ./$$test tests/test.proto.pb || exit 1; \
+ echo "RUN $$test"; \
+ $(RUN_UNDER) ./$$test tests/test.proto.pb || exit 1; \
fi \
done;
- @$(VALGRIND) ./tests/t.test_vs_proto2.googlemessage1 benchmarks/google_message1.dat || exit 1;
- @$(VALGRIND) ./tests/t.test_vs_proto2.googlemessage2 benchmarks/google_message2.dat || exit 1;
@echo "All tests passed!"
-tests/t.test_vs_proto2.googlemessage1 \
-tests/t.test_vs_proto2.googlemessage2: \
- tests/test_vs_proto2.cc $(LIBUPB) benchmarks/google_messages.proto.pb \
- benchmarks/google_messages.pb.cc
- $(E) CXX $< '(benchmarks::SpeedMessage1)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tests/t.test_vs_proto2.googlemessage1 $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"../benchmarks/google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"../benchmarks/google_message1.dat\" \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage1" \
- -DMESSAGE_HFILE=\"../benchmarks/google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc tests/testmain.o -lprotobuf -lpthread $(LIBUPB)
- $(E) CXX $< '(benchmarks::SpeedMessage2)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tests/t.test_vs_proto2.googlemessage2 $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"../benchmarks/google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"../benchmarks/google_message2.dat\" \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
- -DMESSAGE_HFILE=\"../benchmarks/google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc tests/testmain.o -lprotobuf -lpthread $(LIBUPB)
-tests/test_table: tests/test_table.cc
- @# Includes <hash_set> which is a deprecated header.
- $(E) CXX $<
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wno-deprecated -o $@ $< tests/testmain.o $(LIBUPB)
-tests/tests: upb/libupb.a
+# Google protobuf binding ######################################################
+upb_bindings_googlepb_SRCS = \
+ upb/bindings/googlepb/bridge.cc \
+ upb/bindings/googlepb/proto2.cc \
-# Benchmarks. ##################################################################
+GOOGLEPB_TESTS = \
+ tests/bindings/googlepb/test_vs_proto2.googlemessage1 \
+ tests/bindings/googlepb/test_vs_proto2.googlemessage2 \
-# Benchmarks
-UPB_BENCHMARKS=benchmarks/b.parsestream_googlemessage1.upb_table \
- benchmarks/b.parsestream_googlemessage2.upb_table \
+GOOGLEPB_LIB=lib/libupb.bindings.googlepb.a
-ifdef USE_JIT
-UPB_BENCHMARKS += \
- benchmarks/b.parsestream_googlemessage1.upb_jit \
- benchmarks/b.parsestream_googlemessage2.upb_jit \
- benchmarks/b.parsetoproto2_googlemessage1.upb_jit \
- benchmarks/b.parsetoproto2_googlemessage2.upb_jit
-endif
+.PHONY: googlepb clean_googlepb googlepbtest
+clean: clean_googlepb
+clean_googlepb:
+ rm -f tests/bindings/googlepb/test_vs_proto2.googlemessage*
+ rm -f $(GOOGLEPB_LIB)
+googlepb: default $(GOOGLEPB_LIB)
+googlepbtest: $(GOOGLEPB_TESTS)
-BENCHMARKS=$(UPB_BENCHMARKS) \
- benchmarks/b.parsetostruct_googlemessage1.proto2_table \
- benchmarks/b.parsetostruct_googlemessage2.proto2_table \
- benchmarks/b.parsetostruct_googlemessage1.proto2_compiled \
- benchmarks/b.parsetostruct_googlemessage2.proto2_compiled \
- benchmarks/b.parsetoproto2_googlemessage1.upb \
- benchmarks/b.parsetoproto2_googlemessage2.upb
-
-upb_benchmarks: $(UPB_BENCHMARKS)
-benchmarks: $(BENCHMARKS)
-upb_benchmark: $(UPB_BENCHMARKS)
- @rm -f benchmarks/results
- @rm -rf benchmarks/*.dSYM
- @for test in benchmarks/b.* ; do ./$$test ; done
-benchmark: $(BENCHMARKS)
- @rm -f benchmarks/results
- @rm -rf benchmarks/*.dSYM
- @for test in benchmarks/b.* ; do ./$$test ; done
+lib/libupb.bindings.googlepb.a: $(upb_bindings_googlepb_SRCS:upb/%.cc=obj/%.o)
+ $(E) AR $@
+ $(Q) mkdir -p lib && ar rcs $@ $^
+# These generated files live in benchmarks/ but are used by both tests and
+# benchmarks.
benchmarks/google_messages.proto.pb: benchmarks/google_messages.proto
@# TODO: replace with upbc.
protoc benchmarks/google_messages.proto -obenchmarks/google_messages.proto.pb
-
benchmarks/google_messages.pb.cc: benchmarks/google_messages.proto
protoc benchmarks/google_messages.proto --cpp_out=.
-# This basic idea is useful (varying the benchmarks' setup by recompiling
-# several times with different #defines) but the implementation in this
-# Makefile is verbose and error-prone. Open to better ideas here. I don't
-# want to make these command-line parameters -- it makes it more annoying to
-# debug or profile them.
-
-benchmarks/b.parsetostruct_googlemessage1.upb_table \
-benchmarks/b.parsetostruct_googlemessage2.upb_table: \
- benchmarks/parsetostruct.upb.c $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CC benchmarks/parsetostruct.upb.c (benchmarks.SpeedMessage1, nojit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage1.upb_table $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message1.dat\" \
- -DJIT=false $(LIBUPB)
- $(E) 'CC benchmarks/parsetostruct.upb.c (benchmarks.SpeedMessage2, nojit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage2.upb_table $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message2.dat\" \
- -DJIT=false $(LIBUPB)
-
-benchmarks/b.parsestream_googlemessage1.upb_table \
-benchmarks/b.parsestream_googlemessage2.upb_table: \
- benchmarks/parsestream.upb.c $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CC benchmarks/parsestream.upb.c (benchmarks.SpeedMessage1, nojit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsestream_googlemessage1.upb_table $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message1.dat\" -DJIT=false \
- $(LIBUPB)
- $(E) 'CC benchmarks/parsestream.upb.c (benchmarks.SpeedMessage2, nojit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsestream_googlemessage2.upb_table $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message2.dat\" -DJIT=false \
- $(LIBUPB)
-
-ifdef USE_JIT
-benchmarks/b.parsetostruct_googlemessage1.upb_jit \
-benchmarks/b.parsetostruct_googlemessage2.upb_jit: \
- benchmarks/parsetostruct.upb.c $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CC benchmarks/parsetostruct.upb.c (benchmarks.SpeedMessage1, jit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage1.upb_jit $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message1.dat\" -DJIT=true \
- -DJIT=true $(LIBUPB)
- $(E) 'CC benchmarks/parsetostruct.upb.c (benchmarks.SpeedMessage2, jit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage2.upb_jit $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message2.dat\" -DJIT=true \
- -DJIT=true $(LIBUPB)
-
-benchmarks/b.parsestream_googlemessage1.upb_jit \
-benchmarks/b.parsestream_googlemessage2.upb_jit: \
- benchmarks/parsestream.upb.c $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CC benchmarks/parsestream.upb.c (benchmarks.SpeedMessage1, jit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsestream_googlemessage1.upb_jit $< \
+tests/bindings/googlepb/test_vs_proto2.googlemessage1: \
+ tests/bindings/googlepb/test_vs_proto2.cc $(LIBUPB) benchmarks/google_messages.proto.pb \
+ benchmarks/google_messages.pb.cc
+ $(E) CXX $< '(benchmarks::SpeedMessage1)'
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< \
-DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message1.dat\" -DJIT=true \
- $(LIBUPB)
- $(E) 'CC benchmarks/parsestream.upb.c (benchmarks.SpeedMessage2, jit)'
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -o benchmarks/b.parsestream_googlemessage2.upb_jit $< \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- -DMESSAGE_FILE=\"google_message2.dat\" -DJIT=true \
- $(LIBUPB)
-
-benchmarks/b.parsetoproto2_googlemessage1.upb_jit \
-benchmarks/b.parsetoproto2_googlemessage2.upb_jit: \
- benchmarks/parsetoproto2.upb.cc benchmarks/google_messages.pb.cc $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CXX benchmarks/parsetoproto2.upb.cc (benchmarks.SpeedMessage1, jit)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetoproto2_googlemessage1.upb_jit $< \
+ -DMESSAGE_DESCRIPTOR_FILE=\"../benchmarks/google_messages.proto.pb\" \
+ -DMESSAGE_FILE=\"../benchmarks/google_message1.dat\" \
-DMESSAGE_CIDENT="benchmarks::SpeedMessage1" \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_FILE=\"google_message1.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" -DJIT=true \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread $(LIBUPB)
- $(E) 'CXX benchmarks/parsetoproto2.upb.cc (benchmarks.SpeedMessage2, jit)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetoproto2_googlemessage2.upb_jit $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_FILE=\"google_message2.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" -DJIT=true \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread $(LIBUPB)
-endif
+ -DMESSAGE_HFILE=\"../benchmarks/google_messages.pb.h\" \
+ benchmarks/google_messages.pb.cc tests/testmain.o -lprotobuf -lpthread \
+ lib/libupb.bindings.googlepb.a lib/libupb.pb.a lib/libupb.descriptor.a lib/libupb.a
-benchmarks/b.parsetostruct_googlemessage1.proto2_table \
-benchmarks/b.parsetostruct_googlemessage2.proto2_table: \
- benchmarks/parsetostruct.proto2_table.cc benchmarks/google_messages.pb.cc
- $(E) 'CXX benchmarks/parsetostruct.proto2_table.cc (benchmarks.SpeedMessage1)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage1.proto2_table $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage1" \
- -DMESSAGE_FILE=\"google_message1.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread
- $(E) 'CXX benchmarks/parsetostruct.proto2_table.cc (benchmarks.SpeedMessage2)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage2.proto2_table $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
- -DMESSAGE_FILE=\"google_message2.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread
-
-benchmarks/b.parsetostruct_googlemessage1.proto2_compiled \
-benchmarks/b.parsetostruct_googlemessage2.proto2_compiled: \
- benchmarks/parsetostruct.proto2_compiled.cc benchmarks/google_messages.pb.cc
- $(E) 'CXX benchmarks/parsetostruct.proto2_compiled.cc (benchmarks.SpeedMessage1)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage1.proto2_compiled $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage1" \
- -DMESSAGE_FILE=\"google_message1.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread
- $(E) 'CXX benchmarks/parsetostruct.proto2_compiled.cc (benchmarks.SpeedMessage2)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetostruct_googlemessage2.proto2_compiled $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
- -DMESSAGE_FILE=\"google_message2.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread
-
-benchmarks/b.parsetoproto2_googlemessage1.upb \
-benchmarks/b.parsetoproto2_googlemessage2.upb: \
- benchmarks/parsetoproto2.upb.cc benchmarks/google_messages.pb.cc $(LIBUPB) benchmarks/google_messages.proto.pb
- $(E) 'CXX benchmarks/parsetoproto2.upb.cc (benchmarks.SpeedMessage1, nojit)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetoproto2_googlemessage1.upb $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage1" \
- -DMESSAGE_NAME=\"benchmarks.SpeedMessage1\" \
- -DMESSAGE_FILE=\"google_message1.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" -DJIT=false \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread $(LIBUPB)
- $(E) 'CXX benchmarks/parsetoproto2.upb.cc (benchmarks.SpeedMessage2, nojit)'
- $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o benchmarks/b.parsetoproto2_googlemessage2.upb $< \
- -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
+tests/bindings/googlepb/test_vs_proto2.googlemessage2: \
+ tests/bindings/googlepb/test_vs_proto2.cc $(LIBUPB) benchmarks/google_messages.proto.pb \
+ benchmarks/google_messages.pb.cc
+ $(E) CXX $< '(benchmarks::SpeedMessage2)'
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< \
-DMESSAGE_NAME=\"benchmarks.SpeedMessage2\" \
- -DMESSAGE_FILE=\"google_message2.dat\" \
- -DMESSAGE_HFILE=\"google_messages.pb.h\" \
- -DMESSAGE_DESCRIPTOR_FILE=\"google_messages.proto.pb\" -DJIT=false \
- benchmarks/google_messages.pb.cc -lprotobuf -lpthread $(LIBUPB)
+ -DMESSAGE_DESCRIPTOR_FILE=\"../benchmarks/google_messages.proto.pb\" \
+ -DMESSAGE_FILE=\"../benchmarks/google_message2.dat\" \
+ -DMESSAGE_CIDENT="benchmarks::SpeedMessage2" \
+ -DMESSAGE_HFILE=\"../benchmarks/google_messages.pb.h\" \
+ benchmarks/google_messages.pb.cc tests/testmain.o -lprotobuf -lpthread \
+ lib/libupb.bindings.googlepb.a lib/libupb.pb.a lib/libupb.descriptor.a lib/libupb.a
# Lua extension ##################################################################
-LUA_CPPFLAGS = $(strip $(shell pkg-config --silence-errors --cflags lua || pkg-config --silence-errors --cflags lua5.1 || echo '-I/usr/local/include'))
ifeq ($(shell uname), Darwin)
LUA_LDFLAGS = -undefined dynamic_lookup
else
LUA_LDFLAGS =
endif
-LUAEXT=upb/bindings/lua/upb.so
-lua: $(LUAEXT)
-upb/bindings/lua/upb.so: upb/bindings/lua/upb.c $(LIBUPB_PIC)
- $(E) CC bindings/lua/upb.c
- $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(LUA_CPPFLAGS) -fpic -shared -o $@ $< upb/libupb_pic.a $(LUA_LDFLAGS)
+LUAEXTS = \
+ upb/bindings/lua/upb.so \
+ upb/bindings/lua/upb.pb.so \
+
+.PHONY: clean_lua testlua lua
+clean: clean_lua
+testlua:
+ LUA_PATH=tests/bindings/lua/?.lua LUA_CPATH=upb/bindings/lua/?.so lua tests/bindings/lua/upb.lua
+
+clean_lua:
+ rm -f upb/bindings/lua/upb.lua.h
+ rm -f upb/bindings/lua/upb.so
+ rm -f upb/bindings/lua/upb.pb.so
+
+lua: $(LUAEXTS)
+
+upb/bindings/lua/upb.lua.h:
+ $(E) XXD upb/bindings/lua/upb.lua
+ $(Q) xxd -i < upb/bindings/lua/upb.lua > upb/bindings/lua/upb.lua.h
+
+upb/bindings/lua/upb.so: upb/bindings/lua/upb.c upb/bindings/lua/upb.lua.h lib/libupb.descriptor_pic.a lib/libupb_pic.a lib/libupb.pb_pic.a
+ $(E) CC upb/bindings/lua/upb.c
+ $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -shared -o $@ $< lib/libupb.pb_pic.a lib/libupb.descriptor_pic.a lib/libupb_pic.a $(LUA_LDFLAGS)
+
+upb/bindings/lua/upb.pb.so: upb/bindings/lua/upb.pb.c lib/libupb_pic.a lib/libupb.pb_pic.a
+ $(E) CC upb/bindings/lua/upb.pb.c
+ $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -shared -o $@ $< $(LUA_LDFLAGS)
# Python extension #############################################################
@@ -508,9 +389,9 @@ pythontest: $(PYTHONEXT)
RUBY=ruby
RUBYEXT=upb/bindings/ruby/upb.so
ruby: $(RUBYEXT)
-upb/bindings/ruby/Makefile: upb/bindings/ruby/extconf.rb
+upb/bindings/ruby/Makefile: upb/bindings/ruby/extconf.rb lib/libupb_pic.a lib/libupb.pb_pic.a lib/libupb.descriptor_pic.a
$(E) RUBY upb/bindings/ruby/extconf.rb
$(Q) cd upb/bindings/ruby && ruby extconf.rb
-$(RUBYEXT): $(LIBUPB_PIC) upb/bindings/ruby/upb.c upb/bindings/ruby/Makefile
+$(RUBYEXT): upb/bindings/ruby/upb.c upb/bindings/ruby/Makefile
$(E) CC upb/bindings/ruby/upb.c
$(Q) cd upb/bindings/ruby && make
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback