Skip to content

Commit cd20202

Browse files
committed
tooling: Simplify Makefiles and make them more user-friendly
1 parent eabb9da commit cd20202

File tree

22 files changed

+357
-412
lines changed

22 files changed

+357
-412
lines changed

Makefile

+31-28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# This file contains Makefile targets for the cloe project.
44
#
55

6+
CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
7+
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
8+
9+
include ${CLOE_ROOT}/Makefile.help
10+
611
# Set the clang-format command line to use:
712
CLANG_FORMAT := $(shell command -v clang-format 2>/dev/null)
813
CLANG_FORMAT_ARGS := -style=file
@@ -13,15 +18,6 @@ AG := $(or \
1318
"grep -r" \
1419
)
1520

16-
define print_header
17-
@printf "________________________________________"
18-
@printf "________________________________________\n"
19-
@printf ":: %s\n" ${1}
20-
endef
21-
22-
CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
23-
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
24-
2521
# Build configuration:
2622
BUILD_DIR := build
2723
LOCKFILE_SOURCE := conanfile.py
@@ -34,26 +30,28 @@ CONAN_OPTIONS :=
3430
.DEFAULT: help
3531
.SILENT: help
3632
help::
37-
echo "Usage: make <target>"
33+
$(call print_help_usage)
3834
echo
3935

36+
# Setup targets ---------------------------------------------------------------
4037
include Makefile.setup
41-
include Makefile.all
4238

4339
# Workspace targets -----------------------------------------------------------
4440
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all export-cli smoketest smoketest-deps
4541
help::
46-
echo "Available workspace targets:"
47-
echo " smoketest to run BATS system tests"
48-
echo " sphinx to generate Sphinx documentation"
49-
echo " doxygen to generate Doxygen documentation"
50-
echo " deploy to deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]"
51-
echo " deploy-cli to install cloe-launch with pip"
52-
echo " export-cli to export cloe-launch-profile conan recipe"
42+
$(call print_help_section, "Available workspace targets")
43+
$(call print_help_target, status, "show status of each of the Conan packages")
44+
$(call print_help_target, smoketest-deps, "build system test pre-requisites")
45+
$(call print_help_target, smoketest, "run system tests")
46+
$(call print_help_target, sphinx, "generate Sphinx documentation")
47+
$(call print_help_target, doxygen, "generate Doxygen documentation")
48+
$(call print_help_target, deploy, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]")
49+
$(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}")
50+
$(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe")
5351
echo
54-
echo " docker-test to build only a single Docker image"
55-
echo " docker-all to build all Docker images"
56-
echo " docker-release to upload all Conan packages from Docker images"
52+
$(call print_help_target, docker-test, "build only a single Docker image")
53+
$(call print_help_target, docker-all, "build all Docker images")
54+
$(call print_help_target, docker-release, "upload all Conan packages from Docker images")
5755
echo
5856

5957
${BUILD_LOCKFILE}:
@@ -97,16 +95,14 @@ sphinx:
9795
mkdir -p ${BUILD_DIR}/sphinx
9896
${MAKE} -C docs html
9997

100-
doxygen:
98+
doxygen:keyboard tilt
10199
$(call print_header, "Generating Doxygen documentation...")
102100
mkdir -p ${BUILD_DIR}/doxygen
103101
doxygen Doxyfile
104102

105103
smoketest-deps: export-cli smoketest-deps-select
106-
# Call this target with WITH_VTD=1 to include VTD binding tests.
107104

108105
smoketest: smoketest-select
109-
# Call this target with WITH_VTD=1 to include VTD binding tests.
110106

111107
purge-all:
112108
$(call print_header, "Removing all cloe Conan packages...")
@@ -117,13 +113,17 @@ purge-all:
117113
# Development targets ---------------------------------------------------------
118114
.PHONY: format todos find-missing-eol sanitize-files
119115
help::
120-
echo "Available development targets:"
121-
echo " status to show current workspace status"
122-
echo " format to format Cloe source code with clang-format"
123-
echo " todos to show all TODOs in Cloe source code"
116+
$(call print_help_section, "Available development targets")
117+
$(call print_help_target, format, "format Cloe source code with clang-format")
118+
$(call print_help_target, todos, "show all TODOs in Cloe source code")
124119
echo
125120

126121
format:
122+
# When you do this, isolate the change in a single commit and then add the
123+
# commit hash to a file such as .git-blame-ignore-revs, so that git-blame
124+
# continues to work as expected.
125+
#
126+
# See: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
127127
find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec ${CLANG_FORMAT} ${CLANG_FORMAT_ARGS} -i {} \;
128128

129129
todos:
@@ -139,3 +139,6 @@ find-missing-eol:
139139

140140
sanitize-files:
141141
git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done
142+
143+
# Build targets ---------------------------------------------------------------
144+
include Makefile.all

0 commit comments

Comments
 (0)