Skip to content

Commit 5c97ef8

Browse files
committed
CMake: Update CI
- Duplicated the ci.yml into ci-scons.yml and ci-cmake.yml - Replaced some manual shell commands to detect changes with tj-actions/changed-files@v45 - Conditionally run the CI depending on what files change. - Add ios toolchain from leetal/ios-cmake - Added a cmake-minimum of 3.10 to silence errors from ios toolchain
1 parent f83f364 commit 5c97ef8

File tree

8 files changed

+1408
-58
lines changed

8 files changed

+1408
-58
lines changed

.github/actions/setup-godot-cpp/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ inputs:
2222
ndk-version:
2323
default: r23c
2424
description: Android NDK version.
25+
buildtool:
26+
description: scons or cmake
2527
scons-version:
2628
default: 4.4.0
2729
description: SCons version.
2830

31+
2932
runs:
3033
using: composite
3134
steps:
@@ -55,8 +58,13 @@ runs:
5558
version: ${{ inputs.mingw-version }}
5659

5760
- name: Setup SCons
61+
if: ${{ inputs.buildtool == 'scons' }}
5862
shell: bash
5963
run: |
6064
python -c "import sys; print(sys.version)"
6165
python -m pip install scons==${{ inputs.scons-version }}
6266
scons --version
67+
68+
- name: Install Ninja
69+
if: ${{ inputs.buildtool == 'cmake' }}
70+
uses: ashutoshvarma/setup-ninja@master

