Skip to content

Commit c56a449

Browse files
Merge pull request #2 from cracked-machine/copilot/fix-69db1914-8b51-4c7f-9901-2395d4df0edf
Add Docker matrix build workflow for cross-platform CI/CD
2 parents f4db9eb + 53078c8 commit c56a449

File tree

4 files changed

+87
-4
lines changed

4 files changed

+87
-4
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Docker Matrix Build
2+
3+
on:
4+
push:
5+
# Run on all branches (no branch filter)
6+
pull_request:
7+
# Run on all branches (no branch filter)
8+
9+
jobs:
10+
docker-matrix-build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
config: [Debug, Release, RelWithDebInfo, MinSizeRel]
15+
arch: [x86_64-linux-gnu, x86_64-w64-mingw32]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Build Docker image
22+
run: |
23+
docker build -t cpp-project:${{ matrix.config }}-${{ matrix.arch }} .
24+
25+
- name: Run build script in Docker
26+
run: |
27+
docker run --rm \
28+
-v ${{ github.workspace }}:/workspace \
29+
-w /workspace \
30+
--user root \
31+
cpp-project:${{ matrix.config }}-${{ matrix.arch }} \
32+
./scripts/build.sh ${{ matrix.config }} ${{ matrix.arch }}

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2727

2828
add_subdirectory( ${CMAKE_SOURCE_DIR}/src )
2929

30+
# Copy MinGW runtime DLLs for Windows builds
31+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_ARCH STREQUAL "x86_64-w64-mingw32")
32+
# Ensure bin directory exists
33+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
34+
35+
# Copy runtime DLLs
36+
if(EXISTS /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll)
37+
file(COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll
38+
DESTINATION ${CMAKE_BINARY_DIR}/bin/)
39+
endif()
40+
41+
if(EXISTS /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll)
42+
file(COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll
43+
DESTINATION ${CMAKE_BINARY_DIR}/bin/)
44+
endif()
45+
endif()
46+

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM debian:trixie
2+
3+
ARG USER=user
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# misc tools
7+
RUN apt update -y && apt install -y \
8+
clangd \
9+
clang-format \
10+
sudo \
11+
locales \
12+
doxygen \
13+
git \
14+
build-essential \
15+
make \
16+
pkg-config \
17+
cmake \
18+
ninja-build \
19+
yq \
20+
jq
21+
22+
# optional cross compile to windows
23+
RUN apt update -y && apt install -y \
24+
gcc-mingw-w64-x86-64 \
25+
g++-mingw-w64-x86-64
26+
27+
RUN locale-gen en_GB.UTF-8 && update-locale
28+
29+
RUN useradd -m $USER && echo "$USER:$USER" | chpasswd && adduser $USER sudo
30+
RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
31+
32+
RUN printf "alias ll='ls -la'" >> /home/$USER/.bashrc
33+
34+
WORKDIR /workspace
35+
36+
CMD /bin/bash

toolchain/cmake-x86_64-w64-mingw32.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ set(CMAKE_SYSTEM_INCLUDE_PATH /usr/x86_64-w64-mingw32/include)
2020
# Ensure dbghelp is available
2121
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldbghelp")
2222

23-
# runtime deps for mingw
24-
file( COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll build-${BUILD_ARCH}/bin/libstdc++-6.dll
25-
/usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll build-${BUILD_ARCH}/bin/libgcc_s_seh-1.dll
26-
DESTINATION ${CMAKE_BINARY_DIR}/bin/ )
23+
# runtime deps for mingw - these will be copied after the build directory is created
24+
# The actual copying is moved to a post-build step in the main CMakeLists.txt

0 commit comments

Comments
 (0)