Skip to content

Commit de41391

Browse files
committed
tooling: Add setup-conan target to Makefile.setup
1 parent 5b72d5b commit de41391

12 files changed

+194
-83
lines changed

.github/workflows/build-cloe.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
sudo apt-get update &&
3636
sudo apt-get install -y make locales &&
3737
sudo make -f Makefile.setup \
38-
WITHOUT_DEV_DEPS=yes \
3938
DEBIAN_FRONTEND=noninteractive \
4039
APT_ARGS="--no-install-recommends -y" \
4140
install-system-deps \

Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ define print_header
1919
@printf ":: %s\n" ${1}
2020
endef
2121

22-
CLOE_ROOT := $(shell pwd)
22+
CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2323
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
2424

2525
# Build configuration:
@@ -41,14 +41,15 @@ include Makefile.setup
4141
include Makefile.all
4242

4343
# Workspace targets -----------------------------------------------------------
44-
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all smoketest smoketest-deps
44+
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all export-cli smoketest smoketest-deps
4545
help::
4646
echo "Available workspace targets:"
4747
echo " smoketest to run BATS system tests"
4848
echo " sphinx to generate Sphinx documentation"
4949
echo " doxygen to generate Doxygen documentation"
5050
echo " deploy to deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]"
5151
echo " deploy-cli to install cloe-launch with pip"
52+
echo " export-cli to export cloe-launch-profile conan recipe"
5253
echo
5354
echo " docker-test to build only a single Docker image"
5455
echo " docker-all to build all Docker images"
@@ -101,7 +102,7 @@ doxygen:
101102
mkdir -p ${BUILD_DIR}/doxygen
102103
doxygen Doxyfile
103104

104-
smoketest-deps: | export-cli smoketest-deps-select
105+
smoketest-deps: export-cli smoketest-deps-select
105106
# Call this target with WITH_VTD=1 to include VTD binding tests.
106107

107108
smoketest: smoketest-select

Makefile.setup

+35-21
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
# Usage: make -f Makefile.setup setup
55
#
66
# This Makefile defines targets for setting up a development environment.
7-
# If you just want the bare minimum, define WITHOUT_DEV_DEPS.
7+
# It is separate from the project Makefile in order to minimize Docker
8+
# cache invalidation and also to improve readability.
89
#
910

