Skip to content

Updating project structure #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/ciimage/Dockerfile.archlinux
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ RUN pacman -Syu --noconfirm && \
clang \
gdb \
llvm \
rust \
cargo \
cmake \
wget \
python \
python-pip \
Expand Down
5 changes: 2 additions & 3 deletions .github/ciimage/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ RUN apt-get update && \
gdb \
llvm \
libstdc++-8-dev \
rustc \
cargo \
cmake \
wget \
python3 \
python3-pip \
Expand All @@ -36,4 +35,4 @@ ENV LD_LIBRARY_PATH=/usr/local/lib
WORKDIR /workspace

# Default command
CMD ["bash"]
CMD ["bash"]
4 changes: 2 additions & 2 deletions .github/ciimage/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENV TZ=UTC

# Install system dependencies and clean up
RUN dnf -y update && \
dnf -y groupinstall "Development Tools" && \
dnf install -y \
gcc \
gcc-c++ \
Expand All @@ -19,9 +20,8 @@ RUN dnf -y update && \
python3-pip \
git && \
dnf clean all

# Install Meson and Ninja using pip
RUN python3 -m pip install --no-cache-dir meson ninja
RUN python3 -m pip install --no-cache-dir cmake meson ninja

# Set environment variables
ENV CC=/usr/bin/clang
Expand Down
12 changes: 4 additions & 8 deletions .github/ciimage/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@ RUN apt-get update && \
g++ \
gdb \
llvm \
gobjc \
gobjc++ \
libobjc-10-dev \
libstdc++-10-dev \
rustc \
cargo \
dub \
wget \
python3 \
python3-pip \
git && \
git \
tzdata && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Meson, Ninja, and Cython using pip
RUN python3 -m pip install --no-cache-dir meson ninja
RUN python3 -m pip install --no-cache-dir cmake meson ninja

# Set environment variables
ENV CC=/usr/bin/gcc
ENV CXX=/usr/bin/g++
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV LD_LIBRARY_PATH=/usr/local/lib
282 changes: 282 additions & 0 deletions .github/workflows/cmake_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
name: CMake CI

on:
push:
paths:
- "**.c"
- "**.h"
- "**.cpp"
- "**.hpp"
- "**.py"
- "**.build"
- "**.options"
pull_request:
paths:
- "**.c"
- "**.h"
- "**.cpp"
- "**.hpp"
- "**.py"
- "**.build"
- "**.options"

jobs:
build_msvc:
name: Building on MSVC ${{ matrix.msvc_version }}
runs-on: windows-latest
strategy:
matrix:
msvc_version: [2015, 2017, 2019, 2022]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install CMake and Ninja
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install cmake ninja
if ($env:msvc_version -eq "2015") {
choco install visualstudio2015buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended --includeOptional --passive"
} elseif ($env:msvc_version -eq "2017") {
choco install visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
} elseif ($env:msvc_version -eq "2019") {
choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
} elseif ($env:msvc_version -eq "2022") {
choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
}
$env:CC="cl.exe"
$env:CXX="cl.exe"

- name: Configure CMake
run: cmake -S . -B build_msvc_${{ matrix.msvc_version }} -G "Ninja" -DWITH_TEST=ON

- name: Build
run: cmake --build build_msvc_${{ matrix.msvc_version }} --config Release

- name: Upload Build Log
if: failure()
uses: actions/upload-artifact@v4
with:
name: windows_msvc_${{ matrix.msvc_version }}_cmake_buildlog
path: build_msvc_${{ matrix.msvc_version }}/build.ninja

build_macosx:
name: Building on macOS with Xcode ${{ matrix.xcode_version }}
runs-on: macos-latest
strategy:
matrix:
xcode_version: ["15.2", "15.3"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Xcode
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode_version }}.app

- name: Install CMake and Ninja
run: |
python -m pip install cmake ninja

- name: Configure CMake
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON

- name: Build
run: cmake --build builddir --config Release

