-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
173 lines (131 loc) · 5.65 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
161
162
163
164
165
166
167
168
169
170
171
172
173
###############################################################################
#
# BSD 2-Clause License
#
# Copyright (c) 2024, Danil Borchevkin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
# *****************************************************************************
# * INCLUDES
# *****************************************************************************
# TODO add includes if needed
# *****************************************************************************
# * FUNCTIONS
# *****************************************************************************
# TODO add functions here
# *****************************************************************************
# * VARIABLES
# *****************************************************************************
SHELL := /bin/bash
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
THREADS_NUM = $(shell nproc)
BUILD_OPTS_RELEASE = -j${THREADS_NUM}
BUILD_OPTS_DEBUG = -j1
INC=-I${ROOT_DIR}/inc
# *****************************************************************************
# * TARGETS - MANDATORY
# *****************************************************************************
# Init repository / project
.PHONY: init
init: clean
mkdir -p ${ROOT_DIR}/artifacts/build/debug
mkdir -p ${ROOT_DIR}/artifacts/build/release
mkdir -p ${ROOT_DIR}/artifacts/reports/check_style
mkdir -p ${ROOT_DIR}/artifacts/reports/check_static
mkdir -p ${ROOT_DIR}/artifacts/reports/check_security
mkdir -p ${ROOT_DIR}/artifacts/reports/test_unit
mkdir -p ${ROOT_DIR}/artifacts/reports/test_integration
mkdir -p ${ROOT_DIR}/artifacts/reports/test_e2e
# Clean
.PHONY: clean
clean:
rm -rf ${ROOT_DIR}/artifacts
# Apply codestyle to all codebase
.PHONY: apply_style
apply_style:
$(error Target not implemented)
# Check codestyle and return error if ther ere some violence,
# generate a report into ./artifacts/reports/check_style/
.PHONY: check_style
check_style:
$(error Target not implemented)
# Run static analyzers, generate an analyze report into ./artifacts/reports/check_static/
.PHONY: check_static
check_static:
$(error Target not implemented)
# Run security analyzers, generate an analyze report into ./artifacts/reports/check_security/
.PHONY: check_security
check_security:
$(error Target not implemented)
# Build project in debug configuration
.PHONY: build_debug
build_debug:
gcc $(INC) -o ${ROOT_DIR}/artifacts/srvc_server ${ROOT_DIR}/src/srvc_server.c ${ROOT_DIR}/src/server.c
gcc $(INC) -o ${ROOT_DIR}/artifacts/srvc_client ${ROOT_DIR}/src/srvc_client.c ${ROOT_DIR}/src/client.c
gcc ${INC} -o ${ROOT_DIR}/artifacts/srvc_controller ${ROOT_DIR}/src/srvc_controller.c ${ROOT_DIR}/src/client.c
# Build project in release configuraiton
.PHONY: build_release
build_release:
cmake -S ${ROOT_DIR} -B ${ROOT_DIR}/artifacts/build/release
cmake --build ${ROOT_DIR}/artifacts/build/release
# Run unit tests, generate a test report and a gcov report into ./artifacts/reports/test_unit/
.PHONY: test_unit
test_unit: build_debug
cd ${ROOT_DIR}/artifacts/build/debug && ctest --output-on-failure
# Run integration testing and generate artifacts into ./artifacts/reports/test_integration/
.PHONY: test_integration
test_integration: build_debug
cd ${ROOT_DIR}/artifacts/build/debug && ctest --output-on-failure
# Test E2E and generate artifacts into ./artifacts/reports/test_e2e/
.PHONY: test_e2e
test_e2e: build_debug
$(error Target not implemented)
# Build docs and generate a docs bundle into ./artifacts/docs
.PHONY: docs_build
docs_buld:
$(error Target not implemented)
# Run debug workflow
.PHONY: all_debug
all_debug:
init build_debug
# Run release workflow
.PHONY: all_release
all_release:
init check_style check_static check_security build_release
test_unit test_integration docs_build
# *****************************************************************************
# * TARGETS - PROJECT-SPECIFIC
# *****************************************************************************
.PHONY: run_server
run_server: build_debug
${ROOT_DIR}/artifacts/srvc_server
.PHONY: run_controller
run_controller: build_debug
${ROOT_DIR}/artifacts/srvc_controller localhost 8888
.PHONY: run_client
run_client: build_debug
${ROOT_DIR}/artifacts/srvc_client localhost 8888
# *****************************************************************************
# * END OF MAKEFILE
# *****************************************************************************