Skip to content

Commit

Permalink
tooling: Add setup-conan target to Makefile.setup
Browse files Browse the repository at this point in the history
  • Loading branch information
cassava committed Jul 27, 2022
1 parent 5b72d5b commit de41391
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 83 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-cloe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
sudo apt-get update &&
sudo apt-get install -y make locales &&
sudo make -f Makefile.setup \
WITHOUT_DEV_DEPS=yes \
DEBIAN_FRONTEND=noninteractive \
APT_ARGS="--no-install-recommends -y" \
install-system-deps \
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define print_header
@printf ":: %s\n" ${1}
endef

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

# Build configuration:
Expand All @@ -41,14 +41,15 @@ include Makefile.setup
include Makefile.all

# Workspace targets -----------------------------------------------------------
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all smoketest smoketest-deps
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all export-cli smoketest smoketest-deps
help::
echo "Available workspace targets:"
echo " smoketest to run BATS system tests"
echo " sphinx to generate Sphinx documentation"
echo " doxygen to generate Doxygen documentation"
echo " deploy to deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]"
echo " deploy-cli to install cloe-launch with pip"
echo " export-cli to export cloe-launch-profile conan recipe"
echo
echo " docker-test to build only a single Docker image"
echo " docker-all to build all Docker images"
Expand Down Expand Up @@ -101,7 +102,7 @@ doxygen:
mkdir -p ${BUILD_DIR}/doxygen
doxygen Doxyfile

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

smoketest: smoketest-select
Expand Down
56 changes: 35 additions & 21 deletions Makefile.setup
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
# Usage: make -f Makefile.setup setup
#
# This Makefile defines targets for setting up a development environment.
# If you just want the bare minimum, define WITHOUT_DEV_DEPS.
# It is separate from the project Makefile in order to minimize Docker
# cache invalidation and also to improve readability.
#

CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

APT := $(or \
$(shell command -v apt 2>/dev/null), \
$(shell command -v apt-get 2>/dev/null) \
Expand Down Expand Up @@ -39,17 +42,42 @@ endif
help::
echo "Available setup targets:"
echo " setup to perform Git repository setup"
echo " setup-conan to install Conan profile"
echo " install-system-deps to install build (and development) system requirements"
echo " install-python-deps to install Python runtime requirements with ${PIP}"
echo " install-sphinx-deps to install Sphinx runtime requirements with ${PIP}"
echo " install-python-tools to install Python development tools with ${PIPX}"
echo

.PHONY: setup
.PHONY: setup setup-conan
setup:
git config --local core.hooksPath .git-hooks/

.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps install-python-tools
CONAN_DIR=$(shell conan config home)
setup-conan:
# Install Conan if it is not available.
if ! command -v conan >/dev/null 2>&1; then ${PIP} install --user conan; 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_DIR}/profiles/default ]; then \
conan config init; \
conan profile update settings.compiler.libcxx=libstdc++11 default; \
conan profile update settings.build_type=RelWithDebInfo 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 and cloe-release profiles.
if [ -d "${CLOE_ROOT}/dist/conan" ]; then \
install "${CLOE_ROOT}/dist/conan/cloe-debug.profile" "${CONAN_DIR}/profiles/cloe-debug"; \
install "${CLOE_ROOT}/dist/conan/cloe-release.profile" "${CONAN_DIR}/profiles/cloe-release"; \
fi

.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps install-python-tools install-sphinx-deps
install-system-deps::

# Ubuntu ----------------------------------------------------------------------
Expand All @@ -62,6 +90,7 @@ install-ubuntu-deps::
${APT} install ${APT_ARGS} \
bats \
build-essential \
clang-format \
cmake \
doxygen \
curl \
Expand All @@ -73,19 +102,11 @@ install-ubuntu-deps::
psmisc \
python3-setuptools \
python3-pip \
python3-venv \
time \
tmux \
;

ifndef WITHOUT_DEV_DEPS
install-ubuntu-deps::
command -v ${APT} >/dev/null 2>&1
${APT} install ${APT_ARGS} \
clang-format \
python3-venv \
;
endif

# Archlinux -------------------------------------------------------------------
ifdef PACMAN
install-system-deps:: install-archlinux-deps
Expand All @@ -97,6 +118,7 @@ install-archlinux-deps::
base-devel \
bash \
bash-bats \
clang \
cmake \
curl \
doxygen \
Expand All @@ -106,19 +128,11 @@ install-archlinux-deps::
patchelf \
psmisc \
python-pip \
python-virtualenv \
time \
tmux \
;

ifndef WITHOUT_DEV_DEPS
install-archlinux-deps::
command -v ${PACMAN} >/dev/null 2>&1
${PACMAN} -S ${PACMAN_ARGS} \
clang \
python-virtualenv \
;
endif

# Python ----------------------------------------------------------------------
install-python-deps::
command -v ${PIP} >/dev/null 2>&1
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cloe_requires(dep):
if self.options.with_engine:
cloe_requires("cloe-engine")
if self.options["cloe-engine"].server:
boost_version = "[<1.70]"
boost_version = "[>=1.65.0,<1.70]"

# Overrides:
self.requires("fmt/[~=8.1.1]", override=True)
Expand Down
5 changes: 5 additions & 0 deletions dist/conan/cloe-debug.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(default)

