@@ -34,10 +34,11 @@ 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
+ -a, --api-version <ver> specify the Godot API version to use (e.g. 4.3, 4.3.1).
41
42
42
43
Examples:
43
44
check.sh fmt clippy
@@ -61,6 +62,22 @@ function log() {
61
62
echo " $@ " >&2
62
63
}
63
64
65
+ # Converts a x.x.x version string to a feature string.
66
+ # e.g. 4.3.0 -> godot/api-4-3, 4.3.1 -> godot/api-4-3-1
67
+ function version_to_feature() {
68
+ echo " godot/api-$( echo " $1 " | sed ' s/\./-/g' | sed ' s/-0$//' ) "
69
+ }
70
+
71
+ # Validates that the given string is a valid x.x.x version string.
72
+ # Allow for .0 to be dropped (e.g. 4.3 is equivalent to 4.3.0).
73
+ function validate_version_string() {
74
+ if [[ ! " $1 " =~ ^4\. [0-9]+ (\. [0-9]+)? $ ]]; then
75
+ log " Invalid Godot version string '$1 '."
76
+ log " The version string should be in the form 'x.x.x' or 'x.x' and the major version should be at least 4."
77
+ exit 2
78
+ fi
79
+ }
80
+
64
81
# Echoes the given command to stderr, then executes it.
65
82
function run() {
66
83
# https://stackoverflow.com/a/76153233/14637
@@ -78,9 +95,10 @@ function findGodot() {
78
95
# $godotBin previously detected.
79
96
if [[ -v godotBin ]]; then
80
97
return
98
+ fi
81
99
82
100
# User-defined GODOT4_BIN.
83
- elif [[ -n " $GODOT4_BIN " ]]; then
101
+ if [[ -n " $GODOT4_BIN " ]]; then
84
102
log " Using environment variable GODOT4_BIN=$( printf %q " $GODOT4_BIN " ) "
85
103
godotBin=" $GODOT4_BIN "
86
104
@@ -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 " $GODOT_ARGS --path itest/godot --headless -- " [${extraArgs[@]} ]"
161
179
}
162
180
163
181
function cmd_doc() {
@@ -176,10 +194,11 @@ function cmd_dok() {
176
194
# `itest` compilations and `check.sh` runs. Note that this means some runs are different from CI.
177
195
extraCargoArgs=(" --no-default-features" )
178
196
cmds=()
179
- nextArgIsFilter=false
180
197
extraArgs=()
198
+ apiVersion=" "
181
199
182
- for arg in " $@ " ; do
200
+ while [[ $# -gt 0 ]]; do
201
+ arg=" $1 "
183
202
case " $arg " in
184
203
-h | --help | help)
185
204
echo " $HELP_TEXT "
@@ -196,22 +215,39 @@ for arg in "$@"; do
196
215
;;
197
216
-f | --filter)
198
217
if [[ " ${cmds[*]} " =~ itest ]]; then
199
- nextArgIsFilter=true
218
+ if [[ -z " $2 " ]]; then
219
+ log " -f/--filter requires an argument."
220
+ exit 2
221
+ fi
222
+
223
+ extraArgs+=(" $2 " )
224
+ shift
200
225
else
201
226
log " -f/--filter requires 'itest' to be specified as a command."
202
227
exit 2
203
228
fi
204
229
;;
205
- * )
206
- if $nextArgIsFilter ; then
207
- extraArgs+=(" $arg " )
208
- nextArgIsFilter=false
209
- else
210
- log " Unrecognized argument '$arg '. Use '$0 --help' to see what's available."
230
+ -a | --api-version)
231
+ if [[ -z " $2 " || " $2 " == -* ]]; then
232
+ log " -a/--api-version requires an argument."
211
233
exit 2
212
234
fi
235
+
236
+ apiVersion=" $2 "
237
+ validate_version_string " $apiVersion "
238
+
239
+ apiFeature=$( version_to_feature " $apiVersion " )
240
+ extraCargoArgs+=(" --features" " $apiFeature " )
241
+
242
+ echo " Using Godot API version $apiVersion with feature $apiFeature "
243
+ shift
244
+ ;;
245
+ * )
246
+ log " Unrecognized argument '$arg '. Use '$0 --help' to see what's available."
247
+ exit 2
213
248
;;
214
249
esac
250
+ shift
215
251
done
216
252
217
253
# Default if no commands are explicitly given.
0 commit comments