forked from hydro-project/anna
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
160 lines (138 loc) · 5.87 KB
/
Makefile
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
APTGET := $(shell command -v apt-get 2> /dev/null)
BREW := $(shell command -v brew 2> /dev/null)
DNF := $(shell command -v dnf 2> /dev/null)
YUM := $(shell command -v yum 2> /dev/null)
CLANG := $(shell command -v clang 2> /dev/null)
MDBOOK := $(shell command -v mdbook 2> /dev/null)
GRCOV := $(shell command -v grcov 2> /dev/null)
all: clean-start clippy build test coverage docs cleanup
@echo "SUCCESS!!"
.PHONY: clean-start
clean-start:
@find . -name "*.profraw" | xargs rm -f
# Dependencies not installed
# clang on mac
# make
# rust toolchain
# python tooling
.PHONY: dependencies
dependencies: clang
@echo "Installing build-tools"
ifneq ($(BREW),)
brew install autoconf automake libtool pkg-config cmake protobuf curl lcov zmq cppzmq spdlog yaml-cpp googletest llvm
endif
ifneq ($(APTGET),)
sudo apt-get -y install build-essential autoconf automake libtool curl unzip pkg-config cmake libc++-dev libc++abi-dev protobuf-compiler lcov llvm libzmq3-dev
endif
ifneq ($(YUM),)
sudo yum install -y build-essential autoconf automake libtool curl cmake protobuf-compiler lcov llvm zeromq zeromq-devel
endif
cargo install mdbook
cargo install mdbook-linkcheck
cargo install grcov
rustup component add llvm-tools-preview
# Skipping installing Python pre-requisites for now
# sudo apt-get install -y python3-pip
# brew install python
# sudo pip3 install pycodestyle coverage codecov
# awscli jq
.PHONY: rustup
rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
@. ${HOME}/.cargo/env
.PHONY: clang
clang:
ifeq ($(CLANG),)
@echo "Installing clang"
ifneq ($(BREW),)
# Leave mac Xcode clang install to the user
endif
ifneq ($(APTGET),)
echo "Installing clang..."
#sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main"
sudo apt-get install -y --allow-unauthenticated clang clang++ lldb clang-format
endif
endif
.PHONY: clean
clean: cleanup
@echo "Deleting all build artifacts"
@rm -rf clients/cpp/build
@rm -rf server/cpp/build
@rm -rf build
@cargo --quiet clean
@rm -f clients/python/anna/*_pb2.py
@rm -rf coverage
.PHONY: clippy
clippy:
@echo "Running 'clippy' on rust code"
@cargo clippy --quiet --tests # -- -D warnings # for now, don't fail on warnings
# Debug build, use "-DCMAKE_BUILD_TYPE=Release" for a Release build
.PHONY: build
build: client-cpp server-cpp client-rust client-python
.PHONY: client-cpp
client-cpp:
@mkdir -p clients/cpp/build
@echo "Building client C++ project into ./clients/cpp/build"
@LD_LIBRARY_PATH="/usr/local/lib" cd clients/cpp/build && cmake "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER="/usr/bin/clang++" -DBUILD_TEST=ON .. 2>&1 > /dev/null && make -s -j8 2>&1 > /dev/null
.PHONY: server-cpp
server-cpp:
@mkdir -p server/cpp/build
@echo "Building server C++ project into ./server/cpp/build"
@LD_LIBRARY_PATH="/usr/local/lib" cd server/cpp/build && cmake "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER="/usr/bin/clang++" -DBUILD_TEST=ON .. 2>&1 > /dev/null && make -s -j8 2>&1 > /dev/null
.PHONY: client-rust
client-rust:
@echo "Building rust code in workspace into ./target"
@cargo build --quiet
.PHONY: client-python
client-python:
@echo "Compiling python client"
@cd clients/python/anna && protoc -I=../../../server/protobuf/ --python_out=. kvs.proto shared.proto causal.proto
.PHONY: coverage
coverage: test
@echo "Generating coverage report in ./coverage/index.html"
@genhtml -o coverage --quiet rust_workspace.info server/cpp/build/server.info #clients/cpp/build/client.info
# TODO add back in client.info coverage data for cpp client
.PHONY: test
test: server-cpp-tests client-cpp-tests workspace-rust-tests
.PHONY: server-cpp-tests
server-cpp-tests:
@echo "Running C++ server tests with coverage"
@cd server/cpp/build && make --no-print-directory -s server-test-coverage
@find server/cpp -name "*.profraw" | xargs rm -f
.PHONY: client-cpp-tests
client-cpp-tests:
@echo "Running C++ client tests with coverage"
@cd clients/cpp/build && make --no-print-directory -s client-test-coverage
#@find clients/cpp -name "*.profraw" | xargs rm -f #none generated at the moment!! :-(
.PHONY: workspace-rust-tests
workspace-rust-tests:
@echo "Running rust tests with coverage"
@RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="anna-%p-%m.profraw" cargo --quiet test
@echo "Gathering covering information"
@grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o rust_workspace.info
@lcov --remove rust_workspace.info '/Applications/*' '/usr*' '*/build/*' '**/build.rs' '*/cpp/hash_ring/*' '*/cpp/zmq/*' '**/errors.rs' '**/*.pb.*' '*tests/*' '*/protobuf/*' -o rust_workspace.info
@find clients/rust -name "*.profraw" | xargs rm -f # .profraw files from execution of rust client
@find . -name "*.profraw" | xargs rm -f # .profraw files from execution of cpp client & server via rust test execution
.PHONY: docs
docs:
@echo "Generating docs with cargo doc"
@cargo doc --quiet --no-deps --target-dir=target/html/code 2>&1 > /dev/null
@echo "Generating book with mdbook"
@mdbook build > /dev/null 2>&1
@rm -f target/html/*.profraw target/html/client_log.txt target/html/log.txt target/html/log_0.txt target/html/*.info
@rm -f target/html/Makefile
@rm -f target/html/LICENSE target/html/Cargo.toml target/html/Cargo.lock target/html/CMakeLists.txt
@rm -rf target/html/build target/html/conf target/html/dockerfiles
@rm -rf target/html/src target/html/tests target/html/protobuf
@rm -rf target/html/cli target/html/clients target/html/server
@rm -rf target/html/coverage target/html/venv
@echo "Cleaned up extra files in docs folder"
.PHONY: cleanup
cleanup: test-cleanup coverage-cleanup
@echo "Cleaned up files left over from build and test"
.PHONY: test-cleanup
test-cleanup:
@rm -f log.txt log_0.txt pids client_log.txt
.PHONY: coverage-cleanup
coverage-cleanup:
@rm -f rust_workspace.info server/cpp/build/server.info clients/cpp/build/client.info