Skip to content

Commit bbcacc6

Browse files
Merge pull request #7 from dreamer-coding/main
Updating project structure
2 parents 98e2ec1 + 520066e commit bbcacc6

File tree

15 files changed

+413
-50
lines changed

15 files changed

+413
-50
lines changed

.github/ciimage/Dockerfile.archlinux

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ RUN pacman -Syu --noconfirm && \
1111
clang \
1212
gdb \
1313
llvm \
14-
rust \
15-
cargo \
14+
cmake \
1615
wget \
1716
python \
1817
python-pip \

.github/ciimage/Dockerfile.debian

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ RUN apt-get update && \
1515
gdb \
1616
llvm \
1717
libstdc++-8-dev \
18-
rustc \
19-
cargo \
18+
cmake \
2019
wget \
2120
python3 \
2221
python3-pip \
@@ -36,4 +35,4 @@ ENV LD_LIBRARY_PATH=/usr/local/lib
3635
WORKDIR /workspace
3736

3837
# Default command
39-
CMD ["bash"]
38+
CMD ["bash"]

.github/ciimage/Dockerfile.fedora

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ENV TZ=UTC
66

77
# Install system dependencies and clean up
88
RUN dnf -y update && \
9+
dnf -y groupinstall "Development Tools" && \
910
dnf install -y \
1011
gcc \
1112
gcc-c++ \
@@ -19,9 +20,8 @@ RUN dnf -y update && \
1920
python3-pip \
2021
git && \
2122
dnf clean all
22-
2323
# Install Meson and Ninja using pip
24-
RUN python3 -m pip install --no-cache-dir meson ninja
24+
RUN python3 -m pip install --no-cache-dir cmake meson ninja
2525

2626
# Set environment variables
2727
ENV CC=/usr/bin/clang