11+
CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
12+
1013
APT := $(or \
1114
$(shell command -v apt 2>/dev/null), \
1215
$(shell command -v apt-get 2>/dev/null) \
@@ -39,17 +42,42 @@ endif
3942
help::
4043
echo "Available setup targets:"
4144
echo " setup to perform Git repository setup"
45+
echo " setup-conan to install Conan profile"
4246
echo " install-system-deps to install build (and development) system requirements"
4347
echo " install-python-deps to install Python runtime requirements with ${PIP}"
4448
echo " install-sphinx-deps to install Sphinx runtime requirements with ${PIP}"
4549
echo " install-python-tools to install Python development tools with ${PIPX}"
4650
echo
4751

48-
.PHONY: setup
52+
.PHONY: setup setup-conan
4953
setup:
5054
git config --local core.hooksPath .git-hooks/
5155

52-
.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps install-python-tools
56+
CONAN_DIR=$(shell conan config home)
57+
setup-conan:
58+
# Install Conan if it is not available.
59+
if ! command -v conan >/dev/null 2>&1; then ${PIP} install --user conan; fi
60+
# Initialize Conan configuration if it doesn't already exist.
61+
#
62+
# Since running any conan command, even conan --help creates ${CONAN_DIR}
63+
# and the default configuration, we rely on the existence of the default
64+
# profile as an indication that we have a "fresh" setup where we can
65+
# make our override.
66+
if [ ! -f ${CONAN_DIR}/profiles/default ]; then \
67+
conan config init; \
68+
conan profile update settings.compiler.libcxx=libstdc++11 default; \
69+
conan profile update settings.build_type=RelWithDebInfo default; \
70+
fi
71+
if ! conan config get general.revisions_enabled >/dev/null 2>&1; then \
72+
conan config set general.revisions_enabled=True; \
73+
fi
74+
# Install cloe-debug and cloe-release profiles.
75+
if [ -d "${CLOE_ROOT}/dist/conan" ]; then \
76+
install "${CLOE_ROOT}/dist/conan/cloe-debug.profile" "${CONAN_DIR}/profiles/cloe-debug"; \
77+
install "${CLOE_ROOT}/dist/conan/cloe-release.profile" "${CONAN_DIR}/profiles/cloe-release"; \
78+
fi
79+
80+
.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps install-python-tools install-sphinx-deps
5381
install-system-deps::
5482

5583
# Ubuntu ----------------------------------------------------------------------
@@ -62,6 +90,7 @@ install-ubuntu-deps::
6290
${APT} install ${APT_ARGS} \
6391
bats \
6492
build-essential \
93+
clang-format \
6594
cmake \
6695
doxygen \
6796
curl \
@@ -73,19 +102,11 @@ install-ubuntu-deps::
73102
psmisc \
74103
python3-setuptools \
75104
python3-pip \
105+
python3-venv \
76106
time \
77107
tmux \
78108
;
79109

80-
ifndef WITHOUT_DEV_DEPS
81-
install-ubuntu-deps::
82-
command -v ${APT} >/dev/null 2>&1
83-
${APT} install ${APT_ARGS} \
84-
clang-format \
85-
python3-venv \
86-
;
87-
endif
88-
89110
# Archlinux -------------------------------------------------------------------
90111
ifdef PACMAN
91112
install-system-deps:: install-archlinux-deps
@@ -97,6 +118,7 @@ install-archlinux-deps::
97118
base-devel \
98119
bash \
99120
bash-bats \
121+
clang \
100122
cmake \
101123
curl \
102124
doxygen \
@@ -106,19 +128,11 @@ install-archlinux-deps::
106128
patchelf \
107129
psmisc \
108130
python-pip \
131+
python-virtualenv \
109132
time \
110133
tmux \
111134
;
112135

113-
ifndef WITHOUT_DEV_DEPS
114-
install-archlinux-deps::
115-
command -v ${PACMAN} >/dev/null 2>&1
116-
${PACMAN} -S ${PACMAN_ARGS} \
117-
clang \
118-
python-virtualenv \
119-
;
120-
endif
121-
122136
# Python ----------------------------------------------------------------------
123137
install-python-deps::
124138
command -v ${PIP} >/dev/null 2>&1

conanfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def cloe_requires(dep):
5959
if self.options.with_engine:
6060
cloe_requires("cloe-engine")
6161
if self.options["cloe-engine"].server:
62-
boost_version = "[<1.70]"
62+
boost_version = "[>=1.65.0,<1.70]"
6363

6464
# Overrides:
6565
self.requires("fmt/[~=8.1.1]", override=True)

dist/conan/cloe-debug.profile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include(default)
2+
3+
[settings]
4+
build_type=RelWithDebInfo
5+
*/*@cloe/develop:build_type=Debug

dist/conan/cloe-release.profile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include(default)
2+
3+
[settings]
4+
build_type=Release
5+
*/*@cloe/develop:build_type=RelWithDebInfo

dist/docker/Dockerfile.archlinux

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax = docker/dockerfile:1.2
22
# Dockerfile.archlinux
33
#
4-
# See Dockerfile.focal for documentation of each of the lines.
4+
# See Dockerfile.jammy for documentation of each of the lines.
55
ARG VTD_IMAGE=scratch
66
FROM ${VTD_IMAGE} AS vtd
77
WORKDIR /vtd
@@ -12,7 +12,6 @@ FROM archlinux:latest
1212
COPY Makefile.setup /cloe/Makefile.setup
1313
RUN pacman -Syu --noconfirm --needed make ccache && \
1414
make -f /cloe/Makefile.setup \
15-
WITHOUT_DEV_DEPS=yes \
1615
PACMAN_ARGS="--noconfirm --needed" \
1716
install-system-deps \
1817
&& \
@@ -31,14 +30,11 @@ RUN pip3 install --upgrade pip && \
3130
install-python-deps
3231

3332
# Install and Setup Conan
34-
ARG BUILD_TYPE=RelWithDebInfo
35-
RUN conan config init && \
36-
conan profile update settings.build_type=${BUILD_TYPE} default && \
37-
conan profile update settings.compiler.libcxx=libstdc++11 default && \
38-
conan profile update settings.compiler.version=11 default && \
39-
sed -r -i 's/10.1"]/10.1", "11", "11.1"]/' /root/.conan/settings.yml
40-
33+
COPY dist/conan /cloe/dist/conan
34+
ARG CONAN_PROFILE=cloe-release
4135
ENV CONAN_NON_INTERACTIVE=yes
36+
RUN make -f /cloe/Makefile.setup setup-conan && \
37+
conan config set general.default_profile=${CONAN_PROFILE}
4238

4339
# Build and Install Cloe
4440
WORKDIR /cloe

dist/docker/Dockerfile.bionic

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax = docker/dockerfile:1.2
22
# Dockerfile.bionic
33
#
4-
# See Dockerfile.focal for documentation of each of the lines.
4+
# See Dockerfile.jammy for documentation of each of the lines.
55
ARG VTD_IMAGE=scratch
66
FROM ${VTD_IMAGE} AS vtd
77
WORKDIR /vtd
@@ -15,7 +15,6 @@ RUN --mount=type=cache,id=bionic-cache,target=/var/cache/apt \
1515
apt-get update && \
1616
apt-get install -y make ccache locales libbsd0 && \
1717
make -f /cloe/Makefile.setup \
18-
WITHOUT_DEV_DEPS=yes \
1918
DEBIAN_FRONTEND=noninteractive \
2019
APT_ARGS="--no-install-recommends -y" \
2120
install-system-deps \
@@ -34,12 +33,11 @@ RUN pip3 install --upgrade pip && \
3433
install-python-deps
3534

3635
# Install and Setup Conan
37-
ARG BUILD_TYPE=RelWithDebInfo
38-
RUN conan profile new --detect default && \
39-
conan profile update settings.build_type=${BUILD_TYPE} default && \
40-
conan profile update settings.compiler.libcxx=libstdc++11 default
41-
36+
COPY dist/conan /cloe/dist/conan
37+
ARG CONAN_PROFILE=cloe-release
4238
ENV CONAN_NON_INTERACTIVE=yes
39+
RUN make -f /cloe/Makefile.setup setup-conan && \
40+
conan config set general.default_profile=${CONAN_PROFILE}
4341

4442
# Build and Install Cloe
4543
WORKDIR /cloe

dist/docker/Dockerfile.focal

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
# syntax = docker/dockerfile:1.2
22
# Dockerfile.focal
33
#
4-
# This file acts partly as a Docker recipe for building Cloe on Ubuntu.
5-
#
6-
# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY,
7-
# HTTPS_PROXY, and NO_PROXY variables.
8-
9-
# This is a work-around to not being able to use variables in RUN --mount=from:
10-
# If you want to use VTD in this image, you need to specify the Docker image
11-
# containing the distribution that can be mounted at /root/.conan/data/
4+
# See Dockerfile.jammy for documentation of each of the lines.
125
ARG VTD_IMAGE=scratch
136
FROM ${VTD_IMAGE} AS vtd
147
WORKDIR /vtd
158

169
FROM ubuntu:20.04
1710

1811
# Install System Packages
19-
#
20-
# These packages are required for building and testing Cloe.
2112
COPY Makefile.setup /cloe/Makefile.setup
2213
RUN --mount=type=cache,id=focal-cache,target=/var/cache/apt \
2314
--mount=type=cache,id=focal-lib,target=/var/lib/apt \
2415
apt-get update && \
2516
apt-get install -y make ccache locales && \
2617
make -f /cloe/Makefile.setup \
27-
WITHOUT_DEV_DEPS=yes \
2818
DEBIAN_FRONTEND=noninteractive \
2919
APT_ARGS="--no-install-recommends -y" \
3020
install-system-deps \
@@ -43,22 +33,13 @@ RUN pip3 install --upgrade pip && \
4333
install-python-deps
4434

4535
# Install and Setup Conan
46-
#
47-
# You may not want to use the default Conan remote (conan-center), so we use
48-
# whatever is stored in the build arguments CONAN_REMOTE. Currently, only
49-
# anonymous access is possible in this Dockerfile.
50-
ARG BUILD_TYPE=RelWithDebInfo
51-
RUN conan profile new --detect default && \
52-
conan profile update settings.build_type=${BUILD_TYPE} default && \
53-
conan profile update settings.compiler.libcxx=libstdc++11 default
54-
36+
COPY dist/conan /cloe/dist/conan
37+
ARG CONAN_PROFILE=cloe-release
5538
ENV CONAN_NON_INTERACTIVE=yes
39+
RUN make -f /cloe/Makefile.setup setup-conan && \
40+
conan config set general.default_profile=${CONAN_PROFILE}
5641

5742
# Build and Install Cloe
58-
#
59-
# All common processes are made easy to apply by writing target recipes in the
60-
# Makefile at the root of the repository. This also acts as a form of
61-
# documentation.
6243
WORKDIR /cloe
6344
ARG WITH_VTD=0
6445
ARG KEEP_SOURCES=0

0 commit comments

Comments
 (0)