Makefile.am 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. benchmarks_protoc_inputs_benchmark_wrapper = \
  2. benchmarks.proto
  3. benchmarks_protoc_inputs = \
  4. datasets/google_message1/proto3/benchmark_message1_proto3.proto
  5. benchmarks_protoc_inputs_proto2 = \
  6. datasets/google_message1/proto2/benchmark_message1_proto2.proto \
  7. datasets/google_message2/benchmark_message2.proto \
  8. datasets/google_message3/benchmark_message3.proto \
  9. datasets/google_message3/benchmark_message3_1.proto \
  10. datasets/google_message3/benchmark_message3_2.proto \
  11. datasets/google_message3/benchmark_message3_3.proto \
  12. datasets/google_message3/benchmark_message3_4.proto \
  13. datasets/google_message3/benchmark_message3_5.proto \
  14. datasets/google_message3/benchmark_message3_6.proto \
  15. datasets/google_message3/benchmark_message3_7.proto \
  16. datasets/google_message3/benchmark_message3_8.proto \
  17. datasets/google_message4/benchmark_message4.proto \
  18. datasets/google_message4/benchmark_message4_1.proto \
  19. datasets/google_message4/benchmark_message4_2.proto \
  20. datasets/google_message4/benchmark_message4_3.proto
  21. make_tmp_dir:
  22. mkdir -p 'tmp/java/src/main/java'
  23. touch make_tmp_dir
  24. if USE_EXTERNAL_PROTOC
  25. protoc_middleman: make_tmp_dir $(benchmarks_protoc_inputs)
  26. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=./tmp $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper)
  27. touch protoc_middleman
  28. protoc_middleman2: make_tmp_dir $(benchmarks_protoc_inputs_proto2)
  29. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=./tmp $(benchmarks_protoc_inputs_proto2)
  30. touch protoc_middleman2
  31. else
  32. # We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
  33. # relative to srcdir, which may not be the same as the current directory when
  34. # building out-of-tree.
  35. protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper)
  36. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) )
  37. touch protoc_middleman
  38. protoc_middleman2: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2) $(well_known_type_protoc_inputs)
  39. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2) )
  40. touch protoc_middleman2
  41. endif
  42. all_data = `find . -type f -name "dataset.*.pb"`
  43. ############# CPP RULES ##############
  44. benchmarks_protoc_outputs = \
  45. benchmarks.pb.cc \
  46. datasets/google_message1/proto3/benchmark_message1_proto3.pb.cc
  47. benchmarks_protoc_outputs_header = \
  48. benchmarks.pb.h \
  49. datasets/google_message1/proto3/benchmark_message1_proto3.pb.h
  50. benchmarks_protoc_outputs_proto2_header = \
  51. datasets/google_message1/proto2/benchmark_message1_proto2.pb.h \
  52. datasets/google_message2/benchmark_message2.pb.h \
  53. datasets/google_message3/benchmark_message3.pb.h \
  54. datasets/google_message3/benchmark_message3_1.pb.h \
  55. datasets/google_message3/benchmark_message3_2.pb.h \
  56. datasets/google_message3/benchmark_message3_3.pb.h \
  57. datasets/google_message3/benchmark_message3_4.pb.h \
  58. datasets/google_message3/benchmark_message3_5.pb.h \
  59. datasets/google_message3/benchmark_message3_6.pb.h \
  60. datasets/google_message3/benchmark_message3_7.pb.h \
  61. datasets/google_message3/benchmark_message3_8.pb.h \
  62. datasets/google_message4/benchmark_message4.pb.h \
  63. datasets/google_message4/benchmark_message4_1.pb.h \
  64. datasets/google_message4/benchmark_message4_2.pb.h \
  65. datasets/google_message4/benchmark_message4_3.pb.h
  66. benchmarks_protoc_outputs_proto2 = \
  67. datasets/google_message1/proto2/benchmark_message1_proto2.pb.cc \
  68. datasets/google_message2/benchmark_message2.pb.cc \
  69. datasets/google_message3/benchmark_message3.pb.cc \
  70. datasets/google_message3/benchmark_message3_1.pb.cc \
  71. datasets/google_message3/benchmark_message3_2.pb.cc \
  72. datasets/google_message3/benchmark_message3_3.pb.cc \
  73. datasets/google_message3/benchmark_message3_4.pb.cc \
  74. datasets/google_message3/benchmark_message3_5.pb.cc \
  75. datasets/google_message3/benchmark_message3_6.pb.cc \
  76. datasets/google_message3/benchmark_message3_7.pb.cc \
  77. datasets/google_message3/benchmark_message3_8.pb.cc \
  78. datasets/google_message4/benchmark_message4.pb.cc \
  79. datasets/google_message4/benchmark_message4_1.pb.cc \
  80. datasets/google_message4/benchmark_message4_2.pb.cc \
  81. datasets/google_message4/benchmark_message4_3.pb.cc
  82. $(benchmarks_protoc_outputs): protoc_middleman
  83. $(benchmarks_protoc_outputs_header): protoc_middleman
  84. $(benchmarks_protoc_outputs_proto2): protoc_middleman2
  85. $(benchmarks_protoc_outputs_proto2_header): protoc_middleman2
  86. initialize_submodule:
  87. oldpwd=`pwd`
  88. cd $(top_srcdir)/third_party
  89. git submodule update --init -r
  90. cd $(top_srcdir)/third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make
  91. cd $$oldpwd
  92. touch initialize_submodule
  93. $(top_srcdir)/src/libprotobuf.la: initialize_submodule
  94. $(top_srcdir)/third_party/benchmark/src/libbenchmark.a: initialize_submodule
  95. AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
  96. bin_PROGRAMS = cpp-benchmark
  97. cpp_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
  98. cpp_benchmark_SOURCES = cpp_benchmark.cc
  99. cpp_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) -I$(top_srcdir)/third_party/benchmark/include
  100. # Explicit deps because BUILT_SOURCES are only done before a "make all/check"
  101. # so a direct "make test_cpp" could fail if parallel enough.
  102. # See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
  103. cpp_benchmark-cpp_benchmark.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
  104. nodist_cpp_benchmark_SOURCES = \
  105. $(benchmarks_protoc_outputs) \
  106. $(benchmarks_protoc_outputs_proto2) \
  107. $(benchmarks_protoc_outputs_proto2_header) \
  108. $(benchmarks_protoc_outputs_header)
  109. cpp: protoc_middleman protoc_middleman2 cpp-benchmark initialize_submodule
  110. ./cpp-benchmark $(all_data)
  111. ############ CPP RULES END ############
  112. ############# JAVA RULES ##############
  113. java_benchmark_testing_files = \
  114. java/src/main/java/com/google/protobuf/ProtoBench.java \
  115. java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
  116. javac_middleman: $(java_benchmark_testing_files) protoc_middleman protoc_middleman2
  117. cp -r java tmp && cd tmp/java && mvn clean compile assembly:single
  118. cd ../..
  119. @touch javac_middleman
  120. java-benchmark: javac_middleman
  121. @echo "Writing shortcut script java-benchmark..."
  122. @echo '#! /bin/sh' > java-benchmark
  123. @echo 'java -cp '"tmp/java/target/*.jar"' com.google.protobuf.ProtoBench $$@' >> java-benchmark
  124. @chmod +x java-benchmark
  125. java: protoc_middleman protoc_middleman2 java-benchmark
  126. ./java-benchmark $(all_data)
  127. ############# JAVA RULES END ##############
  128. ############# PYTHON RULES ##############
  129. python_add_init: protoc_middleman protoc_middleman2
  130. all_file=`find tmp -type f -regex '.*\.py'` && \
  131. for file in $${all_file[@]}; do \
  132. path="$${file%/*}"; \
  133. while true; do \
  134. touch "$$path/__init__.py" && chmod +x "$$path/__init__.py"; \
  135. if [[ $$path != *"/"* ]]; then break; fi; \
  136. path=$${path%/*}; \
  137. done \
  138. done
  139. python_cpp_pkg_flags = `pkg-config --cflags --libs python`
  140. lib_LTLIBRARIES = libbenchmark_messages.la
  141. libbenchmark_messages_la_SOURCES = python_benchmark_messages.cc
  142. libbenchmark_messages_la_LIBADD = $(top_srcdir)/src/.libs/libprotobuf.la
  143. libbenchmark_messages_la_LDFLAGS = -version-info 1:0:0 -export-dynamic
  144. libbenchmark_messages_la_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) $(python_cpp_pkg_flags)
  145. libbenchmark_messages_la-libbenchmark_messages_la.$(OBJEXT): $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2)
  146. nodist_libbenchmark_messages_la_SOURCES = \
  147. $(benchmarks_protoc_outputs) \
  148. $(benchmarks_protoc_outputs_proto2) \
  149. $(benchmarks_protoc_outputs_proto2_header) \
  150. $(benchmarks_protoc_outputs_header)
  151. python-pure-python-benchmark: python_add_init
  152. @echo "Writing shortcut script python-pure-python-benchmark..."
  153. @echo '#! /bin/sh' > python-pure-python-benchmark
  154. @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-pure-python-benchmark
  155. @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-pure-python-benchmark
  156. @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'python\' >> python-pure-python-benchmark
  157. @echo cp py_benchmark.py tmp >> python-pure-python-benchmark
  158. @echo python tmp/py_benchmark.py false '$$@' >> python-pure-python-benchmark
  159. @chmod +x python-pure-python-benchmark
  160. python-cpp-reflection-benchmark: python_add_init
  161. @echo "Writing shortcut script python-cpp-reflection-benchmark..."
  162. @echo '#! /bin/sh' > python-cpp-reflection-benchmark
  163. @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-cpp-reflection-benchmark
  164. @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-cpp-reflection-benchmark
  165. @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-reflection-benchmark
  166. @echo cp py_benchmark.py tmp >> python-cpp-reflection-benchmark
  167. @echo python tmp/py_benchmark.py false '$$@' >> python-cpp-reflection-benchmark
  168. @chmod +x python-cpp-reflection-benchmark
  169. python-cpp-generated-code-benchmark: python_add_init libbenchmark_messages.la
  170. @echo "Writing shortcut script python-cpp-generated-code-benchmark..."
  171. @echo '#! /bin/sh' > python-cpp-generated-code-benchmark
  172. @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-cpp-generated-code-benchmark
  173. @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/libprotobuf.la >> python-cpp-generated-code-benchmark
  174. @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-generated-code-benchmark
  175. @echo cp py_benchmark.py tmp >> python-cpp-generated-code-benchmark
  176. @echo python tmp/py_benchmark.py true '$$@' >> python-cpp-generated-code-benchmark
  177. @chmod +x python-cpp-generated-code-benchmark
  178. python-pure-python: python-pure-python-benchmark
  179. ./python-pure-python-benchmark $(all_data)
  180. python-cpp-reflection: python-cpp-reflection-benchmark
  181. ./python-cpp-reflection-benchmark $(all_data)
  182. python-cpp-generated-code: python-cpp-generated-code-benchmark
  183. ./python-cpp-generated-code-benchmark $(all_data)
  184. ############# PYTHON RULES END ##############
  185. ############# GO RULES BEGIN ##############
  186. benchmarks_protoc_inputs_proto2_message1 = \
  187. datasets/google_message1/proto2/benchmark_message1_proto2.proto
  188. benchmarks_protoc_inputs_proto2_message2 = \
  189. datasets/google_message2/benchmark_message2.proto
  190. benchmarks_protoc_inputs_proto2_message3 = \
  191. datasets/google_message3/benchmark_message3.proto \
  192. datasets/google_message3/benchmark_message3_1.proto \
  193. datasets/google_message3/benchmark_message3_2.proto \
  194. datasets/google_message3/benchmark_message3_3.proto \
  195. datasets/google_message3/benchmark_message3_4.proto \
  196. datasets/google_message3/benchmark_message3_5.proto \
  197. datasets/google_message3/benchmark_message3_6.proto \
  198. datasets/google_message3/benchmark_message3_7.proto \
  199. datasets/google_message3/benchmark_message3_8.proto
  200. benchmarks_protoc_inputs_proto2_message4 = \
  201. datasets/google_message4/benchmark_message4.proto \
  202. datasets/google_message4/benchmark_message4_1.proto \
  203. datasets/google_message4/benchmark_message4_2.proto \
  204. datasets/google_message4/benchmark_message4_3.proto
  205. if USE_EXTERNAL_PROTOC
  206. go_protoc_middleman: make_tmp_dir $(benchmarks_protoc_inputs)
  207. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs)
  208. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_benchmark_wrapper)
  209. touch protoc_middleman
  210. go_protoc_middleman2: make_tmp_dir $(benchmarks_protoc_inputs_proto2_message1) $(benchmarks_protoc_inputs_proto2_message2) $(benchmarks_protoc_inputs_proto2_message3) $(benchmarks_protoc_inputs_proto2_message4)
  211. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message1)
  212. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message2)
  213. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message3)
  214. $(PROTOC) -I$(srcdir) -I$(top_srcdir) --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message4)
  215. touch protoc_middleman2
  216. else
  217. # We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
  218. # relative to srcdir, which may not be the same as the current directory when
  219. # building out-of-tree.
  220. go_protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs)
  221. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) )
  222. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_benchmark_wrapper) )
  223. touch protoc_middleman
  224. go_protoc_middleman2: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2_message1) $(benchmarks_protoc_inputs_proto2_message2) $(benchmarks_protoc_inputs_proto2_message3) $(benchmarks_protoc_inputs_proto2_message4) $(well_known_type_protoc_inputs)
  225. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message1) )
  226. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message2) )
  227. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message3) )
  228. oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message4) )
  229. touch protoc_middleman2
  230. endif
  231. go-benchmark: go_protoc_middleman go_protoc_middleman2
  232. @echo "Writing shortcut script go-benchmark..."
  233. @echo '#! /bin/sh' > go-benchmark
  234. @echo 'mkdir tmp_cc && mv *.cc tmp_cc' >> go-benchmark
  235. @echo 'go test -bench=. -- $$@' >> go-benchmark
  236. @echo 'mv tmp_cc/* . && rm -rf tmp_cc' >> go-benchmark
  237. @chmod +x go-benchmark
  238. go: go_protoc_middleman go_protoc_middleman2 go-benchmark
  239. ./go-benchmark $(all_data)
  240. ############# GO RULES END ##############
  241. MAINTAINERCLEANFILES = \
  242. Makefile.in
  243. CLEANFILES = \
  244. $(benchmarks_protoc_outputs) \
  245. $(benchmarks_protoc_outputs_header) \
  246. $(benchmarks_protoc_outputs_proto2) \
  247. $(benchmarks_protoc_outputs_proto2_header) \
  248. initialize_submodule \
  249. make_tmp_dir \
  250. protoc_middleman \
  251. protoc_middleman2 \
  252. javac_middleman \
  253. java-benchmark \
  254. python_cpp_proto_library \
  255. python-pure-python-benchmark \
  256. python-cpp-reflection-benchmark \
  257. python-cpp-generated-code-benchmark \
  258. go-benchmark \
  259. go_protoc_middleman \
  260. go_protoc_middleman2
  261. clean-local:
  262. -rm -rf tmp/*