Makefile.am 13 KB

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