diff --git a/.github/workflows/docker-matrix-build.yml b/.github/workflows/docker-matrix-build.yml new file mode 100644 index 0000000..fe819c6 --- /dev/null +++ b/.github/workflows/docker-matrix-build.yml @@ -0,0 +1,32 @@ +name: Docker Matrix Build + +on: + push: + # Run on all branches (no branch filter) + pull_request: + # Run on all branches (no branch filter) + +jobs: + docker-matrix-build: + runs-on: ubuntu-latest + strategy: + matrix: + config: [Debug, Release, RelWithDebInfo, MinSizeRel] + arch: [x86_64-linux-gnu, x86_64-w64-mingw32] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build Docker image + run: | + docker build -t cpp-project:${{ matrix.config }}-${{ matrix.arch }} . + + - name: Run build script in Docker + run: | + docker run --rm \ + -v ${{ github.workspace }}:/workspace \ + -w /workspace \ + --user root \ + cpp-project:${{ matrix.config }}-${{ matrix.arch }} \ + ./scripts/build.sh ${{ matrix.config }} ${{ matrix.arch }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 96c4982..ba088e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,3 +27,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_subdirectory( ${CMAKE_SOURCE_DIR}/src ) +# Copy MinGW runtime DLLs for Windows builds +if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_ARCH STREQUAL "x86_64-w64-mingw32") + # Ensure bin directory exists + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + # Copy runtime DLLs + if(EXISTS /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll) + file(COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll + DESTINATION ${CMAKE_BINARY_DIR}/bin/) + endif() + + if(EXISTS /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll) + file(COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll + DESTINATION ${CMAKE_BINARY_DIR}/bin/) + endif() +endif() + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..695aaaa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM debian:trixie + +ARG USER=user +ENV DEBIAN_FRONTEND=noninteractive + +# misc tools +RUN apt update -y && apt install -y \ + clangd \ + clang-format \ + sudo \ + locales \ + doxygen \ + git \ + build-essential \ + make \ + pkg-config \ + cmake \ + ninja-build \ + yq \ + jq + +# optional cross compile to windows +RUN apt update -y && apt install -y \ + gcc-mingw-w64-x86-64 \ + g++-mingw-w64-x86-64 + +RUN locale-gen en_GB.UTF-8 && update-locale + +RUN useradd -m $USER && echo "$USER:$USER" | chpasswd && adduser $USER sudo +RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +RUN printf "alias ll='ls -la'" >> /home/$USER/.bashrc + +WORKDIR /workspace + +CMD /bin/bash \ No newline at end of file diff --git a/toolchain/cmake-x86_64-w64-mingw32.cmake b/toolchain/cmake-x86_64-w64-mingw32.cmake index f998603..b5b64f3 100755 --- a/toolchain/cmake-x86_64-w64-mingw32.cmake +++ b/toolchain/cmake-x86_64-w64-mingw32.cmake @@ -20,7 +20,5 @@ set(CMAKE_SYSTEM_INCLUDE_PATH /usr/x86_64-w64-mingw32/include) # Ensure dbghelp is available set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldbghelp") -# runtime deps for mingw -file( COPY /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libstdc++-6.dll build-${BUILD_ARCH}/bin/libstdc++-6.dll - /usr/lib/gcc/x86_64-w64-mingw32/14-win32/libgcc_s_seh-1.dll build-${BUILD_ARCH}/bin/libgcc_s_seh-1.dll - DESTINATION ${CMAKE_BINARY_DIR}/bin/ ) +# runtime deps for mingw - these will be copied after the build directory is created +# The actual copying is moved to a post-build step in the main CMakeLists.txt