[settings]
build_type=RelWithDebInfo
*/*@cloe/develop:build_type=Debug
5 changes: 5 additions & 0 deletions dist/conan/cloe-release.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(default)

[settings]
build_type=Release
*/*@cloe/develop:build_type=RelWithDebInfo
14 changes: 5 additions & 9 deletions dist/docker/Dockerfile.archlinux
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1.2
# Dockerfile.archlinux
#
# See Dockerfile.focal for documentation of each of the lines.
# See Dockerfile.jammy for documentation of each of the lines.
ARG VTD_IMAGE=scratch
FROM ${VTD_IMAGE} AS vtd
WORKDIR /vtd
Expand All @@ -12,7 +12,6 @@ FROM archlinux:latest
COPY Makefile.setup /cloe/Makefile.setup
RUN pacman -Syu --noconfirm --needed make ccache && \
make -f /cloe/Makefile.setup \
WITHOUT_DEV_DEPS=yes \
PACMAN_ARGS="--noconfirm --needed" \
install-system-deps \
&& \
Expand All @@ -31,14 +30,11 @@ RUN pip3 install --upgrade pip && \
install-python-deps

# Install and Setup Conan
ARG BUILD_TYPE=RelWithDebInfo
RUN conan config init && \
conan profile update settings.build_type=${BUILD_TYPE} default && \
conan profile update settings.compiler.libcxx=libstdc++11 default && \
conan profile update settings.compiler.version=11 default && \
sed -r -i 's/10.1"]/10.1", "11", "11.1"]/' /root/.conan/settings.yml

COPY dist/conan /cloe/dist/conan
ARG CONAN_PROFILE=cloe-release
ENV CONAN_NON_INTERACTIVE=yes
RUN make -f /cloe/Makefile.setup setup-conan && \
conan config set general.default_profile=${CONAN_PROFILE}

# Build and Install Cloe
WORKDIR /cloe
Expand Down
12 changes: 5 additions & 7 deletions dist/docker/Dockerfile.bionic
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1.2
# Dockerfile.bionic
#
# See Dockerfile.focal for documentation of each of the lines.
# See Dockerfile.jammy for documentation of each of the lines.
ARG VTD_IMAGE=scratch
FROM ${VTD_IMAGE} AS vtd
WORKDIR /vtd
Expand All @@ -15,7 +15,6 @@ RUN --mount=type=cache,id=bionic-cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y make ccache locales libbsd0 && \
make -f /cloe/Makefile.setup \
WITHOUT_DEV_DEPS=yes \
DEBIAN_FRONTEND=noninteractive \
APT_ARGS="--no-install-recommends -y" \
install-system-deps \
Expand All @@ -34,12 +33,11 @@ RUN pip3 install --upgrade pip && \
install-python-deps

# Install and Setup Conan
ARG BUILD_TYPE=RelWithDebInfo
RUN conan profile new --detect default && \
conan profile update settings.build_type=${BUILD_TYPE} default && \
conan profile update settings.compiler.libcxx=libstdc++11 default

COPY dist/conan /cloe/dist/conan
ARG CONAN_PROFILE=cloe-release
ENV CONAN_NON_INTERACTIVE=yes
RUN make -f /cloe/Makefile.setup setup-conan && \
conan config set general.default_profile=${CONAN_PROFILE}

# Build and Install Cloe
WORKDIR /cloe
Expand Down
29 changes: 5 additions & 24 deletions dist/docker/Dockerfile.focal
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
# syntax = docker/dockerfile:1.2
# Dockerfile.focal
#
# This file acts partly as a Docker recipe for building Cloe on Ubuntu.
#
# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY,
# HTTPS_PROXY, and NO_PROXY variables.

# This is a work-around to not being able to use variables in RUN --mount=from:
# If you want to use VTD in this image, you need to specify the Docker image
# containing the distribution that can be mounted at /root/.conan/data/
# See Dockerfile.jammy for documentation of each of the lines.
ARG VTD_IMAGE=scratch
FROM ${VTD_IMAGE} AS vtd
WORKDIR /vtd

FROM ubuntu:20.04

# Install System Packages
#
# These packages are required for building and testing Cloe.
COPY Makefile.setup /cloe/Makefile.setup
RUN --mount=type=cache,id=focal-cache,target=/var/cache/apt \
--mount=type=cache,id=focal-lib,target=/var/lib/apt \
apt-get update && \
apt-get install -y make ccache locales && \
make -f /cloe/Makefile.setup \
WITHOUT_DEV_DEPS=yes \
DEBIAN_FRONTEND=noninteractive \
APT_ARGS="--no-install-recommends -y" \
install-system-deps \
Expand All @@ -43,22 +33,13 @@ RUN pip3 install --upgrade pip && \
install-python-deps

# Install and Setup Conan
#
# You may not want to use the default Conan remote (conan-center), so we use
# whatever is stored in the build arguments CONAN_REMOTE. Currently, only
# anonymous access is possible in this Dockerfile.
ARG BUILD_TYPE=RelWithDebInfo
RUN conan profile new --detect default && \
conan profile update settings.build_type=${BUILD_TYPE} default && \
conan profile update settings.compiler.libcxx=libstdc++11 default

COPY dist/conan /cloe/dist/conan
ARG CONAN_PROFILE=cloe-release
ENV CONAN_NON_INTERACTIVE=yes
RUN make -f /cloe/Makefile.setup setup-conan && \
conan config set general.default_profile=${CONAN_PROFILE}

# Build and Install Cloe
#
# All common processes are made easy to apply by writing target recipes in the
# Makefile at the root of the repository. This also acts as a form of
# documentation.
WORKDIR /cloe
ARG WITH_VTD=0
ARG KEEP_SOURCES=0
Expand Down
Loading

0 comments on commit de41391

Please sign in to comment.