.github/workflows/ci-cmake.yml

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Continuous integration
2+
on:
3+
workflow_call:
4+
5+
env:
6+
# Only used for the cache key. Increment version to force clean build.
7+
GODOT_BASE_BRANCH: master
8+
# Used to select the version of Godot to run the tests with.
9+
GODOT_TEST_VERSION: master
10+
# Use UTF-8 on Linux.
11+
LANG: en_US.UTF-8
12+
LC_ALL: en_US.UTF-8
13+
14+
concurrency:
15+
group: ci-cmake-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build-cmake:
20+
name: ${{ matrix.name }}
21+
runs-on: ${{ matrix.os }}
22+
env:
23+
EM_VERSION: 3.1.39
24+
config-flags:
25+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
26+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
27+
-DGODOTCPP_ENABLE_TESTING=ON
28+
-DGODOTCPP_BUILD_PROFILE="test/build_profile.json"
29+
SCCACHE_GHA_ENABLED: "true"
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- name: 🐧 Linux (GCC, Makefiles)
36+
os: ubuntu-22.04
37+
platform: linux
38+
config-flags: -DCMAKE_BUILD_TYPE=Release
39+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release.cmake
40+
artifact-path: cmake-build/bin/libgodot-cpp.linux.template_release.x86_64.a
41+
run-tests: true
42+
43+
- name: 🐧 Linux (GCC, Makefiles, Double Precision)
44+
os: ubuntu-22.04
45+
platform: linux
46+
config-flags: -DCMAKE_BUILD_TYPE=Release -DGODOTCPP_PRECISION=double
47+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-double-release.cmake
48+
artifact-path: cmake-build/bin/libgodot-cpp.linux.template_release.double.x86_64.a
49+
flags: precision=double
50+
run-tests: false
51+
52+
- name: 🏁 Windows (x86_64, MSVC)
53+
os: windows-2019
54+
platform: windows
55+
compiler: msvc
56+
build-flags: --config Release
57+
artifact-name: godot-cpp-windows-msvc2019-x86_64-release.cmake
58+
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.lib
59+
run-tests: false
60+
61+
- name: 🏁 Windows (x86_64, MinGW, Ninja)
62+
os: windows-2019
63+
platform: windows
64+
compiler: mingw
65+
config-flags:
66+
-GNinja -DCMAKE_BUILD_TYPE=Release
67+
-DCMAKE_CXX_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
68+
artifact-name: godot-cpp-linux-mingw-x86_64-release.cmake
69+
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.a
70+
run-tests: false
71+
72+
- name: 🍎 macOS (universal, Makefiles)
73+
os: macos-latest
74+
platform: macos
75+
config-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
76+
artifact-name: godot-cpp-macos-universal-release.cmake
77+
artifact-path: cmake-build/bin/libgodot-cpp.macos.template_release.universal.a
78+
run-tests: false
79+
80+
- name: 🤖 Android (arm64, Ninja)
81+
os: ubuntu-22.04
82+
platform: android
83+
config-flags:
84+
-G Ninja -DCMAKE_BUILD_TYPE=Release
85+
--toolchain ${ANDROID_HOME}/ndk/23.2.8568313/build/cmake/android.toolchain.cmake
86+
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a
87+
artifact-name: godot-cpp-android-arm64-release.cmake
88+
artifact-path: cmake-build/bin/libgodot-cpp.android.template_release.arm64.a
89+
flags: arch=arm64
90+
run-tests: false
91+
92+
- name: 🍏 iOS (arm64, XCode)
93+
os: macos-latest
94+
platform: ios
95+
config-flags:
96+
-G Xcode
97+
--toolchain cmake/ios.toolchain.cmake
98+
-DPLATFORM=OS64
99+
build-flags: --config Release
100+
artifact-name: godot-cpp-ios-arm64-release.cmake
101+
artifact-path: cmake-build/bin/libgodot-cpp.ios.template_release.arm64.a
102+
flags: arch=arm64
103+
run-tests: false
104+
105+
- name: 🌐 Web (wasm32, Ninja)
106+
os: ubuntu-22.04
107+
platform: web
108+
config-flags:
109+
-G Ninja -DCMAKE_BUILD_TYPE=Release
110+
--toolchain ${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
111+
artifact-name: godot-cpp-web-wasm32-release.cmake
112+
artifact-path: cmake-build/bin/libgodot-cpp.web.template_release.wasm32.a
113+
run-tests: false
114+
115+
steps:
116+
- name: Checkout
117+
uses: actions/checkout@v4
118+
with:
119+
submodules: recursive
120+
121+
- name: Run sccache-cache
122+
uses: mozilla-actions/[email protected]
123+
124+
- name: Setup godot-cpp
125+
uses: ./.github/actions/setup-godot-cpp
126+
with:
127+
platform: ${{ matrix.platform }}
128+
windows-compiler: ${{ matrix.compiler }}
129+
buildtool: cmake
130+
131+
- name: Configure godot-cpp-test with template_debug
132+
run: >
133+
cmake --log-level=VERBOSE -S . -B cmake-build ${{ env.config-flags }} ${{ matrix.config-flags }}
134+
135+
- name: Build godot-cpp-test (template_debug)
136+
run: >
137+
cmake --build cmake-build --verbose --target godot-cpp-test ${{ matrix.build-flags }}
138+
139+
- name: Configure godot-cpp-test with template_release
140+
run: >
141+
cmake --fresh --log-level=VERBOSE -S . -B cmake-build
142+
-DGODOTCPP_TARGET=template_release ${{ env.config-flags }} ${{ matrix.config-flags }}
143+
144+
- name: Build godot-cpp-test (template_release)
145+
run: >
146+
cmake --build cmake-build --verbose --target godot-cpp-test ${{ matrix.build-flags }}
147+
148+
- name: Run sccache stat for check
149+
shell: bash
150+
run: ${SCCACHE_PATH} --show-stats
151+
152+
- name: Download latest Godot artifacts
153+
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
154+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
155+
with:
156+
repo: godotengine/godot
157+
branch: master
158+
event: push
159+
workflow: linux_builds.yml
160+
workflow_conclusion: success
161+
name: linux-editor-mono
162+
search_artifacts: true
163+
check_artifacts: true
164+
ensure_latest: true
165+
path: godot-artifacts
166+
167+
- name: Prepare Godot artifacts for testing
168+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
169+
run: |
170+
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
171+
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
172+
173+
- name: Download requested Godot version for testing
174+
if: matrix.run-tests && env.GODOT_TEST_VERSION != 'master'
175+
run: |
176+
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
177+
unzip -a Godot.zip
178+
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
179+
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
180+
181+
- name: Run tests
182+
if: matrix.run-tests
183+
run: |
184+
$GODOT --headless --version
185+
cd test
186+
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
187+
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
188+
./run-tests.sh
189+
190+
- name: Upload artifact
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: ${{ matrix.artifact-name }}
194+
path: ${{ matrix.artifact-path }}
195+
if-no-files-found: error

.github/workflows/ci.yml renamed to .github/workflows/ci-scons.yml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ env:
1212
LC_ALL: en_US.UTF-8
1313

1414
concurrency:
15-
group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
15+
group: ci-scons-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

1818
jobs:
19-
build:
19+
build-scons:
2020
name: ${{ matrix.name }}
2121
runs-on: ${{ matrix.os }}
2222
strategy:
@@ -113,6 +113,7 @@ jobs:
113113
with:
114114
platform: ${{ matrix.platform }}
115115
windows-compiler: ${{ contains(matrix.flags, 'use_mingw=yes') && 'mingw' || 'msvc' }}
116+
buildtool: scons
116117

117118
- name: Generate godot-cpp sources only
118119
run: |
@@ -183,40 +184,3 @@ jobs:
183184
name: ${{ matrix.artifact-name }}
184185
path: ${{ matrix.artifact-path }}
185186
if-no-files-found: error
186-
187-
linux-cmake-ninja:
188-
name: 🐧 Build (Linux, GCC, CMake Ninja)
189-
runs-on: ubuntu-22.04
190-
steps:
191-
- name: Checkout
192-
uses: actions/checkout@v4
193-
with:
194-
submodules: recursive
195-
196-
- name: Install dependencies
197-
run: |
198-
sudo apt-get update -qq
199-
sudo apt-get install -qqq build-essential pkg-config cmake ninja-build
200-
201-
- name: Build test GDExtension library
202-
run: |
203-
mkdir cmake-build
204-
cd cmake-build
205-
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES -DGODOTCPP_TARGET=template_release
206-
cmake --build . --verbose -j $(nproc) --target godot-cpp-test --config Release
207-
208-
windows-msvc-cmake:
209-
name: 🏁 Build (Windows, MSVC, CMake)
210-
runs-on: windows-2019
211-
steps:
212-
- name: Checkout
213-
uses: actions/checkout@v4
214-
with:
215-
submodules: recursive
216-
217-
- name: Build test GDExtension library
218-
run: |
219-
mkdir cmake-build
220-
cd cmake-build
221-
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES -DGODOTCPP_TARGET=template_release
222-
cmake --build . --verbose --target godot-cpp-test --config Release

.github/workflows/runner.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,57 @@ jobs:
99
# First stage: Only static checks, fast and prevent expensive builds from running.
1010

1111
static-checks:
12-
if: '!vars.DISABLE_GODOT_CI'
1312
name: 📊 Static Checks
13+
if: '!vars.DISABLE_GODOT_CI'
1414
uses: ./.github/workflows/static_checks.yml
1515

16-
# Second stage: Run all the builds and some of the tests.
17-
18-
ci:
19-
name: 🛠️ Continuous Integration
16+
# Second stage: Review code changes
17+
changes:
18+
name: Analyze Changes
2019
needs: static-checks
21-
uses: ./.github/workflows/ci.yml
20+
runs-on: ubuntu-latest
21+
outputs:
22+
sources: ${{ steps.filter.outputs.sources_any_changed }}
23+
scons: ${{ steps.filter.outputs.scons_any_changed }}
24+
cmake: ${{ steps.filter.outputs.cmake_any_changed }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
- uses: tj-actions/changed-files@v45
30+
id: filter
31+
with:
32+
files_yaml: |
33+
sources:
34+
- '.github/workflows/*.yml'
35+
- '**/*.py'
36+
- '**/*.cpp'
37+
- '**/*.h'
38+
- 'test/build_profile.json'
39+
- 'gdextension/extension_api.json'
40+
scons:
41+
- '**/SConstruct'
42+
- '**/SCsub'
43+
- '**/*.py'
44+
cmake:
45+
- '**/CMakeLists.txt'
46+
- '**/*.cmake'
47+
- name: echo sources changed
48+
run: |
49+
echo sources ${{ steps.filter.outputs.sources_any_modified }}
50+
echo scons ${{ steps.filter.outputs.scons_any_modified }}
51+
echo cmake ${{ steps.filter.outputs.cmake_any_modified }}
52+
53+
# Third stage: Run all the builds and some of the tests.
54+
55+
ci-scons:
56+
name: 🛠️ SCons CI
57+
needs: changes
58+
if: ${{ needs.changes.outputs.scons == 'true' || needs.changes.outputs.sources == 'true' }}
59+
uses: ./.github/workflows/ci-scons.yml
60+
61+
ci-cmake:
62+
name: 🛠️ CMake CI
63+
needs: changes
64+
if: ${{ needs.changes.outputs.cmake == 'true' || needs.changes.outputs.sources == 'true' }}
65+
uses: ./.github/workflows/ci-cmake.yml

.github/workflows/static_checks.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ jobs:
1717
fetch-depth: 2
1818

1919
- name: Get changed files
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
run: |
23-
if [ "${{ github.event_name }}" == "pull_request" ]; then
24-
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
25-
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
26-
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
27-
fi
28-
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
29-
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
20+
id: changed-files
21+
uses: tj-actions/changed-files@v45
3022

3123
- name: Style checks via pre-commit
3224
uses: pre-commit/[email protected]
3325
with:
34-
extra_args: --verbose --hook-stage manual --files ${{ env.CHANGED_FILES }}
26+
extra_args: --verbose --hook-stage manual --files ${{ steps.changed-files.outputs.all_changed_files }}
3527

3628
- name: Check generated files consistency
3729
run:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.17)
1+
cmake_minimum_required(VERSION 3.10...3.17)
22

33
#[=======================================================================[.rst:
44

cmake/godotcpp.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function(godotcpp_generate)
276276
string(
277277
CONCAT
278278
SYSTEM_NAME
279-
"$<$<PLATFORM_ID:Android>:android.${ANDROID_ABI}>"
279+
"$<$<PLATFORM_ID:Android>:android>"
280280
"$<$<PLATFORM_ID:iOS>:ios>"
281281
"$<$<PLATFORM_ID:Linux>:linux>"
282282
"$<$<PLATFORM_ID:Darwin>:macos>"

0 commit comments

Comments
 (0)