.github/ciimage/Dockerfile.ubuntu

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,20 @@ RUN apt-get update && \
1414
g++ \
1515
gdb \
1616
llvm \
17-
gobjc \
18-
gobjc++ \
19-
libobjc-10-dev \
2017
libstdc++-10-dev \
2118
rustc \
2219
cargo \
23-
dub \
2420
wget \
2521
python3 \
2622
python3-pip \
27-
git && \
23+
git \
24+
tzdata && \
2825
apt-get clean && \
2926
rm -rf /var/lib/apt/lists/*
3027

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

3430
# Set environment variables
3531
ENV CC=/usr/bin/gcc
3632
ENV CXX=/usr/bin/g++
37-
ENV LD_LIBRARY_PATH=/usr/local/lib
33+
ENV LD_LIBRARY_PATH=/usr/local/lib

.github/workflows/cmake_ci.yml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
name: CMake CI
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.c"
7+
- "**.h"
8+
- "**.cpp"
9+
- "**.hpp"
10+
- "**.py"
11+
- "**.build"
12+
- "**.options"
13+
pull_request:
14+
paths:
15+
- "**.c"
16+
- "**.h"
17+
- "**.cpp"
18+
- "**.hpp"
19+
- "**.py"
20+
- "**.build"
21+
- "**.options"
22+
23+
jobs:
24+
build_msvc:
25+
name: Building on MSVC ${{ matrix.msvc_version }}
26+
runs-on: windows-latest
27+
strategy:
28+
matrix:
29+
msvc_version: [2015, 2017, 2019, 2022]
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.12'
40+
41+
- name: Install CMake and Ninja
42+
shell: pwsh
43+
run: |
44+
python -m pip install --upgrade pip
45+
python -m pip install cmake ninja
46+
if ($env:msvc_version -eq "2015") {
47+
choco install visualstudio2015buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended --includeOptional --passive"
48+
} elseif ($env:msvc_version -eq "2017") {
49+
choco install visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
50+
} elseif ($env:msvc_version -eq "2019") {
51+
choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
52+
} elseif ($env:msvc_version -eq "2022") {
53+
choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive"
54+
}
55+
$env:CC="cl.exe"
56+
$env:CXX="cl.exe"
57+
58+
- name: Configure CMake
59+
run: cmake -S . -B build_msvc_${{ matrix.msvc_version }} -G "Ninja" -DWITH_TEST=ON
60+
61+
- name: Build
62+
run: cmake --build build_msvc_${{ matrix.msvc_version }} --config Release
63+
64+
- name: Upload Build Log
65+
if: failure()
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: windows_msvc_${{ matrix.msvc_version }}_cmake_buildlog
69+
path: build_msvc_${{ matrix.msvc_version }}/build.ninja
70+
71+
build_macosx:
72+
name: Building on macOS with Xcode ${{ matrix.xcode_version }}
73+
runs-on: macos-latest
74+
strategy:
75+
matrix:
76+
xcode_version: ["15.2", "15.3"]
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v5
85+
with:
86+
python-version: '3.12'
87+
88+
- name: Install Xcode
89+
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode_version }}.app
90+
91+
- name: Install CMake and Ninja
92+
run: |
93+
python -m pip install cmake ninja
94+
95+
- name: Configure CMake
96+
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
97+
98+
- name: Build
99+
run: cmake --build builddir --config Release
100+
101+
- name: Upload Build Log
102+
if: failure()
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: macos_xcode_${{ matrix.xcode_version }}_cmake_buildlog
106+
path: builddir/build.ninja
107+
108+
build_msys:
109+
name: Building on MSYS ${{ matrix.architecture }}
110+
runs-on: windows-latest
111+
strategy:
112+
matrix:
113+
architecture: [x86, x64]
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v4
117+
with:
118+
fetch-depth: 0
119+
120+
- name: Set up MSYS2
121+
uses: msys2/setup-msys2@v2
122+
with:
123+
update: true
124+
125+
- name: Set environment variables
126+
run: |
127+
echo "CC=/mingw${{ matrix.architecture }}/bin/gcc.exe" >> $GITHUB_ENV
128+
echo "CXX=/mingw${{ matrix.architecture }}/bin/g++.exe" >> $GITHUB_ENV
129+
130+
- name: Set up Python
131+
uses: actions/setup-python@v5
132+
with:
133+
python-version: '3.12'
134+
135+
- name: Install CMake and Ninja
136+
run: |
137+
python -m pip install cmake ninja
138+
139+
- name: Configure CMake
140+
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
141+
142+
- name: Build
143+
run: cmake --build builddir --config Release
144+
145+
- name: Upload Build Log
146+
if: failure()
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: msys_${{ matrix.architecture }}_cmake_buildlog
150+
path: builddir/build.ninja
151+
152+
build_posix:
153+
name: Build on Linux ${{ matrix.distro }}
154+
runs-on: ubuntu-latest
155+
156+
strategy:
157+
matrix:
158+
distro: [ubuntu, fedora, archlinux, debian]
159+
160+
steps:
161+
- name: Checkout code
162+
uses: actions/checkout@v4
163+
with:
164+
fetch-depth: 0
165+
166+
- name: Set up Docker Buildx
167+
uses: docker/setup-buildx-action@v3
168+
169+
- name: Cache Docker layers
170+
uses: actions/cache@v4
171+
with:
172+
path: /tmp/.buildx-cache
173+
key: ${{ runner.os }}-buildx-${{ matrix.distro }}
174+
restore-keys: |
175+
${{ runner.os }}-buildx
176+
177+
- name: Build Docker Image
178+
run: |
179+
docker build \
180+
--file .github/ciimage/Dockerfile.${{ matrix.distro }} \
181+
--tag ${GITHUB_REPOSITORY}:${{ matrix.distro }} .
182+
183+
- name: Run CMake Build in Docker Container
184+
run: |
185+
docker run --rm \
186+
-v ${{ github.workspace }}:/workspace \
187+
-w /workspace \
188+
${GITHUB_REPOSITORY}:${{ matrix.distro }} \
189+
/bin/bash -c "
190+
apt-get update
191+
cmake -S . -B builddir -G Ninja -DWITH_TEST=ON
192+
cmake --build builddir --config Release"
193+
194+
build_cross:
195+
name: Building on Bedrock ${{ matrix.architecture }}
196+
runs-on: ubuntu-latest # Using Ubuntu as the base system for cross-compilation
197+
198+
strategy:
199+
matrix:
200+
architecture: [arm, arm64, mips, mipsel, riscv64, ppc, ppc64le, sparc64, s390x]
201+
202+
steps:
203+
- name: Checkout code
204+
uses: actions/checkout@v4
205+
with:
206+
fetch-depth: 0
207+
208+
- name: Set up Python
209+
uses: actions/setup-python@v5
210+
with:
211+
python-version: '3.12'
212+
213+
- name: Install Cross-Compilation Toolchain
214+
run: |
215+
sudo apt-get update
216+
if [ "${{ matrix.architecture }}" == "arm" ]; then
217+
sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
218+
elif [ "${{ matrix.architecture }}" == "arm64" ]; then
219+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
220+
elif [ "${{ matrix.architecture }}" == "mips" ]; then
221+
sudo apt-get install -y gcc-mips-linux-gnu g++-mips-linux-gnu
222+
elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
223+
sudo apt-get install -y gcc-mipsel-linux-gnu g++-mipsel-linux-gnu
224+
elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
225+
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
226+
elif [ "${{ matrix.architecture }}" == "ppc" ]; then
227+
sudo apt-get install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu
228+
elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
229+
sudo apt-get install -y gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu
230+
elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
231+
sudo apt-get install -y gcc-sparc64-linux-gnu g++-sparc64-linux-gnu
232+
elif [ "${{ matrix.architecture }}" == "s390x" ]; then
233+
sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu
234+
fi
235+
236+
- name: Set Cross-Compilation Environment Variables
237+
run: |
238+
if [ "${{ matrix.architecture }}" == "arm" ]; then
239+
echo "CC=arm-linux-gnueabi-gcc" >> $GITHUB_ENV
240+
echo "CXX=arm-linux-gnueabi-g++" >> $GITHUB_ENV
241+
elif [ "${{ matrix.architecture }}" == "arm64" ]; then
242+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
243+
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
244+
elif [ "${{ matrix.architecture }}" == "mips" ]; then
245+
echo "CC=mips-linux-gnu-gcc" >> $GITHUB_ENV
246+
echo "CXX=mips-linux-gnu-g++" >> $GITHUB_ENV
247+
elif [ "${{ matrix.architecture }}" == "mipsel" ]; then
248+
echo "CC=mipsel-linux-gnu-gcc" >> $GITHUB_ENV
249+
echo "CXX=mipsel-linux-gnu-g++" >> $GITHUB_ENV
250+
elif [ "${{ matrix.architecture }}" == "riscv64" ]; then
251+
echo "CC=riscv64-linux-gnu-gcc" >> $GITHUB_ENV
252+
echo "CXX=riscv64-linux-gnu-g++" >> $GITHUB_ENV
253+
elif [ "${{ matrix.architecture }}" == "ppc" ]; then
254+
echo "CC=powerpc-linux-gnu-gcc" >> $GITHUB_ENV
255+
echo "CXX=powerpc-linux-gnu-g++" >> $GITHUB_ENV
256+
elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then
257+
echo "CC=powerpc64le-linux-gnu-gcc" >> $GITHUB_ENV
258+
echo "CXX=powerpc64le-linux-gnu-g++" >> $GITHUB_ENV
259+
elif [ "${{ matrix.architecture }}" == "sparc64" ]; then
260+
echo "CC=sparc64-linux-gnu-gcc" >> $GITHUB_ENV
261+
echo "CXX=sparc64-linux-gnu-g++" >> $GITHUB_ENV
262+
elif [ "${{ matrix.architecture }}" == "s390x" ]; then
263+
echo "CC=s390x-linux-gnu-gcc" >> $GITHUB_ENV
264+
echo "CXX=s390x-linux-gnu-g++" >> $GITHUB_ENV
265+
fi
266+
267+
- name: Install CMake and Ninja
268+
run: |
269+
python -m pip install cmake ninja
270+
271+
- name: Configure CMake
272+
run: cmake -S . -B builddir -G "Ninja" -DWITH_TEST=ON
273+
274+
- name: Build
275+
run: cmake --build builddir --config Release
276+
277+
- name: Upload Build Log
278+
if: failure()
279+
uses: actions/upload-artifact@v4
280+
with:
281+
name: cross_${{ matrix.architecture }}_cmake_buildlog
282+
path: builddir/build.ninja

0 commit comments

Comments
 (0)