1
1
# Makefile
2
+ #
2
3
# This file contains Makefile targets for the cloe project.
3
4
#
4
5
5
- # Make configuration:
6
- SHELL := /bin/bash
7
- GNUMAKEFLAGS := --no-print-directory
8
-
9
6
# Set the clang-format command line to use:
10
7
CLANG_FORMAT := $(shell command -v clang-format 2>/dev/null)
11
8
CLANG_FORMAT_ARGS := -style=file
@@ -16,201 +13,84 @@ AG := $(or \
16
13
"grep -r" \
17
14
)
18
15
16
+ define print_header
17
+ @printf "________________________________________"
18
+ @printf "________________________________________\n"
19
+ @printf ":: %s\n" ${1}
20
+ endef
21
+
19
22
CLOE_ROOT := .
20
23
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
21
24
22
25
# Build configuration:
23
- SOURCE_DIR := .
24
- BUILD_DIR := build
25
- INSTALL_DIR := /usr/local
26
-
27
- # These packages can all be built in parallel:
28
- PACKAGES := engine $(wildcard plugins/* )
29
-
30
- # This variable contains packages that should not be built.
31
- # This should only be provided from the command line, for example:
32
- # make NOBUILD_PKGS="plugins/vtd plugins/demo_printer" package
33
- NOBUILD_PKGS :=
34
-
35
- # These options are passed to conan when it is working with the cloe metapackage.
26
+ BUILD_DIR := build
27
+ INSTALL_DIR := /usr/local
36
28
CONAN_OPTIONS :=
37
29
38
- # Options:
39
- BUILD_TESTS := 1
40
- ifeq (${BUILD_TESTS},0)
41
- CONAN_OPTIONS += -o cloe:test=False
42
- CONAN_OPTIONS += -o fable:test=False
43
- CONAN_OPTIONS += -o cloe-runtime:test=False
44
- CONAN_OPTIONS += -o cloe-models:test=False
45
- CONAN_OPTIONS += -o cloe-oak:test=False
46
- ifeq (${WITH_ENGINE},1)
47
- CONAN_OPTIONS += -o cloe-engine:test=False
48
- endif
49
- ifeq (${WITH_VTD},1)
50
- CONAN_OPTIONS += -o cloe-plugin-vtd:test=False
51
- endif
52
- CONAN_OPTIONS += -o cloe-plugin-basic:test=False
53
- endif
54
-
55
- WITH_ENGINE := 1
56
- ifeq (${WITH_ENGINE},0)
57
- PACKAGES := $(filter-out engine, ${PACKAGES})
58
- CONAN_OPTIONS += -o cloe:with_engine=False
59
- endif
60
-
61
- WITH_VTD := 1
62
- ifeq (${WITH_VTD},0)
63
- PACKAGES := $(filter-out plugins/vtd, ${PACKAGES})
64
- CONAN_OPTIONS += -o cloe:with_vtd=False
65
- endif
66
-
67
- # Take NOBUILD_PKGS into account to assemble a final list of
68
- # packages that we shall build (in addition to fable, runtime, and models).
69
- # This can also be provided from the command line.
70
- BUILD_PKGS := $(filter-out ${NOBUILD_PKGS}, ${PACKAGES})
71
-
72
30
.PHONY : help
73
31
.DEFAULT : help
32
+ .SILENT : help
74
33
help ::
75
- @ echo " Usage: make <target>"
76
- @ echo
34
+ echo " Usage: make <target>"
35
+ echo
77
36
78
- # Setup Targets ----------------------------------------------------------------
79
37
include Makefile.setup
38
+ include Makefile.all
80
39
81
- # Build Targets -----------------------------------------------------------------------------
40
+ # Workspace targets -----------------------------------------------------------
41
+ .PHONY : deploy doxygen docker docker-test smoketest
82
42
help ::
83
- @echo " Available workspace build targets:"
84
- @echo " smoketest to run BATS system tests"
85
- @echo " clean to clean all generated artifacts"
86
- @echo " git-clean to clean all extraneous artifacts from repository"
87
- @echo " doc to generate Doxygen documentation"
88
- @echo
89
- @echo " Available Conan build targets:"
90
- @echo " export to export all recipes to Conan cache"
91
- @echo " package to build and package all Cloe Conan packages"
92
- @echo " purge to remove all Cloe Conan packages from cache"
93
- @echo " deploy to install all Cloe Conan packages locally"
94
- @echo " docker to build all Docker images"
95
- @echo
96
- @echo " Available development targets:"
97
- @echo " format to format Cloe source code with clang-format"
98
- @echo " todos to show all TODOs in Cloe source code"
99
- @echo
100
- @echo " Options:"
101
- @echo " BUILD_TESTS=(0|1) to build and run unit tests"
102
- @echo " WITH_ENGINE=(0|1) to build and deploy cloe-engine (default=1)"
103
- @echo " WITH_VTD=(0|1) to build and deploy cloe-plugin-vtd (default=1)"
104
- @echo
105
- @echo " Defines:"
106
- @echo " CONAN_OPTIONS = ${CONAN_OPTIONS} "
107
- @echo " NOBUILD_PKGS = ${NOBUILD_PKGS} "
108
- @echo " SOURCE_DIR = ${SOURCE_DIR} "
109
- @echo " BUILD_DIR = ${BUILD_DIR} "
110
- @echo
111
-
112
- .PHONY : clean clean-all test test-all package package-all deploy purge purge-all export smoketest git-clean docker
113
-
114
- ${BUILD_PKGS} ::
115
- ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed 's/-all//')
116
-
117
- export :
118
- conan export vendor/cpp-netlib cloe/stable
119
- conan export vendor/incbin cloe/stable
120
- conan export vendor/open-simulation-interface cloe/stable
43
+ echo " Available workspace targets:"
44
+ echo " deploy to deploy Cloe to INSTALL_DIR [=${INSTALL_DIR} ]"
45
+ echo " docker to build all Docker images"
46
+ echo " docker-test to build only a single Docker image"
47
+ echo " doxygen to generate Doxygen documentation"
48
+ echo " smoketest to run BATS system tests"
49
+ echo
121
50
122
- smoketest :
123
- @echo ___________________________________________________________________________________
124
- @echo " Running smoketests..."
125
- @${CLOE_LAUNCH} clean -P conanfile.py
126
- @\t ime -f " \nTotal smoketest time (real) = %e sec" bats tests
127
-
128
- doc :
129
- @echo ___________________________________________________________________________________
130
- @echo " Generating Doxygen documentation..."
131
- mkdir -p build/doxygen
132
- doxygen Doxyfile
51
+ deploy :
52
+ $(call print_header, "Deploying binaries to ${INSTALL_DIR}...")
53
+ conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR} /deploy -g deploy .
54
+ mkdir -p ${INSTALL_DIR}
55
+ cp -r ${BUILD_DIR} /deploy/cloe-* /* ${INSTALL_DIR} /
133
56
134
57
docker :
58
+ $(call print_header, "Building all Docker images...")
135
59
${MAKE} -C dist/docker all
136
60
137
61
docker-test :
62
+ $(call print_header, "Building ubuntu-18.04 Docker image...")
138
63
${MAKE} -C dist/docker ubuntu-18.04
139
64
140
- clean-all : ${BUILD_PKGS}
141
-
142
- clean :
143
- @echo ___________________________________________________________________________________
144
- @echo " Cleaning build files..."
145
- rm -rf ${BUILD_DIR}
146
- rm -f compile_commands.json
147
- ${MAKE} -C runtime clean
148
- ${MAKE} -C models clean
149
- ${MAKE} clean-all
150
-
151
- git-clean :
152
- -git clean -xdf -e .gtm
153
-
154
- purge-all : ${BUILD_PKGS}
155
-
156
- purge :
157
- @echo ___________________________________________________________________________________
158
- @echo " Removing Conan packages..."
159
- ${MAKE} -C fable purge
160
- ${MAKE} -C oak purge
161
- ${MAKE} -C runtime purge
162
- ${MAKE} -C models purge
163
- ${MAKE} purge-all
164
-
165
- package-all : ${BUILD_PKGS}
166
-
167
- package :
168
- @echo ___________________________________________________________________________________
169
- @echo " Creating Conan packages..."
170
- conan export fable cloe/develop
171
- conan export oak cloe/develop
172
- ${MAKE} -C runtime package
173
- ${MAKE} -C models package
174
- ${MAKE} package-all
175
- ${MAKE} -f Makefile.package package
176
-
177
- package-outdated-all : ${BUILD_PKGS}
178
-
179
- package-outdated :
180
- @echo ___________________________________________________________________________________
181
- @echo " Creating outdated Conan packages..."
182
- ${MAKE} -C runtime package-outdated
183
- ${MAKE} -C models package-outdated
184
- ${MAKE} package-outdated-all
185
-
186
- test-all : ${BUILD_PKGS}
187
-
188
- test :
189
- @echo ___________________________________________________________________________________
190
- @echo " Running CMake tests..."
191
- ${MAKE} -C runtime test
192
- ${MAKE} -C models test
193
- ${MAKE} test-all
65
+ doxygen :
66
+ $(call print_header, "Generating Doxygen documentation...")
67
+ mkdir -p ${BUILD_DIR} /doxygen
68
+ doxygen Doxyfile
194
69
195
- deploy :
196
- @echo ___________________________________________________________________________________
197
- @echo " Deploying binaries to ${INSTALL_DIR} ..."
198
- conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR} /deploy -g deploy .
199
- mkdir -p ${INSTALL_DIR}
200
- cp -r ${BUILD_DIR} /deploy/cloe-* /* ${INSTALL_DIR} /
70
+ smoketest :
71
+ $(call print_header, "Running smoke tests...")
72
+ @${CLOE_LAUNCH} clean -P conanfile.py
73
+ @\t ime -f " \nTotal smoketest time (real) = %e sec" bats tests
74
+
75
+
76
+ # Development targets ---------------------------------------------------------
77
+ .PHONY : format todos find-missing-eol sanitize-files
78
+ help ::
79
+ echo " Available development targets:"
80
+ echo " format to format Cloe source code with clang-format"
81
+ echo " todos to show all TODOs in Cloe source code"
82
+ echo
83
+
84
+ format :
85
+ find . -type f -not -path ' */\.git/*' -and \( -name ' *.cpp' -o -name ' *.hpp' \) -exec ${CLANG_FORMAT} ${CLANG_FORMAT_ARGS} -i {} \;
201
86
202
- # Development targets -----------------------------------------------------------------------
203
- .PHONY : todos format find-missing-eol sanitize-files
204
87
todos :
205
88
${AG} TODO
206
89
${AG} FIXME
207
90
${AG} XXX
208
91
209
- format :
210
- find . -type f -not -path ' */\.git/* ' -and \( -name ' *.cpp ' -o -name ' *.hpp ' \) -exec ${CLANG_FORMAT} ${CLANG_FORMAT_ARGS} -i {} \;
92
+ find-missing-eol :
93
+ find . -type f -size +0 -exec gawk ' ENDFILE{if ($0 == "") print FILENAME} ' {} \;
211
94
212
95
sanitize-files :
213
96
git grep --cached -Ilz ' ' | while IFS= read -rd ' ' f; do tail -c1 < " $$ f" | read -r _ || echo >> " $$ f" ; done
214
-
215
- find-missing-eol :
216
- find . -type f -size +0 -exec gawk ' ENDFILE{if ($0 == "") print FILENAME}' {} \;
0 commit comments