|
| 1 | +# This Makefile ties together the steps required to install C++ and |
| 2 | +# Python dependencies. It only works on Linux, but can serve as |
| 3 | +# self-documenting instructions for building on Windows. |
| 4 | +# As such, they are ordered roughly in chronological order. |
| 5 | + |
| 6 | +# Commands with a preceding '@' are for the purposes of make only, |
| 7 | +# there is no need to reproduce then on Windows. |
| 8 | + |
| 9 | +PROTOC=build/protoc |
| 10 | +PROTOS_DIR=src/protos |
| 11 | +GRPC_CPP_PLUGIN_PATH=build/grpc_cpp_plugin |
| 12 | +VENV_ACTIVATE=venv/bin/activate |
| 13 | + |
| 14 | +SHELL := /bin/bash |
| 15 | + |
| 16 | +UNCONSTRAINED_RESULT_FILES= results/sync.csv results/threaded_client.csv |
| 17 | +CONSTRAINED_RESULT_FILES= results/rate_100mbit.csv results/delay_1ms.csv results/compressionlevel_3_rate_100mbit.csv |
| 18 | + |
| 19 | +all: compile_project $(UNCONSTRAINED_RESULT_FILES) $(CONSTRAINED_RESULT_FILES) |
| 20 | + |
| 21 | +venv/bin/activate: |
| 22 | + @echo "### Creating Python virtual environment ###" |
| 23 | + python3 -m venv venv |
| 24 | + |
| 25 | +venv/.done: requirements.txt venv/bin/activate |
| 26 | + @echo "### Installing Python dependencies ###" |
| 27 | + . $(VENV_ACTIVATE) && \ |
| 28 | + pip install -U pip && \ |
| 29 | + pip install -r requirements.txt && \ |
| 30 | + conan profile new --detect --force grpc_cpp_benchmark && \ |
| 31 | + conan profile update settings.compiler.libcxx=libstdc++11 grpc_cpp_benchmark && \ |
| 32 | + conan remote add -f conancenter https://center.conan.io |
| 33 | + @touch $@ |
| 34 | + |
| 35 | +RENDERED_TEMPLATE_FILES= src/protos/send_array.proto src/common/types_lookup.hpp src/client/sync_client.cpp src/server/sync_server.cpp src/client/sync_client_fixed_chunksize.cpp |
| 36 | + |
| 37 | +$(RENDERED_TEMPLATE_FILES): % : render_templates.py venv/.done %.in |
| 38 | + @echo "### Rendering input file from template ###" |
| 39 | + . $(VENV_ACTIVATE) && python $< $@.in $@ |
| 40 | + |
| 41 | +build/.deps_done: conanfile.txt venv/.done |
| 42 | + @echo "### Installing C++ dependencies ###" |
| 43 | + mkdir -p build |
| 44 | + . $(VENV_ACTIVATE) && conan install -if build --build=* --profile=grpc_cpp_benchmark . |
| 45 | + @touch $@ |
| 46 | + |
| 47 | +generated_src/.generate_done: src/protos/send_array.proto build/.deps_done |
| 48 | + @echo "### Compiling .proto file to C++ source ###" |
| 49 | + $(PROTOC) --proto_path=$(PROTOS_DIR) --cpp_out=generated_src --grpc_out=generated_src --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) send_array.proto |
| 50 | + @touch $@ |
| 51 | + |
| 52 | +BIN_OUTPUT_FILES= build/bin/measure_memcpy build/bin/sync_client build/bin/sync_client_fixed_chunksize build/bin/sync_server |
| 53 | + |
| 54 | +$(BIN_OUTPUT_FILES): compile_project; |
| 55 | + |
| 56 | +compile_project: build/.deps_done generated_src/.generate_done $(RENDERED_TEMPLATE_FILES) CMakeLists.txt **/CMakeLists.txt |
| 57 | + @echo "### Setting up CMake ###" |
| 58 | + cd build && cmake .. |
| 59 | + @echo "### Compiling the C++ source ###" |
| 60 | + $(MAKE) -C build |
| 61 | + |
| 62 | +$(UNCONSTRAINED_RESULT_FILES): run_unconstrained_measurements; |
| 63 | +run_unconstrained_measurements: runner/run_measurements.py build/bin/sync_client build/bin/sync_server |
| 64 | + @echo "### Running unconstrained measurements ###" |
| 65 | + . $(VENV_ACTIVATE) && python $< |
| 66 | + |
| 67 | + |
| 68 | +$(CONSTRAINED_RESULT_FILES): runner/run_constrained.py build/bin/sync_client_fixed_chunksize build/bin/sync_server |
| 69 | + @echo "### Running constrained measurements ###" |
| 70 | + . $(VENV_ACTIVATE) && python $< $@ |
| 71 | + |
| 72 | +results/memcpy.csv: build/bin/measure_memcpy |
| 73 | + build/bin/measure_memcpy > $@ |
| 74 | + |
| 75 | +clean: |
| 76 | + rm -rf venv |
| 77 | + rm -rf build |
| 78 | + rm -rf generated_src/*.cc |
| 79 | + rm -rf generated_src/*.h |
| 80 | + rm -rf **/.*done |
| 81 | + rm -f src/protos/*.proto |
| 82 | + rm -f src/types_lookup.hpp |
| 83 | + rm -f results/*.csv |
| 84 | + |
| 85 | +.PHONY: clean compile_project all run_constrained_measurements |
0 commit comments