-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
182 lines (147 loc) · 5.8 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
174
175
176
177
178
179
180
181
182
# Makefile
#
# This file contains Makefile targets for the cloe project.
#
# Make configuration:
SHELL := /bin/bash
GNUMAKEFLAGS := --no-print-directory
SUBMAKEFLAGS :=
CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
CLOE_LAUNCH := PYTHONPATH="$(CLOE_ROOT)/cli" python3 -m cloe_launch
include $(CLOE_ROOT)/Makefile.help
# Set the clang-format command line to use:
CLANG_FORMAT := $(shell command -v clang-format 2>/dev/null)
CLANG_FORMAT_ARGS := -style=file
AG := $(or \
$(shell command -v rg 2>/dev/null), \
$(shell command -v ag 2>/dev/null), \
"grep -r" \
)
# Build configuration:
BUILD_DIR := build
INSTALL_DIR := /usr/local
DEPLOY_DIR := deploy
CONAN_OPTIONS :=
# Lockfile for cloe-deployment:
DEPLOY_LOCKFILE_SOURCE := tests/conanfile_deployment.py
DEPLOY_BUILD_LOCKFILE := $(DEPLOY_DIR)/conan.lock
DEPLOY_LOCKFILE_OPTION := --lockfile="$(CLOE_ROOT)/$(DEPLOY_BUILD_LOCKFILE)"
.DEFAULT_GOAL := help
.PHONY: help
.SILENT: help
help::
$(call print_help_usage)
echo
$(call print_help_section, "Default target")
$(call print_help_target, help, "show this help on available targets")
echo
# Setup targets ---------------------------------------------------------------
include Makefile.setup
$(DEPLOY_BUILD_LOCKFILE):
mkdir -p "$(DEPLOY_DIR)"
conan lock create --lockfile-out "$(DEPLOY_BUILD_LOCKFILE)" --build -- "$(DEPLOY_LOCKFILE_SOURCE)"
.PHONY: lockfile
lockfile: $(DEPLOY_BUILD_LOCKFILE)
# Workspace targets -----------------------------------------------------------
help::
$(call print_help_section, "Available workspace targets")
$(call print_help_target, docs, "generate Doxygen and Sphinx documentation")
echo
.PHONY: docs
docs:
$(call print_header, "Generating Doxygen documentation...")
$(MAKE) -C docs doxygen
$(call print_header, "Generating Sphinx documentation...")
$(MAKE) -C docs html
help::
$(call print_help_target, export-cli, "export $(_yel)cloe-launch-profile$(_rst) Conan recipe")
$(call print_help_target, deploy-cli, "install $(_yel)cloe-launch$(_rst) with $(_dim)$(PIPX)$(_rst)")
echo
.PHONY: export-cli
export-cli:
$(MAKE) -C cli export
.PHONY: deploy-cli
deploy-cli:
$(call print_header, "Deploying cloe-launch binary with pip...")
$(MAKE) -C cli install
help::
$(call print_help_target, lockfile, "create a lockfile for cloe deployment packages")
$(call print_help_target, package-all, "package all cloe deployment packages")
$(call print_help_target, status-all, "show status of each of the Conan packages")
$(call print_help_target, export-all, "export all package sources to Conan cache")
$(call print_help_target, build-all, "build individual packages locally in-source")
$(call print_help_target, deploy-all, "deploy $(_yel)cloe$(_rst) to $(_grn)INSTALL_DIR$(_rst)=$(_dim)$(INSTALL_DIR)$(_rst)")
$(call print_help_target, clean-all, "clean entire repository of temporary files")
$(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache")
echo
.PHONY: build-all
build-all: lockfile
$(MAKE) all-select CONAN_OPTIONS="$(CONAN_OPTIONS) $(DEPLOY_LOCKFILE_OPTION)"
.PHONY: status-all
status-all: $(DEPLOY_BUILD_LOCKFILE)
@for pkg in $(ALL_PKGS); do \
$(MAKE) LOCKFILE_SOURCE="" LOCKFILE_OPTION=$(DEPLOY_LOCKFILE_OPTION) -C $${pkg} status || true; \
done
.PHONY: export-all
export-all:
$(call print_header, "Exporting all cloe Conan packages...")
$(MAKE) export-select export-cli export
.PHONY: deploy-all
deploy-all:
$(call print_header, "Deploying binaries to $(INSTALL_DIR)...")
$(CLOE_LAUNCH) deploy -D $(DEPLOY_DIR) $(DEPLOY_LOCKFILE_SOURCE) $(CONAN_OPTIONS)
.PHONY: clean-all
clean-all:
$(MAKE) clean clean-select
.PHONY: purge-all
purge-all:
$(call print_header, "Removing all cloe Conan packages...")
conan remove -f 'cloe-*'
conan remove -f 'cloe'
conan remove -f 'fable'
.PHONY: package-all
package-all:
conan install $(CONAN_OPTIONS) --install-folder $(DEPLOY_DIR) --build=missing --build=outdated $(DEPLOY_LOCKFILE_SOURCE)
# Development targets ---------------------------------------------------------
help::
$(call print_help_section, "Available development targets")
$(call print_help_target, format, "format Cloe source code with clang-format")
$(call print_help_target, todos, "show all TODOs in Cloe source code")
echo
.PHONY: format
format:
# When you do this, isolate the change in a single commit and then add the
# commit hash to a file such as .git-blame-ignore-revs, so that git-blame
# continues to work as expected.
#
# See: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec $(CLANG_FORMAT) $(CLANG_FORMAT_ARGS) -i {} \;
.PHONY: todos
todos:
$(AG) TODO
$(AG) FIXME
$(AG) XXX
# Hidden development targets --------------------------------------------------
.PHONY: grep-uuids
grep-uuids:
@rg -H --no-heading '^.*([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}).*$$' -r '$$1' \
| sed -nr 's/^(.+):([a-f0-9-]+)$$/\1\t\2/p' \
| sort -k2 \
| uniq --all-repeated=separate -f1 \
| sed -r 's/^(.*) (.*)$$/\2\t\1/'
.PHONY: grep-conan-requires
grep-conan-requires:
@rg -t py '^.*requires\(f?["](.+/[0-9]+\.[^)]+)["].*\).*$$' -r '$$1' -I --no-heading --no-line-number | sort | uniq
.PHONY: find-missing-eol
find-missing-eol:
find . -type f -size +0 -exec gawk 'ENDFILE{if ($0 == "") print FILENAME}' {} \;
.PHONY: sanitize-files
sanitize-files:
git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done
# Micro-packages build targets ------------------------------------------------
include Makefile.all
# Mono-package build targets --------------------------------------------------
DISABLE_HELP_PREAMBLE := true
help::
@printf "Available $(_yel)cloe$(_rst) package targets:\n"
include Makefile.package