@@ -34,10 +34,13 @@ Commands:
34
34
dok generate docs and open in browser
35
35
36
36
Options:
37
- -h, --help print this help text
38
- --double run check with double-precision
39
- -f, --filter <arg> only run integration tests which contain any of the
40
- args (comma-separated). requires itest.
37
+ -h, --help print this help text
38
+ --double run check with double-precision
39
+ -f, --filter <arg> only run integration tests which contain any of the
40
+ args (comma-separated). requires itest.
41
+ -g, --godot-version (works only if GODOT4_BIN is not set and gdvm is
42
+ in path) specify the Godot version to use (e.g. 4.3.0).
43
+ Will also use the corresponding API feature.
41
44
42
45
Examples:
43
46
check.sh fmt clippy
@@ -78,12 +81,27 @@ function findGodot() {
78
81
# $godotBin previously detected.
79
82
if [[ -v godotBin ]]; then
80
83
return
84
+ fi
85
+
86
+ gdvmArgs=()
81
87
82
88
# User-defined GODOT4_BIN.
83
- elif [[ -n " $GODOT4_BIN " ]]; then
89
+ if [[ -n " $GODOT4_BIN " ]]; then
84
90
log " Using environment variable GODOT4_BIN=$( printf %q " $GODOT4_BIN " ) "
85
91
godotBin=" $GODOT4_BIN "
86
92
93
+ # gdvm
94
+ elif command -v gdvm > /dev/null; then
95
+ log " Found 'gdvm' executable"
96
+ godotBin=" gdvm"
97
+ gdvmArgs+=(" run" )
98
+
99
+ if [[ -n " $gdvmGodotVersion " ]]; then
100
+ gdvmArgs+=(" $gdvmGodotVersion " " --force" )
101
+ fi
102
+
103
+ gdvmArgs+=(" --console" " --" )
104
+
87
105
# Executable in path.
88
106
elif command -v godot4 > /dev/null; then
89
107
log " Found 'godot4' executable"
@@ -95,7 +113,7 @@ function findGodot() {
95
113
log " Found 'godot4.bat' script"
96
114
godotBin=" godot4.bat"
97
115
98
- # This should come last: only use this as a last resort as `godot` may refer to a
116
+ # This should come last: only use this as a last resort as `godot` may refer to a
99
117
# Godot 3.x installation.
100
118
elif command -v godot > /dev/null; then
101
119
# Check if `godot` actually is Godot 4.x
@@ -157,7 +175,7 @@ function cmd_test() {
157
175
function cmd_itest() {
158
176
findGodot && \
159
177
run cargo build -p itest " ${extraCargoArgs[@]} " && \
160
- run " $godotBin " --path itest/godot --headless -- " [${extraArgs[@]} ]"
178
+ run " $godotBin " " ${gdvmArgs[@]} " --path itest/godot --headless -- " [${extraArgs[@]} ]"
161
179
}
162
180
163
181
function cmd_doc() {
@@ -177,6 +195,7 @@ function cmd_dok() {
177
195
extraCargoArgs=(" --no-default-features" )
178
196
cmds=()
179
197
nextArgIsFilter=false
198
+ nextArgIsGodotVersion=false
180
199
extraArgs=()
181
200
182
201
for arg in " $@ " ; do
@@ -202,10 +221,27 @@ for arg in "$@"; do
202
221
exit 2
203
222
fi
204
223
;;
224
+ -g | --godot-version)
225
+ nextArgIsGodotVersion=true
226
+ ;;
205
227
* )
206
228
if $nextArgIsFilter ; then
207
229
extraArgs+=(" $arg " )
208
230
nextArgIsFilter=false
231
+ elif $nextArgIsGodotVersion ; then
232
+ gdvmGodotVersion=" $arg "
233
+ nextArgIsGodotVersion=false
234
+
235
+ if [[ ! " $gdvmGodotVersion " =~ ^4\. [0-9]+\. [0-9]+$ ]]; then
236
+ log " Invalid Godot version string '$gdvmGodotVersion '."
237
+ log " The version string should be in the form 'x.x.x' and the major version should be at least 4."
238
+ exit 2
239
+ fi
240
+
241
+ # API version is the same but with periods replaced by hyphens, and a .0 patch version is omitted if present.
242
+ # E.g. 4.3.0 -> api-4-3, 4.3.1 -> api-4-3-1
243
+ apiFeature=" godot/api-$( echo " $gdvmGodotVersion " | sed ' s/\./-/g' | sed ' s/-0$//' ) "
244
+ extraCargoArgs+=(" --features" " $apiFeature " )
209
245
else
210
246
log " Unrecognized argument '$arg '. Use '$0 --help' to see what's available."
211
247
exit 2
0 commit comments