8
8
SDKCONFIG_DIR=" tools/esp32-arduino-libs"
9
9
fi
10
10
11
+ check_requirements (){ # check_requirements <sketchdir> <sdkconfig_path>
12
+ local sketchdir=$1
13
+ local sdkconfig_path=$2
14
+
15
+ # Check if the sketch requires any configuration options (AND)
16
+ local requirements=$( jq -r ' .requires[]? // empty' " $sketchdir /ci.json" )
17
+ if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
18
+ for requirement in $requirements ; do
19
+ requirement=$( echo $requirement | xargs)
20
+ found_line=$( grep -E " ^$requirement " " $sdkconfig_path " )
21
+ if [[ " $found_line " == " " ]]; then
22
+ return 0
23
+ fi
24
+ done
25
+ fi
26
+
27
+ # Check if the sketch requires any configuration options (OR)
28
+ local requirements_or=$( jq -r ' .requires_any[]? // empty' " $sketchdir /ci.json" )
29
+ if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
30
+ local found=false
31
+ for requirement in $requirements_or ; do
32
+ requirement=$( echo $requirement | xargs)
33
+ found_line=$( grep -E " ^$requirement " " $sdkconfig_path " )
34
+ if [[ " $found_line " != " " ]]; then
35
+ found=true
36
+ break
37
+ fi
38
+ done
39
+ if [[ " $found " == " false" ]]; then
40
+ return 0
41
+ fi
42
+ fi
43
+
44
+ return 1
45
+ }
46
+
11
47
function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [extra-options]
12
48
while [ ! -z " $1 " ]; do
13
49
case " $1 " in
@@ -171,35 +207,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
171
207
exit 0
172
208
fi
173
209
174
- # Check if the sketch requires any configuration options (AND)
175
- requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
176
- if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
177
- for requirement in $requirements ; do
178
- requirement=$( echo $requirement | xargs)
179
- found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
180
- if [[ " $found_line " == " " ]]; then
181
- echo " Target $target does not meet the requirement $requirement for $sketchname . Skipping."
182
- exit 0
183
- fi
184
- done
185
- fi
186
-
187
- # Check if the sketch excludes any configuration options (OR)
188
- requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
189
- if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
190
- found=false
191
- for requirement in $requirements_or ; do
192
- requirement=$( echo $requirement | xargs)
193
- found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
194
- if [[ " $found_line " != " " ]]; then
195
- found=true
196
- break
197
- fi
198
- done
199
- if [[ " $found " == " false" ]]; then
200
- echo " Target $target meets none of the requirements in requires_any for $sketchname . Skipping."
201
- exit 0
202
- fi
210
+ if ! check_requirements " $sketchdir " " $SDKCONFIG_DIR /$target /sdkconfig" ; then
211
+ echo " Target $target does not meet the requirements for $sketchname . Skipping."
212
+ exit 0
203
213
fi
204
214
fi
205
215
@@ -348,33 +358,8 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
348
358
fi
349
359
350
360
if [ " $ignore_requirements " != " 1" ]; then
351
- # Check if the sketch requires any configuration options (AND)
352
- requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
353
- if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
354
- for requirement in $requirements ; do
355
- requirement=$( echo $requirement | xargs)
356
- found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
357
- if [[ " $found_line " == " " ]]; then
358
- continue 2
359
- fi
360
- done
361
- fi
362
-
363
- # Check if the sketch excludes any configuration options (OR)
364
- requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
365
- if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
366
- found=false
367
- for requirement in $requirements_or ; do
368
- requirement=$( echo $requirement | xargs)
369
- found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
370
- if [[ " $found_line " != " " ]]; then
371
- found=true
372
- break
373
- fi
374
- done
375
- if [[ " $found " == " false" ]]; then
376
- continue 2
377
- fi
361
+ if ! check_requirements " $sketchdir " " $SDKCONFIG_DIR /$target /sdkconfig" ; then
362
+ continue
378
363
fi
379
364
fi
380
365
fi
@@ -552,6 +537,7 @@ Available commands:
552
537
count: Count sketches.
553
538
build: Build a sketch.
554
539
chunk_build: Build a chunk of sketches.
540
+ check_requirements: Check if target meets sketch requirements.
555
541
"
556
542
557
543
cmd=$1
@@ -569,6 +555,8 @@ case "$cmd" in
569
555
;;
570
556
" chunk_build" ) build_sketches $*
571
557
;;
558
+ " check_requirements" ) check_requirements $*
559
+ ;;
572
560
* )
573
561
echo " ERROR: Unrecognized command"
574
562
echo " $USAGE "
0 commit comments