@@ -52,92 +52,6 @@ function get_actual_path(){
52
52
fi
53
53
}
54
54
55
- # Include-Pfad-Verkürzung Funktionen (für statische Generierung)
56
- # Das Build-Zeit Framework-Verzeichnis (ESP-IDF Quellen)
57
- if [ -n " $IDF_PATH " ]; then
58
- BUILD_FRAMEWORK_DIR=" $IDF_PATH "
59
- elif [ -d " ../esp-idf" ]; then
60
- BUILD_FRAMEWORK_DIR=" $( realpath ../esp-idf) "
61
- else
62
- BUILD_FRAMEWORK_DIR=$( dirname $( dirname " $PWD " ) )
63
- fi
64
-
65
- is_framework_subfolder () {
66
- local potential_subfolder=" $1 "
67
-
68
- # Prüfe ob absoluter Pfad
69
- if [[ " $potential_subfolder " != /* ]]; then
70
- return 1
71
- fi
72
-
73
- # Prüfe ob auf gleichem Laufwerk
74
- local sdk_drive=" ${BUILD_FRAMEWORK_DIR%%:* } "
75
- local sub_drive=" ${potential_subfolder%%:* } "
76
- if [[ " $sdk_drive " != " $sub_drive " ]]; then
77
- return 1
78
- fi
79
-
80
- # Prüfe ob Unterordner (analog zu Python os.path.commonpath)
81
- case " $potential_subfolder " in
82
- " $BUILD_FRAMEWORK_DIR " * )
83
- return 0
84
- ;;
85
- * )
86
- return 1
87
- ;;
88
- esac
89
- }
90
-
91
- shorten_includes () {
92
- local includes_str=" $1 "
93
- local shortened_includes=" "
94
- local generic_includes=" "
95
-
96
- # Konvertiere Include-String zu Array
97
- IFS=' ' read -ra includes_array <<< " $includes_str"
98
-
99
- for inc in " ${includes_array[@]} " ; do
100
- if [[ -n " $inc " ]]; then
101
- if is_framework_subfolder " $inc " ; then
102
- # Mappe auf die kopierte Struktur im Arduino Framework
103
- local rel_path=" ${inc# $BUILD_FRAMEWORK_DIR } "
104
- rel_path=" ${rel_path#/ } " # Entferne führenden Slash
105
-
106
- # Konvertiere ESP-IDF Pfad zu Arduino Framework Pfad
107
- if [[ " $rel_path " == " components/" * ]]; then
108
- # components/freertos/include -> include/freertos
109
- local component_path=" ${rel_path# components/ } "
110
- local component_name=" ${component_path%%/* } "
111
- local sub_path=" ${component_path#*/ } "
112
- if [[ " $sub_path " == " include" ]]; then
113
- shortened_includes+=" -iwithprefix/include/$component_name "
114
- else
115
- shortened_includes+=" -iwithprefix/include/$component_name /$sub_path "
116
- fi
117
- elif [[ " $rel_path " == " managed_components/" * ]]; then
118
- # managed_components/esp32-camera/include -> include/esp32-camera
119
- local component_path=" ${rel_path# managed_components/ } "
120
- local component_name=" ${component_path%%/* } "
121
- local sub_path=" ${component_path#*/ } "
122
- if [[ " $sub_path " == " include" ]]; then
123
- shortened_includes+=" -iwithprefix/include/$component_name "
124
- else
125
- shortened_includes+=" -iwithprefix/include/$component_name /$sub_path "
126
- fi
127
- else
128
- # Andere Pfade direkt mappen
129
- shortened_includes+=" -iwithprefix/$rel_path "
130
- fi
131
- else
132
- generic_includes+=" $inc "
133
- fi
134
- fi
135
- done
136
-
137
- # Rückgabe: "generic_includes|shortened_includes"
138
- echo " $generic_includes |$shortened_includes "
139
- }
140
-
141
55
#
142
56
# START OF DATA EXTRACTION FROM CMAKE
143
57
#
@@ -147,7 +61,6 @@ CPP_FLAGS=""
147
61
AS_FLAGS=" "
148
62
149
63
INCLUDES=" "
150
- INCLUDES_RAW=" "
151
64
DEFINES=" "
152
65
153
66
EXCLUDE_LIBS=" ;"
@@ -197,19 +110,16 @@ for item in "${@:2:${#@}-5}"; do
197
110
if [ " ${item: 0: 1} " = " /" ]; then
198
111
item=` get_actual_path $item `
199
112
INCLUDES+=" $item "
200
- INCLUDES_RAW+=" $item "
201
113
elif [ " ${item: 0: 2} " = " .." ]; then
202
114
if [[ " ${item: 0: 14} " = " ../components/" && " ${item: 0: 22} " != " ../components/arduino/" ]] || [[ " ${item: 0: 11} " = " ../esp-idf/" ]] || [[ " ${item: 0: 22} " = " ../managed_components/" ]]; then
203
115
item=" $PWD ${item: 2} "
204
116
item=` get_actual_path $item `
205
117
INCLUDES+=" $item "
206
- INCLUDES_RAW+=" $item "
207
118
fi
208
119
else
209
120
item=" $PWD /build/$item "
210
121
item=` get_actual_path $item `
211
122
INCLUDES+=" $item "
212
- INCLUDES_RAW+=" $item "
213
123
fi
214
124
elif [ " $prefix " = " -D" ]; then
215
125
if [[ " ${item: 2: 7} " != " ARDUINO" ]] && [[ " $item " != " -DESP32=ESP32" ]] && [[ " $item " != " -DNDEBUG" ]]; then # skip ARDUINO defines
@@ -224,11 +134,6 @@ for item in "${@:2:${#@}-5}"; do
224
134
fi
225
135
done
226
136
227
- # Wende Include-Verkürzung an
228
- SHORTENED_RESULT=$( shorten_includes " $INCLUDES_RAW " )
229
- GENERIC_INCLUDES=" ${SHORTENED_RESULT% |* } "
230
- SHORTENED_INCLUDES=" ${SHORTENED_RESULT#* |} "
231
-
232
137
# collect asm-flags
233
138
str=` cat build/compile_commands.json | grep arduino-lib-builder-as.S | grep command | cut -d' :' -f2 | cut -d' ,' -f1`
234
139
str=" ${str: 2: ${# str} -1} " # remove leading space and quotes
@@ -417,21 +322,79 @@ mkdir -p "$AR_SDK"
417
322
AR_PLATFORMIO_PY=" $AR_SDK /pioarduino-build.py"
418
323
cat configs/pio_start.txt > " $AR_PLATFORMIO_PY "
419
324
420
- # ASFLAGS mit statischer Include-Verkürzung
325
+ # include dirs - SAMMLE REL_INC für Include-Verkürzung
326
+ REL_INC=" "
327
+ set -- $INCLUDES
328
+
329
+ for item; do
330
+ if [[ " $item " != $PWD ]]; then
331
+ ipath=" $item "
332
+ fname=` basename " $ipath " `
333
+ dname=` basename $( dirname " $ipath " ) `
334
+ if [[ " $fname " == " main" && " $dname " == $( basename " $PWD " ) ]]; then
335
+ continue
336
+ fi
337
+ while [[ " $dname " != " components" && " $dname " != " managed_components" && " $dname " != " build" ]]; do
338
+ ipath=` dirname " $ipath " `
339
+ fname=` basename " $ipath " `
340
+ dname=` basename $( dirname " $ipath " ) `
341
+ done
342
+ if [[ " $fname " == " arduino" ]]; then
343
+ continue
344
+ fi
345
+ if [[ " $fname " == " config" ]]; then
346
+ continue
347
+ fi
348
+
349
+ out_sub=" ${item#* $ipath } "
350
+ out_cpath=" $AR_SDK /include/$fname$out_sub "
351
+ REL_INC+=" -iwithprefixbefore $fname$out_sub "
352
+
353
+ # KOPIERE HEADER-DATEIEN
354
+ for f in ` find " $item " -name ' *.h' ` ; do
355
+ rel_f=${f#* $item }
356
+ rel_p=${rel_f%/* }
357
+ mkdir -p " $out_cpath$rel_p "
358
+ cp -n $f " $out_cpath$rel_p /"
359
+ done
360
+ for f in ` find " $item " -name ' *.hpp' ` ; do
361
+ rel_f=${f#* $item }
362
+ rel_p=${rel_f%/* }
363
+ mkdir -p " $out_cpath$rel_p "
364
+ cp -n $f " $out_cpath$rel_p /"
365
+ done
366
+ for f in ` find " $item " -name ' *.inc' ` ; do
367
+ rel_f=${f#* $item }
368
+ rel_p=${rel_f%/* }
369
+ mkdir -p " $out_cpath$rel_p "
370
+ cp -n $f " $out_cpath$rel_p /"
371
+ done
372
+ # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
373
+ if [[ " $fname " == " bt" && " $out_sub " == " /include/$IDF_TARGET /include" && -f " $ipath /controller/$IDF_TARGET /esp_bt_cfg.h" ]]; then
374
+ mkdir -p " $AR_SDK /include/$fname /controller/$IDF_TARGET "
375
+ cp -n " $ipath /controller/$IDF_TARGET /esp_bt_cfg.h" " $AR_SDK /include/$fname /controller/$IDF_TARGET /esp_bt_cfg.h"
376
+ fi
377
+ fi
378
+ done
379
+
380
+ # ASFLAGS mit Include-Verkürzung basierend auf REL_INC
421
381
echo " ASFLAGS=[" >> " $AR_PLATFORMIO_PY "
422
382
if [ " $IS_XTENSA " = " y" ]; then
423
- echo " \" -mlongcalls\" " >> " $AR_PLATFORMIO_PY "
383
+ echo " \" -mlongcalls\" , " >> " $AR_PLATFORMIO_PY "
424
384
else
425
- echo " \" -march=rv32imc\" " >> " $AR_PLATFORMIO_PY "
385
+ echo " \" -march=rv32imc\" , " >> " $AR_PLATFORMIO_PY "
426
386
fi
427
387
428
- # Füge statische Include-Verkürzung hinzu
429
- if [[ -n " $SHORTENED_INCLUDES " ]]; then
388
+ # Füge Include-Verkürzung aus REL_INC hinzu
389
+ if [[ -n " $REL_INC " ]]; then
430
390
echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" sdk\" , \" $IDF_TARGET \" )," >> " $AR_PLATFORMIO_PY "
431
- IFS=' ' read -ra shortened_array <<< " $SHORTENED_INCLUDES"
432
- for flag in " ${shortened_array[@]} " ; do
433
- if [[ -n " $flag " ]]; then
434
- echo " \" $flag \" ," >> " $AR_PLATFORMIO_PY "
391
+ # Konvertiere -iwithprefixbefore zu -iwithprefix
392
+ IFS=' ' read -ra rel_inc_array <<< " $REL_INC"
393
+ for flag in " ${rel_inc_array[@]} " ; do
394
+ if [[ " $flag " == " -iwithprefixbefore" * ]]; then
395
+ # Konvertiere zu -iwithprefix
396
+ converted_flag=" ${flag// -iwithprefixbefore/ -iwithprefix} "
397
+ echo " \" $converted_flag \" ," >> " $AR_PLATFORMIO_PY "
435
398
fi
436
399
done
437
400
fi
@@ -472,20 +435,23 @@ echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
472
435
echo " ]," >> " $AR_PLATFORMIO_PY "
473
436
echo " " >> " $AR_PLATFORMIO_PY "
474
437
475
- # CCFLAGS mit statischer Include-Verkürzung
438
+ # CCFLAGS mit Include-Verkürzung basierend auf REL_INC
476
439
echo " CCFLAGS=[" >> " $AR_PLATFORMIO_PY "
477
440
set -- $PIO_CC_FLAGS
478
441
for item; do
479
442
echo " \" $item \" ," >> " $AR_PLATFORMIO_PY "
480
443
done
481
444
482
- # Füge statische Include-Verkürzung hinzu
483
- if [[ -n " $SHORTENED_INCLUDES " ]]; then
445
+ # Füge Include-Verkürzung aus REL_INC hinzu
446
+ if [[ -n " $REL_INC " ]]; then
484
447
echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" sdk\" , \" $IDF_TARGET \" )," >> " $AR_PLATFORMIO_PY "
485
- IFS=' ' read -ra shortened_array <<< " $SHORTENED_INCLUDES"
486
- for flag in " ${shortened_array[@]} " ; do
487
- if [[ -n " $flag " ]]; then
488
- echo " \" $flag \" ," >> " $AR_PLATFORMIO_PY "
448
+ # Konvertiere -iwithprefixbefore zu -iwithprefix
449
+ IFS=' ' read -ra rel_inc_array <<< " $REL_INC"
450
+ for flag in " ${rel_inc_array[@]} " ; do
451
+ if [[ " $flag " == " -iwithprefixbefore" * ]]; then
452
+ # Konvertiere zu -iwithprefix
453
+ converted_flag=" ${flag// -iwithprefixbefore/ -iwithprefix} "
454
+ echo " \" $converted_flag \" ," >> " $AR_PLATFORMIO_PY "
489
455
fi
490
456
done
491
457
fi
@@ -512,68 +478,8 @@ echo " '-Wl,-Map=\"%s\"' % join(\"\${BUILD_DIR}\", \"\${PROGNAME}.map\")"
512
478
echo " ]," >> " $AR_PLATFORMIO_PY "
513
479
echo " " >> " $AR_PLATFORMIO_PY "
514
480
515
- # CPPPATH nur mit kopierten Headers
481
+ # CPPPATH - NUR Arduino Core (KEINE Framework- Headers!)
516
482
echo " CPPPATH=[" >> " $AR_PLATFORMIO_PY "
517
-
518
- # Bestehende CPPPATH-Logik für kopierte Headers
519
- REL_INC=" "
520
- set -- $INCLUDES
521
-
522
- for item; do
523
- if [[ " $item " != $PWD ]]; then
524
- ipath=" $item "
525
- fname=` basename " $ipath " `
526
- dname=` basename $( dirname " $ipath " ) `
527
- if [[ " $fname " == " main" && " $dname " == $( basename " $PWD " ) ]]; then
528
- continue
529
- fi
530
- while [[ " $dname " != " components" && " $dname " != " managed_components" && " $dname " != " build" ]]; do
531
- ipath=` dirname " $ipath " `
532
- fname=` basename " $ipath " `
533
- dname=` basename $( dirname " $ipath " ) `
534
- done
535
- if [[ " $fname " == " arduino" ]]; then
536
- continue
537
- fi
538
- if [[ " $fname " == " config" ]]; then
539
- continue
540
- fi
541
-
542
- out_sub=" ${item#* $ipath } "
543
- out_cpath=" $AR_SDK /include/$fname$out_sub "
544
- REL_INC+=" -iwithprefixbefore $fname$out_sub "
545
- if [ " $out_sub " = " " ]; then
546
- echo " join($PIO_SDK , \" include\" , \" $fname \" )," >> " $AR_PLATFORMIO_PY "
547
- else
548
- pio_sub=" ${out_sub: 1} "
549
- pio_sub=` echo $pio_sub | sed ' s/\//\\", \\"/g' `
550
- echo " join($PIO_SDK , \" include\" , \" $fname \" , \" $pio_sub \" )," >> " $AR_PLATFORMIO_PY "
551
- fi
552
- for f in ` find " $item " -name ' *.h' ` ; do
553
- rel_f=${f#* $item }
554
- rel_p=${rel_f%/* }
555
- mkdir -p " $out_cpath$rel_p "
556
- cp -n $f " $out_cpath$rel_p /"
557
- done
558
- for f in ` find " $item " -name ' *.hpp' ` ; do
559
- rel_f=${f#* $item }
560
- rel_p=${rel_f%/* }
561
- mkdir -p " $out_cpath$rel_p "
562
- cp -n $f " $out_cpath$rel_p /"
563
- done
564
- for f in ` find " $item " -name ' *.inc' ` ; do
565
- rel_f=${f#* $item }
566
- rel_p=${rel_f%/* }
567
- mkdir -p " $out_cpath$rel_p "
568
- cp -n $f " $out_cpath$rel_p /"
569
- done
570
- # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
571
- if [[ " $fname " == " bt" && " $out_sub " == " /include/$IDF_TARGET /include" && -f " $ipath /controller/$IDF_TARGET /esp_bt_cfg.h" ]]; then
572
- mkdir -p " $AR_SDK /include/$fname /controller/$IDF_TARGET "
573
- cp -n " $ipath /controller/$IDF_TARGET /esp_bt_cfg.h" " $AR_SDK /include/$fname /controller/$IDF_TARGET /esp_bt_cfg.h"
574
- fi
575
- fi
576
- done
577
483
echo " join($PIO_SDK , board_config.get(\" build.arduino.memory_type\" , (board_config.get(\" build.flash_mode\" , \" dio\" ) + \" _qspi\" )), \" include\" )," >> " $AR_PLATFORMIO_PY "
578
484
echo " join(FRAMEWORK_DIR, \" cores\" , board_config.get(\" build.core\" ))" >> " $AR_PLATFORMIO_PY "
579
485
echo " ]," >> " $AR_PLATFORMIO_PY "
@@ -644,10 +550,6 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags"
644
550
echo -n " $LD_SCRIPTS " > " $FLAGS_DIR /ld_scripts"
645
551
echo -n " $AR_LIBS " > " $FLAGS_DIR /ld_libs"
646
552
647
- # Speichere auch die verkürzten Includes in den Flags
648
- echo -n " $SHORTENED_INCLUDES " > " $FLAGS_DIR /shortened_includes"
649
- echo -n " $GENERIC_INCLUDES " > " $FLAGS_DIR /generic_includes"
650
-
651
553
if [ -d " managed_components/espressif__esp32-camera/driver/private_include/" ]; then
652
554
cp -r " managed_components/espressif__esp32-camera/driver/private_include/cam_hal.h" " $AR_SDK /include/espressif__esp32-camera/driver/include/"
653
555
fi
0 commit comments