@@ -52,87 +52,6 @@ function get_actual_path(){
52
52
fi
53
53
}
54
54
55
- # Include-Pfad-Verkürzung Funktionen (für statische Generierung)
56
- if [ -n " $IDF_PATH " ]; then
57
- BUILD_FRAMEWORK_DIR=" $IDF_PATH "
58
- elif [ -d " ../esp-idf" ]; then
59
- BUILD_FRAMEWORK_DIR=" $( realpath ../esp-idf) "
60
- else
61
- BUILD_FRAMEWORK_DIR=$( dirname $( dirname " $PWD " ) )
62
- fi
63
-
64
- is_framework_subfolder () {
65
- local potential_subfolder=" $1 "
66
-
67
- if [[ " $potential_subfolder " != /* ]]; then
68
- return 1
69
- fi
70
-
71
- local sdk_drive=" ${BUILD_FRAMEWORK_DIR%%:* } "
72
- local sub_drive=" ${potential_subfolder%%:* } "
73
- if [[ " $sdk_drive " != " $sub_drive " ]]; then
74
- return 1
75
- fi
76
-
77
- case " $potential_subfolder " in
78
- " $BUILD_FRAMEWORK_DIR " * )
79
- return 0
80
- ;;
81
- * )
82
- return 1
83
- ;;
84
- esac
85
- }
86
-
87
- shorten_includes () {
88
- local includes_str=" $1 "
89
- local shortened_includes=" "
90
- local generic_includes=" "
91
-
92
- IFS=' ' read -ra includes_array <<< " $includes_str"
93
-
94
- for inc in " ${includes_array[@]} " ; do
95
- if [[ -n " $inc " ]]; then
96
- if is_framework_subfolder " $inc " ; then
97
- local rel_path=" ${inc# $BUILD_FRAMEWORK_DIR } "
98
- rel_path=" ${rel_path#/ } "
99
-
100
- if [[ " $rel_path " == " components/" * ]]; then
101
- local component_path=" ${rel_path# components/ } "
102
- local component_name=" ${component_path%%/* } "
103
- local sub_path=" ${component_path#*/ } "
104
- if [[ " $sub_path " == " include" ]]; then
105
- shortened_includes+=" -iwithprefix/include/$component_name "
106
- elif [[ " $sub_path " == " include/" * ]]; then
107
- local remaining_path=" ${sub_path# include/ } "
108
- shortened_includes+=" -iwithprefix/include/$component_name /$remaining_path "
109
- else
110
- shortened_includes+=" -iwithprefix/include/$component_name /$sub_path "
111
- fi
112
- elif [[ " $rel_path " == " managed_components/" * ]]; then
113
- local component_path=" ${rel_path# managed_components/ } "
114
- local component_name=" ${component_path%%/* } "
115
- local sub_path=" ${component_path#*/ } "
116
- if [[ " $sub_path " == " include" ]]; then
117
- shortened_includes+=" -iwithprefix/include/$component_name "
118
- elif [[ " $sub_path " == " include/" * ]]; then
119
- local remaining_path=" ${sub_path# include/ } "
120
- shortened_includes+=" -iwithprefix/include/$component_name /$remaining_path "
121
- else
122
- shortened_includes+=" -iwithprefix/include/$component_name /$sub_path "
123
- fi
124
- else
125
- shortened_includes+=" -iwithprefix/$rel_path "
126
- fi
127
- else
128
- generic_includes+=" $inc "
129
- fi
130
- fi
131
- done
132
-
133
- echo " $generic_includes |$shortened_includes "
134
- }
135
-
136
55
#
137
56
# START OF DATA EXTRACTION FROM CMAKE
138
57
#
@@ -142,7 +61,6 @@ CPP_FLAGS=""
142
61
AS_FLAGS=" "
143
62
144
63
INCLUDES=" "
145
- INCLUDES_RAW=" "
146
64
DEFINES=" "
147
65
148
66
EXCLUDE_LIBS=" ;"
@@ -192,19 +110,16 @@ for item in "${@:2:${#@}-5}"; do
192
110
if [ " ${item: 0: 1} " = " /" ]; then
193
111
item=` get_actual_path $item `
194
112
INCLUDES+=" $item "
195
- INCLUDES_RAW+=" $item "
196
113
elif [ " ${item: 0: 2} " = " .." ]; then
197
114
if [[ " ${item: 0: 14} " = " ../components/" && " ${item: 0: 22} " != " ../components/arduino/" ]] || [[ " ${item: 0: 11} " = " ../esp-idf/" ]] || [[ " ${item: 0: 22} " = " ../managed_components/" ]]; then
198
115
item=" $PWD ${item: 2} "
199
116
item=` get_actual_path $item `
200
117
INCLUDES+=" $item "
201
- INCLUDES_RAW+=" $item "
202
118
fi
203
119
else
204
120
item=" $PWD /build/$item "
205
121
item=` get_actual_path $item `
206
122
INCLUDES+=" $item "
207
- INCLUDES_RAW+=" $item "
208
123
fi
209
124
elif [ " $prefix " = " -D" ]; then
210
125
if [[ " ${item: 2: 7} " != " ARDUINO" ]] && [[ " $item " != " -DESP32=ESP32" ]] && [[ " $item " != " -DNDEBUG" ]]; then # skip ARDUINO defines
@@ -219,11 +134,6 @@ for item in "${@:2:${#@}-5}"; do
219
134
fi
220
135
done
221
136
222
- # Wende Include-Verkürzung an
223
- SHORTENED_RESULT=$( shorten_includes " $INCLUDES_RAW " )
224
- GENERIC_INCLUDES=" ${SHORTENED_RESULT% |* } "
225
- SHORTENED_INCLUDES=" ${SHORTENED_RESULT#* |} "
226
-
227
137
# collect asm-flags
228
138
str=` cat build/compile_commands.json | grep arduino-lib-builder-as.S | grep command | cut -d' :' -f2 | cut -d' ,' -f1`
229
139
str=" ${str: 2: ${# str} -1} " # remove leading space and quotes
@@ -412,25 +322,17 @@ mkdir -p "$AR_SDK"
412
322
AR_PLATFORMIO_PY=" $AR_SDK /pioarduino-build.py"
413
323
cat configs/pio_start.txt > " $AR_PLATFORMIO_PY "
414
324
415
- # ASFLAGS mit statischer Include-Verkürzung
325
+ # Sammle Include-Pfade für Verkürzung
326
+ SHORTENED_INCLUDES=" "
327
+
416
328
echo " ASFLAGS=[" >> " $AR_PLATFORMIO_PY "
417
329
if [ " $IS_XTENSA " = " y" ]; then
418
330
echo " \" -mlongcalls\" " >> " $AR_PLATFORMIO_PY "
419
331
else
420
332
echo " \" -march=rv32imc\" " >> " $AR_PLATFORMIO_PY "
421
333
fi
422
334
423
- # Füge statische Include-Verkürzung hinzu
424
- if [[ -n " $SHORTENED_INCLUDES " ]]; then
425
- echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" sdk\" , \" $IDF_TARGET \" )," >> " $AR_PLATFORMIO_PY "
426
- IFS=' ' read -ra shortened_array <<< " $SHORTENED_INCLUDES"
427
- for flag in " ${shortened_array[@]} " ; do
428
- if [[ -n " $flag " ]]; then
429
- echo " \" $flag \" ," >> " $AR_PLATFORMIO_PY "
430
- fi
431
- done
432
- fi
433
-
335
+ # Include-Verkürzung wird später hinzugefügt
434
336
echo " ]," >> " $AR_PLATFORMIO_PY "
435
337
echo " " >> " $AR_PLATFORMIO_PY "
436
338
@@ -467,24 +369,13 @@ echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
467
369
echo " ]," >> " $AR_PLATFORMIO_PY "
468
370
echo " " >> " $AR_PLATFORMIO_PY "
469
371
470
- # CCFLAGS mit statischer Include-Verkürzung
471
372
echo " CCFLAGS=[" >> " $AR_PLATFORMIO_PY "
472
373
set -- $PIO_CC_FLAGS
473
374
for item; do
474
375
echo " \" $item \" ," >> " $AR_PLATFORMIO_PY "
475
376
done
476
377
477
- # Füge statische Include-Verkürzung hinzu
478
- if [[ -n " $SHORTENED_INCLUDES " ]]; then
479
- echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" sdk\" , \" $IDF_TARGET \" )," >> " $AR_PLATFORMIO_PY "
480
- IFS=' ' read -ra shortened_array <<< " $SHORTENED_INCLUDES"
481
- for flag in " ${shortened_array[@]} " ; do
482
- if [[ -n " $flag " ]]; then
483
- echo " \" $flag \" ," >> " $AR_PLATFORMIO_PY "
484
- fi
485
- done
486
- fi
487
-
378
+ # Include-Verkürzung wird später hinzugefügt
488
379
echo " \" -MMD\" " >> " $AR_PLATFORMIO_PY "
489
380
echo " ]," >> " $AR_PLATFORMIO_PY "
490
381
echo " " >> " $AR_PLATFORMIO_PY "
@@ -507,15 +398,12 @@ echo " '-Wl,-Map=\"%s\"' % join(\"\${BUILD_DIR}\", \"\${PROGNAME}.map\")"
507
398
echo " ]," >> " $AR_PLATFORMIO_PY "
508
399
echo " " >> " $AR_PLATFORMIO_PY "
509
400
510
- # CPPPATH NUR mit Arduino Core - KEINE kopierten Headers!
401
+ # include dirs - HIER WIRD DIE VERKÜRZUNG IMPLEMENTIERT
402
+ REL_INC=" "
511
403
echo " CPPPATH=[" >> " $AR_PLATFORMIO_PY "
512
- echo " join($PIO_SDK , board_config.get(\" build.arduino.memory_type\" , (board_config.get(\" build.flash_mode\" , \" dio\" ) + \" _qspi\" )), \" include\" )," >> " $AR_PLATFORMIO_PY "
513
- echo " join(FRAMEWORK_DIR, \" cores\" , board_config.get(\" build.core\" ))" >> " $AR_PLATFORMIO_PY "
514
- echo " ]," >> " $AR_PLATFORMIO_PY "
515
- echo " " >> " $AR_PLATFORMIO_PY "
516
404
517
- # Headers kopieren (aber NICHT zu CPPPATH hinzufügen)
518
405
set -- $INCLUDES
406
+
519
407
for item; do
520
408
if [[ " $item " != $PWD ]]; then
521
409
ipath=" $item "
@@ -539,7 +427,15 @@ for item; do
539
427
out_sub=" ${item#* $ipath } "
540
428
out_cpath=" $AR_SDK /include/$fname$out_sub "
541
429
542
- # Headers kopieren
430
+ # Sammle für Include-Verkürzung: Konvertiere zu relativem Pfad
431
+ if [ " $out_sub " = " " ]; then
432
+ SHORTENED_INCLUDES+=" -iwithprefix/include/$fname "
433
+ else
434
+ sub_clean=" ${out_sub#/ } " # Entferne führenden Slash
435
+ SHORTENED_INCLUDES+=" -iwithprefix/include/$fname /$sub_clean "
436
+ fi
437
+
438
+ # Headers kopieren (wie bisher)
543
439
for f in ` find " $item " -name ' *.h' ` ; do
544
440
rel_f=${f#* $item }
545
441
rel_p=${rel_f%/* }
@@ -558,7 +454,6 @@ for item; do
558
454
mkdir -p " $out_cpath$rel_p "
559
455
cp -n $f " $out_cpath$rel_p /"
560
456
done
561
-
562
457
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
563
458
if [[ " $fname " == " bt" && " $out_sub " == " /include/$IDF_TARGET /include" && -f " $ipath /controller/$IDF_TARGET /esp_bt_cfg.h" ]]; then
564
459
mkdir -p " $AR_SDK /include/$fname /controller/$IDF_TARGET "
@@ -567,6 +462,55 @@ for item; do
567
462
fi
568
463
done
569
464
465
+ # Nur Arduino Core und Memory-Variant in CPPPATH (NICHT die Framework-Headers!)
466
+ echo " join($PIO_SDK , board_config.get(\" build.arduino.memory_type\" , (board_config.get(\" build.flash_mode\" , \" dio\" ) + \" _qspi\" )), \" include\" )," >> " $AR_PLATFORMIO_PY "
467
+ echo " join(FRAMEWORK_DIR, \" cores\" , board_config.get(\" build.core\" ))" >> " $AR_PLATFORMIO_PY "
468
+ echo " ]," >> " $AR_PLATFORMIO_PY "
469
+ echo " " >> " $AR_PLATFORMIO_PY "
470
+
471
+ # JETZT: Füge Include-Verkürzung zu CCFLAGS und ASFLAGS hinzu
472
+ if [[ -n " $SHORTENED_INCLUDES " ]]; then
473
+ # Aktualisiere CCFLAGS
474
+ sed -i ' /CCFLAGS=\[/,/\]/{
475
+ /"-MMD"/i\
476
+ "-iprefix", join(FRAMEWORK_DIR, "tools", "sdk", "' $IDF_TARGET ' "),
477
+ }' " $AR_PLATFORMIO_PY "
478
+
479
+ # Füge iwithprefix Flags hinzu
480
+ IFS=' ' read -ra shortened_array <<< " $SHORTENED_INCLUDES"
481
+ for flag in " ${shortened_array[@]} " ; do
482
+ if [[ -n " $flag " ]]; then
483
+ sed -i ' /CCFLAGS=\[/,/\]/{
484
+ /"-MMD"/i\
485
+ "' $flag ' ",
486
+ }' " $AR_PLATFORMIO_PY "
487
+ fi
488
+ done
489
+
490
+ # Aktualisiere ASFLAGS
491
+ if [ " $IS_XTENSA " = " y" ]; then
492
+ sed -i ' /ASFLAGS=\[/,/\]/{
493
+ /"-mlongcalls"/a\
494
+ "-iprefix", join(FRAMEWORK_DIR, "tools", "sdk", "' $IDF_TARGET ' "),
495
+ }' " $AR_PLATFORMIO_PY "
496
+ else
497
+ sed -i ' /ASFLAGS=\[/,/\]/{
498
+ /"-march=rv32imc"/a\
499
+ "-iprefix", join(FRAMEWORK_DIR, "tools", "sdk", "' $IDF_TARGET ' "),
500
+ }' " $AR_PLATFORMIO_PY "
501
+ fi
502
+
503
+ # Füge iwithprefix Flags zu ASFLAGS hinzu
504
+ for flag in " ${shortened_array[@]} " ; do
505
+ if [[ -n " $flag " ]]; then
506
+ sed -i ' /ASFLAGS=\[/,/\]/{
507
+ $i\
508
+ "' $flag ' ",
509
+ }' " $AR_PLATFORMIO_PY "
510
+ fi
511
+ done
512
+ fi
513
+
570
514
AR_LIBS=" $LD_LIBS "
571
515
PIO_LIBS=" "
572
516
set -- $LD_LIBS
@@ -624,16 +568,16 @@ DEFINES=`echo "$DEFINES" | tr -s '\'`
624
568
FLAGS_DIR=" $AR_SDK /flags"
625
569
mkdir -p " $FLAGS_DIR "
626
570
echo -n " $DEFINES " > " $FLAGS_DIR /defines"
571
+ echo -n " $REL_INC " > " $FLAGS_DIR /includes"
627
572
echo -n " $C_FLAGS " > " $FLAGS_DIR /c_flags"
628
573
echo -n " $CPP_FLAGS " > " $FLAGS_DIR /cpp_flags"
629
574
echo -n " $AS_FLAGS " > " $FLAGS_DIR /S_flags"
630
575
echo -n " $LD_FLAGS " > " $FLAGS_DIR /ld_flags"
631
576
echo -n " $LD_SCRIPTS " > " $FLAGS_DIR /ld_scripts"
632
577
echo -n " $AR_LIBS " > " $FLAGS_DIR /ld_libs"
633
578
634
- # Speichere auch die verkürzten Includes in den Flags
579
+ # Speichere verkürzte Includes für Debugging
635
580
echo -n " $SHORTENED_INCLUDES " > " $FLAGS_DIR /shortened_includes"
636
- echo -n " $GENERIC_INCLUDES " > " $FLAGS_DIR /generic_includes"
637
581
638
582
if [ -d " managed_components/espressif__esp32-camera/driver/private_include/" ]; then
639
583
cp -r " managed_components/espressif__esp32-camera/driver/private_include/cam_hal.h" " $AR_SDK /include/espressif__esp32-camera/driver/include/"
@@ -699,4 +643,3 @@ done;
699
643
# Add IDF versions to sdkconfig
700
644
echo " #define CONFIG_ARDUINO_IDF_COMMIT \" $IDF_COMMIT \" " >> " $AR_SDK /$MEMCONF /include/sdkconfig.h"
701
645
echo " #define CONFIG_ARDUINO_IDF_BRANCH \" $IDF_BRANCH \" " >> " $AR_SDK /$MEMCONF /include/sdkconfig.h"
702
-
0 commit comments