File tree Expand file tree Collapse file tree 9 files changed +76
-5
lines changed
Expand file tree Collapse file tree 9 files changed +76
-5
lines changed Original file line number Diff line number Diff line change 4242 - name : Build and push Docker image
4343 uses : docker/build-push-action@v3
4444 with :
45- context : ${{ matrix.name }}
45+ context : .
46+ file : ${{ matrix.name }}/Dockerfile
4647 push : true
4748 tags : ${{ steps.meta.outputs.tags }}
4849 labels : ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change @@ -6,12 +6,21 @@ Docker containers are pushed to the GitHub container registry (ghcr.io) by a bui
66All dockerfiles support these build tools:
77- GNU make
88- Python 3
9+ - CMake (with Ninja)
910
1011To cross-compile something, mount the working directory to ` /work ` and run your make command like this:
1112``` shell
1213docker run --rm -v $( pwd) :/work ghcr.io/considerit/cross-linux-armhf-debian11 make $target
1314```
1415
16+ To cross-compile with CMake, a toolchain file is used which expects libraries in ` $CROSS_SYSROOT/lib ` and includes in ` $CROSS_SYSROOT/include ` .
17+ ``` shell
18+ # add -DCMAKE_TOOLCHAIN_FILE=/var/cross-sysroot/toolchain.cmake to your cmake call or use wrapper script on config step
19+ docker run --rm -v $( pwd) :/work ghcr.io/considerit/cross-linux-armhf-debian11 cmake-cross -B ./build-armhf
20+
21+ docker run --rm -v $( pwd) :/work ghcr.io/considerit/cross-linux-armhf-debian11 cmake --build ./build-armhf
22+ ```
23+
1524If you want to build the images yourself, run ` docker build ` on the individual dockerfiles like this:
1625``` shell
1726cd linux-gnueabihf-debian11
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ echo " cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE $@ "
3+ cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE $@
Original file line number Diff line number Diff line change 11FROM debian:11-slim
22
33ARG workdir=/work
4+ ENV CROSS_SYSROOT=/var/cross-sysroot
45
56# install basic utilities
67RUN apt update && apt -y install git rsync python3
@@ -12,6 +13,13 @@ RUN git config --global --add safe.directory $workdir
1213RUN apt -y install g++-aarch64-linux-gnu
1314
1415# install basic build tools
15- RUN apt -y install build-essential make ccache
16+ RUN apt -y install build-essential make ccache cmake ninja-build
17+
18+ # setup CMake for cross-compiling
19+ RUN mkdir -p ${CROSS_SYSROOT}/include/
20+ RUN mkdir -p ${CROSS_SYSROOT}/lib/
21+ ENV CMAKE_TOOLCHAIN_FILE=${CROSS_SYSROOT}/toolchain.cmake
22+ COPY linux-aarch64-tc.cmake ${CMAKE_TOOLCHAIN_FILE}
23+ COPY cmake-cross.sh /usr/bin/cmake-cross
1624
1725WORKDIR $workdir
Original file line number Diff line number Diff line change 1+ set (CMAKE_SYSTEM_NAME Linux )
2+ set (CMAKE_SYSTEM_PROCESSOR aarch64)
3+
4+ set (CMAKE_SYSROOT $ENV{CROSS_SYSROOT} )
5+ set (cross_tripe "aarch64-linux-gnu" )
6+
7+ set (CMAKE_C_COMPILER ${cross_tripe} -gcc)
8+ set (CMAKE_CXX_COMPILER ${cross_tripe} -g++)
9+
10+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
11+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13+ set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
Original file line number Diff line number Diff line change 11FROM debian:10-slim
22
33ARG workdir=/work
4+ ENV CROSS_SYSROOT=/var/cross-sysroot
45
56# install basic utilities
67RUN apt update && apt -y install git rsync python3
@@ -12,6 +13,13 @@ RUN git config --global --add safe.directory $workdir
1213RUN apt -y install g++-arm-linux-gnueabihf
1314
1415# install basic build tools
15- RUN apt -y install build-essential make ccache
16+ RUN apt -y install build-essential make ccache cmake ninja-build
17+
18+ # setup CMake for cross-compiling
19+ RUN mkdir -p ${CROSS_SYSROOT}/include/
20+ RUN mkdir -p ${CROSS_SYSROOT}/lib/
21+ ENV CMAKE_TOOLCHAIN_FILE=${CROSS_SYSROOT}/toolchain.cmake
22+ COPY linux-armhf-tc.cmake ${CMAKE_TOOLCHAIN_FILE}
23+ COPY cmake-cross.sh /usr/bin/cmake-cross
1624
1725WORKDIR $workdir
Original file line number Diff line number Diff line change 11FROM debian:11-slim
22
33ARG workdir=/work
4+ ENV CROSS_SYSROOT=/var/cross-sysroot
45
56# install basic utilities
67RUN apt update && apt -y install git rsync python3
@@ -12,6 +13,13 @@ RUN git config --global --add safe.directory $workdir
1213RUN apt -y install g++-arm-linux-gnueabihf
1314
1415# install basic build tools
15- RUN apt -y install build-essential make ccache
16+ RUN apt -y install build-essential make ccache cmake ninja-build
17+
18+ # setup CMake for cross-compiling
19+ RUN mkdir -p ${CROSS_SYSROOT}/include/
20+ RUN mkdir -p ${CROSS_SYSROOT}/lib/
21+ ENV CMAKE_TOOLCHAIN_FILE=${CROSS_SYSROOT}/toolchain.cmake
22+ COPY linux-armhf-tc.cmake ${CMAKE_TOOLCHAIN_FILE}
23+ COPY cmake-cross.sh /usr/bin/cmake-cross
1624
1725WORKDIR $workdir
Original file line number Diff line number Diff line change 1+ set (CMAKE_SYSTEM_NAME Linux )
2+ set (CMAKE_SYSTEM_PROCESSOR armhf)
3+
4+ set (CMAKE_SYSROOT $ENV{CROSS_SYSROOT} )
5+ set (cross_tripe "arm-linux-gnueabihf" )
6+
7+ set (CMAKE_C_COMPILER ${cross_tripe} -gcc)
8+ set (CMAKE_CXX_COMPILER ${cross_tripe} -g++)
9+
10+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
11+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13+ set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
Original file line number Diff line number Diff line change 11FROM ubuntu:18.04
22
33ARG workdir=/work
4+ ENV CROSS_SYSROOT=/var/cross-sysroot
45
56# install basic utilities
67RUN apt update && apt -y install git rsync python3
@@ -12,6 +13,13 @@ RUN git config --global --add safe.directory $workdir
1213RUN apt -y install g++-arm-linux-gnueabihf
1314
1415# install basic build tools
15- RUN apt -y install build-essential make ccache
16+ RUN apt -y install build-essential make ccache cmake ninja-build
17+
18+ # setup CMake for cross-compiling
19+ RUN mkdir -p ${CROSS_SYSROOT}/include/
20+ RUN mkdir -p ${CROSS_SYSROOT}/lib/
21+ ENV CMAKE_TOOLCHAIN_FILE=${CROSS_SYSROOT}/toolchain.cmake
22+ COPY linux-armhf-tc.cmake ${CMAKE_TOOLCHAIN_FILE}
23+ COPY cmake-cross.sh /usr/bin/cmake-cross
1624
1725WORKDIR $workdir
You can’t perform that action at this time.
0 commit comments