Skip to content

Commit 799e4aa

Browse files
committed
Add api_version build option to select the API JSON file
1 parent fe68c22 commit 799e4aa

File tree

5 files changed

+519421
-172611
lines changed

5 files changed

+519421
-172611
lines changed

.github/workflows/ci-scons.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
env:
66
# Only used for the cache key. Increment version to force clean build.
77
GODOT_BASE_BRANCH: master
8-
# Used to select the version of Godot to run the tests with.
9-
GODOT_TEST_VERSION: master
108
# Use UTF-8 on Linux.
119
LANG: en_US.UTF-8
1210
LC_ALL: en_US.UTF-8
@@ -33,6 +31,16 @@ jobs:
3331
run-tests: true
3432
cache-name: linux-x86_64
3533

34+
- name: 🐧 Linux (GCC) for Godot 4.5
35+
os: ubuntu-22.04
36+
platform: linux
37+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release-godot45
38+
artifact-path: bin/libgodot-cpp.linux.template_release.x86_64.a
39+
run-tests: true
40+
api-version: 4.5
41+
godot-test-versions: "4.5-stable"
42+
cache-name: linux-x86_64-godot45
43+
3644
- name: 🏁 Windows (x86_64, MSVC)
3745
os: windows-2022
3846
platform: windows
@@ -110,22 +118,23 @@ jobs:
110118

111119
- name: Generate godot-cpp sources only
112120
run: |
113-
scons platform=${{ matrix.platform }} verbose=yes build_library=no ${{ matrix.flags }}
121+
scons platform=${{ matrix.platform }} verbose=yes build_library=no ${{ matrix.flags }} ${{ matrix.api-version && format('api_version={0}', matrix.api-version) || '' }}
114122
scons -c
115123
116124
- name: Build godot-cpp (debug)
117125
run: |
118-
scons platform=${{ matrix.platform }} verbose=yes target=template_debug ${{ matrix.flags }}
126+
scons platform=${{ matrix.platform }} verbose=yes target=template_debug ${{ matrix.flags }} ${{ matrix.api-version && format('api_version={0}', matrix.api-version) || '' }}
127+
119128
120129
- name: Build test without rebuilding godot-cpp (debug)
121130
run: |
122131
cd test
123-
scons platform=${{ matrix.platform }} verbose=yes target=template_debug ${{ matrix.flags }} build_library=no
132+
scons platform=${{ matrix.platform }} verbose=yes build_library=no target=template_debug ${{ matrix.flags }} ${{ matrix.api-version && format('api_version={0}', matrix.api-version) || '' }}
124133
125134
- name: Build test and godot-cpp (release)
126135
run: |
127136
cd test
128-
scons platform=${{ matrix.platform }} verbose=yes target=template_release ${{ matrix.flags }}
137+
scons platform=${{ matrix.platform }} verbose=yes target=template_release ${{ matrix.flags }} ${{ matrix.api-version && format('api_version={0}', matrix.api-version) || '' }}
129138
130139
- name: Save Godot build cache
131140
uses: ./.github/actions/godot-cache-save
@@ -135,7 +144,7 @@ jobs:
135144

136145
- name: Download latest Godot artifacts
137146
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
138-
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
147+
if: matrix.run-tests
139148
with:
140149
repo: godotengine/godot
141150
branch: master
@@ -149,27 +158,38 @@ jobs:
149158
path: godot-artifacts
150159

151160
- name: Prepare Godot artifacts for testing
152-
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
161+
if: matrix.run-tests
153162
run: |
154-
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
155-
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
163+
mkdir ./godot-builds
164+
mv ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono ./godot-builds/godot-master
165+
mv ./godot-artifacts/GodotSharp ./godot-builds/
166+
chmod +x ./godot-builds/godot-master
156167
157-
- name: Download requested Godot version for testing
158-
if: matrix.run-tests && env.GODOT_TEST_VERSION != 'master'
168+
- name: Download supported Godot versions for testing
169+
if: matrix.run-tests && matrix.godot-test-versions
159170
run: |
160-
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
161-
unzip -a Godot.zip
162-
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
163-
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
171+
for version in ${{ matrix.godot-test-versions }}; do
172+
wget "https://github.com/godotengine/godot-builds/releases/download/${version}/Godot_v${version}_linux.x86_64.zip" -O Godot.zip
173+
unzip -a Godot.zip
174+
mv "Godot_v${version}_linux.x86_64" "./godot-builds/godot-${version}"
175+
chmod +x "./godot-builds/godot-${version}"
176+
rm Godot.zip
177+
done
164178
165179
- name: Run tests
166180
if: matrix.run-tests
167181
run: |
168-
$GODOT --headless --version
182+
GODOT_BUILDS="$(pwd)/godot-builds"
169183
cd test
170-
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
171-
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
172-
./run-tests.sh
184+
for version in ${{ matrix.godot-test-versions }} master; do
185+
rm -rf ./project/.godot
186+
export GODOT="${GODOT_BUILDS}/godot-${version}"
187+
$GODOT --headless --version
188+
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
189+
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
190+
./run-tests.sh
191+
done
192+
cd ..
173193
174194
- name: Upload artifact
175195
uses: actions/upload-artifact@v4

cmake/godotcpp.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ function(godotcpp_options)
114114
set_property(CACHE GODOTCPP_TARGET PROPERTY STRINGS "template_debug;template_release;editor")
115115

116116
# Input from user for GDExtension interface header and the API JSON file
117+
set(GODOTCPP_API_VERSION
118+
""
119+
CACHE STRING
120+
"The Godot API version to target (ex \"4.5\") using one of the included API JSON files"
121+
)
122+
set_property(CACHE GODOTCPP_API_VERSION PROPERTY STRINGS ";4.5;4.6")
117123
set(GODOTCPP_GDEXTENSION_DIR
118124
"gdextension"
119125
CACHE PATH
@@ -122,7 +128,7 @@ function(godotcpp_options)
122128
set(GODOTCPP_CUSTOM_API_FILE
123129
""
124130
CACHE FILEPATH
125-
"Path to a custom GDExtension API JSON file (takes precedence over `GODOTCPP_GDEXTENSION_DIR`) ( /path/to/custom_api_file )"
131+
"Path to a custom GDExtension API JSON file (takes precedence over `GODOTCPP_GDEXTENSION_DIR` and `GODOTCPP_API_VERSION`) ( /path/to/custom_api_file )"
126132
)
127133

128134
#TODO generate_bindings
@@ -244,7 +250,15 @@ function(godotcpp_generate)
244250
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8") # CMAKE_SIZEOF_VOID_P refers to target architecture.
245251

246252
# API json File
247-
set(GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_GDEXTENSION_DIR}/extension_api.json")
253+
set(GODOTCPP_LATEST_API_VERSION "4.6")
254+
if(GODOTCPP_API_VERSION STREQUAL "" OR GODOTCPP_API_VERSION STREQUAL GODOTCPP_LATEST_API_VERSION)
255+
set(GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_GDEXTENSION_DIR}/extension_api.json")
256+
else()
257+
string(REPLACE "." "-" GODOTCPP_API_VERSION_DASHED "${GODOTCPP_API_VERSION}")
258+
set(GODOTCPP_GDEXTENSION_API_FILE
259+
"${GODOTCPP_GDEXTENSION_DIR}/extension_api-${GODOTCPP_API_VERSION_DASHED}.json"
260+
)
261+
endif()
248262
if(GODOTCPP_CUSTOM_API_FILE) # User-defined override.
249263
set(GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_CUSTOM_API_FILE}")
250264
endif()

0 commit comments

Comments
 (0)