Skip to content

Latest commit

 

History

History
106 lines (79 loc) · 2.84 KB

README.md

File metadata and controls

106 lines (79 loc) · 2.84 KB

CI: Makefile/Docker testing

To test the build on various distro, I'm using docker containers and a Makefile for orchestration.

pros:

  • You are independent of third party CI runner VM images (e.g. github actions/virtual-environments).
  • You can run it locally on any host having a linux docker image support.
  • Most CI provide runner with docker and Makefile installed.

cons:

  • Only GNU/Linux distro supported.
  • Could take few GiB (~30 GiB for all distro and all languages)
    • ~500MiB OS + C++/CMake tools,
    • ~150 MiB Python, wheel,

Usage

To get the help simply type:

make

note: you can also use from top directory

make --directory=cmake

Example

For example to test inside an Alpine container:

make alpine_test

Docker layers

Dockerfile is splitted in several stages.

docker

Run arm64v8 image on amd64 machine

You can build and run arm64v8 (i.e. aarch64) docker container on a amd64 host (x86_64) by enabling qemu support:

docker run --pull always --rm --privileged multiarch/qemu-user-static --reset -p yes

ref: https://github.com/multiarch/qemu-user-static#getting-started

Then you should be able to run them, e.g.:

docker run --rm -it arm64v8/ubuntu

ref: https://github.com/docker-library/official-images#architectures-other-than-amd64

Docker buildx

ref: https://docs.docker.com/buildx/working-with-buildx/

Once you enable QEMU support (see above), you can list available platform using:

docker buildx ls

Then you can build a docker image using one of the available platform

docker buildx build --platform linux/arm64 ...

Custom CMake install

To control the version of CMake, instead of using the version provided by the distro package manager, you can:

  • Install the prebuilt binaries (recommanded)
  • Build it from source (slower)
  • Install it using the pypi package cmake (need a python stack)

Install prebuilt

The recommended and faster way is to use the prebuilt version:

# Install CMake 3.26.4
RUN wget "https://cmake.org/files/v3.26/cmake-3.26.4-linux-x86_64.sh" \
&& chmod a+x cmake-3.26.4-linux-x86_64.sh \
&& ./cmake-3.26.4-linux-x86_64.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.26.4-linux-x86_64.sh

warning: Since CMake 3.20 Kitware use a lowercase linux instead of Linux.

Build from source

To build from source you can use the following snippet:

# Install CMake 3.26.4
RUN wget "https://cmake.org/files/v3.26/cmake-3.26.4.tar.gz" \
&& tar xzf cmake-3.26.4.tar.gz \
&& rm cmake-3.26.4.tar.gz \
&& cd cmake-3.26.4 \
&& ./bootstrap --prefix=/usr/local/ \
&& make \
&& make install \
&& cd .. \
&& rm -rf cmake-3.26.4