- name: Upload Build Log
if: failure()
uses: actions/upload-artifact@v4
with:
name: macos_xcode_${{ matrix.xcode_version }}_cmake_buildlog
path: builddir/build.ninja

build_msys:
name: Building on MSYS ${{ matrix.architecture }}
runs-on: windows-latest
strategy:
matrix:
architecture: [x86, x64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
update: true

- name: Set environment variables
run: |
echo "CC=/mingw${{ matrix.architecture }}/bin/gcc.exe" >> $GITHUB_ENV
echo "CXX=/mingw${{ matrix.architecture }}/bin/g++.exe" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install CMake and Ninja
run: |
python -m pip install cmake ninja

- name: Configure CMake
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON

- name: Build
run: cmake --build builddir --config Release

- name: Upload Build Log
if: failure()
uses: actions/upload-artifact@v4
with:
name: msys_${{ matrix.architecture }}_cmake_buildlog
path: builddir/build.ninja

build_posix:
name: Build on Linux ${{ matrix.distro }}
runs-on: ubuntu-latest

strategy:
matrix:
distro: [ubuntu, fedora, archlinux, debian]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.distro }}
restore-keys: |
${{ runner.os }}-buildx

- name: Build Docker Image
run: |
docker build \
--file .github/ciimage/Dockerfile.${{ matrix.distro }} \
--tag ${GITHUB_REPOSITORY}:${{ matrix.distro }} .

- name: Run CMake Build in Docker Container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
${GITHUB_REPOSITORY}:${{ matrix.distro }} \
/bin/bash -c "
apt-get update
cmake -S . -B builddir -G Ninja -DWITH_TEST=ON
cmake --build builddir --config Release"

build_cross:
name: Building on Bedrock ${{ matrix.architecture }}
runs-on: ubuntu-latest # Using Ubuntu as the base system for cross-compilation

strategy:
matrix:
architecture: [arm, arm64, mips, mipsel, riscv64, ppc, ppc64le, sparc64, s390x]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Cross-Compilation Toolchain
run: |
sudo apt-get update
if [ "${{ matrix.architecture }}" == "arm" ]; then
sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
elif [ "${{ matrix.architecture }}" == "arm64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
elif [ "${{ matrix.architecture }}" == "mips" ]; then
sudo apt-get install -y gcc-mips-linux-gnu g++-mips-linux-gnu
elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
sudo apt-get install -y gcc-mipsel-linux-gnu g++-mipsel-linux-gnu
elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
elif [ "${{ matrix.architecture }}" == "ppc" ]; then
sudo apt-get install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu
elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
sudo apt-get install -y gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu
elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
sudo apt-get install -y gcc-sparc64-linux-gnu g++-sparc64-linux-gnu
elif [ "${{ matrix.architecture }}" == "s390x" ]; then
sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu
fi

- name: Set Cross-Compilation Environment Variables
run: |
if [ "${{ matrix.architecture }}" == "arm" ]; then
echo "CC=arm-linux-gnueabi-gcc" >> $GITHUB_ENV
echo "CXX=arm-linux-gnueabi-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "arm64" ]; then
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "mips" ]; then
echo "CC=mips-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=mips-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
echo "CC=mipsel-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=mipsel-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
echo "CC=riscv64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=riscv64-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "ppc" ]; then
echo "CC=powerpc-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=powerpc-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
echo "CC=powerpc64le-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=powerpc64le-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
echo "CC=sparc64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=sparc64-linux-gnu-g++" >> $GITHUB_ENV
elif [ "${{ matrix.architecture }}" == "s390x" ]; then
echo "CC=s390x-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=s390x-linux-gnu-g++" >> $GITHUB_ENV
fi

- name: Install CMake and Ninja
run: |
python -m pip install cmake ninja

- name: Configure CMake
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON

- name: Build
run: cmake --build builddir --config Release

- name: Upload Build Log
if: failure()
uses: actions/upload-artifact@v4
with:
name: cross_${{ matrix.architecture }}_cmake_buildlog
path: builddir/build.ninja
Loading
Loading