forked from eclipse/cloe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.setup
170 lines (154 loc) · 4.93 KB
/
Makefile.setup
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
# Makefile.setup
# vim: set noet:
#
# Usage: make -f Makefile.setup setup
#
# This Makefile defines targets for setting up a development environment.
# It is separate from the project Makefile in order to minimize Docker
# cache invalidation and also to improve readability.
#
SHELL := /bin/bash
PROJECT_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
CONAN_DIR := $(shell conan config home 2>/dev/null || echo "$HOME/.conan")
CONAN_PROFILE := default
CONAN_PROFILE_PATH := $(CONAN_DIR)/profiles/$(CONAN_PROFILE)
include $(PROJECT_ROOT)/Makefile.help
APT := $(or \
$(shell command -v apt 2>/dev/null), \
$(shell command -v apt-get 2>/dev/null) \
)
APT_ARGS := --no-install-recommends -y
UBUNTU_VERSION := $(shell source /etc/os-release && echo $$VERSION_ID)
PIP := $(or \
$(shell command -v pip3 2>/dev/null), \
$(shell command -v pip 2>/dev/null) \
)
ifeq ($(VIRTUAL_ENV), )
PIP_INSTALL_ARGS := --user --upgrade
else
PIP_INSTALL_ARGS := --upgrade
endif
PIPX := $(shell command -v pipx 2>/dev/null)
PIPX_INSTALL_ARGS :=
ifndef PIPX
PIPX := $(PIP)
PIPX_INSTALL_ARGS := $(PIP_INSTALL_ARGS)
endif
.DEFAULT_GOAL := help
.PHONY: help
.SILENT: help
help::
$(call print_help_section, "Available setup targets")
$(call print_help_target, setup-git, "perform Git repository setup")
$(call print_help_target, setup-conan, "install Conan profile")
$(call print_help_target, install-system-deps, "install build (and development) system requirements")
$(call print_help_target, install-python-deps, "install Python runtime requirements with $(_dim)$(PIP)$(_rst)")
$(call print_help_target, install-sphinx-deps, "install Sphinx runtime requirements with $(_dim)$(PIP)$(_rst)")
$(call print_help_target, install-python-tools, "install Python development tools with $(_dim)$(PIPX)$(_rst)")
echo
.PHONY: setup-git
setup-git:
git config --local core.hooksPath .git-hooks/
.PHONY: setup-conan
setup-conan:
# Install Conan if it is not available.
if ! command -v conan >/dev/null 2>&1; then $(PIP) install --user --upgrade "conan<2"; fi
# Initialize Conan configuration if it doesn't already exist.
#
# Since running any conan command, even conan --help creates $(CONAN_DIR)
# and the default configuration, we rely on the existence of the default
# profile as an indication that we have a "fresh" setup where we can
# make our override.
if [ ! -f $(CONAN_PROFILE_PATH) ]; then \
conan config init; \
conan profile update settings.compiler.libcxx=libstdc++11 $(CONAN_PROFILE); \
conan profile update settings.build_type=Debug $(CONAN_PROFILE); \
fi
if ! conan config get general.default_build_profile >/dev/null 2>&1; then \
conan config set general.default_build_profile=default; \
fi
if ! conan config get general.revisions_enabled >/dev/null 2>&1; then \
conan config set general.revisions_enabled=True; \
fi
# Install cloe-{debug,normal,release} profiles.
for profile in "$(PROJECT_ROOT)"/dist/conan/*.profile; do \
export profile_name=$$(basename -s .profile $${profile}); \
install -m 644 "$${profile}" "$(CONAN_DIR)/profiles/$${profile_name}"; \
sed -r -i "s/default/$(CONAN_PROFILE)/" "$(CONAN_DIR)/profiles/$${profile_name}"; \
done
# Ensure we have an up-to-date CMake configured.
if [ $$(( cmake --version | head -1 | cut -f3 -d' '; echo "3.14.99" ) | sort -V | tail -1) = "3.14.99" ]; then \
if ! grep "cmake/" $(CONAN_PROFILE_PATH) >/dev/null; then \
echo -e "[tool_requires]\ncmake/[>=3.15.0]" >> $(CONAN_PROFILE_PATH); \
fi; \
fi
.PHONY: install-system-deps
install-system-deps::
# Ubuntu ----------------------------------------------------------------------
ifdef APT
install-system-deps:: install-ubuntu-deps
endif
.PHONY: install-ubuntu-deps
install-ubuntu-deps::
command -v $(APT) >/dev/null 2>&1
$(APT) install $(APT_ARGS) \
bats \
build-essential \
clang-format \
cmake \
curl \
doxygen \
file \
git \
graphviz \
jq \
libgl-dev \
libxinerama-dev \
libxrandr-dev \
libfontconfig1-dev \
netcat-openbsd \
patchelf \
psmisc \
python3-pip \
python3-setuptools \
python3-venv \
time \
tmux \
;
# Require GCC and G++ version >= 8
if [ "$(UBUNTU_VERSION)" == "18.04" ]; then \
$(APT) install $(APT_ARGS) gcc-8 g++-8; \
if [ $$(readlink /usr/bin/g++) == "g++-7" ]; then \
ln -sf /usr/bin/g++-8 /usr/bin/g++ && \
ln -sf /usr/bin/gcc-8 /usr/bin/gcc; \
fi; \
fi
# Python ----------------------------------------------------------------------
.PHONY: install-python-deps
install-python-deps::
command -v $(PIP) >/dev/null 2>&1
$(PIP) install $(PIP_INSTALL_ARGS) \
click \
"conan<2.0.0" \
libtmux \
toml \
pipx \
;
.PHONY: install-sphinx-deps
install-sphinx-deps:
command -v $(PIP) >/dev/null 2>&1
$(PIP) install $(PIP_INSTALL_ARGS) -r docs/requirements.txt
.PHONY: install-python-tools
install-python-tools::
command -v $(PIPX) >/dev/null 2>&1
for pkg in \
black \
mypy \
flake8 \
poetry \
pylint \
yq \
; \
do \
$(PIPX) install $(PIPX_INSTALL_ARGS) $${pkg}; \
done