Skip to content

Commit dbd39e3

Browse files
authored
Update copy-libs.sh
1 parent 2e443a2 commit dbd39e3

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

tools/copy-libs.sh

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function get_actual_path(){
5353
}
5454

5555
# Include-Pfad-Verkürzung Funktionen (für statische Generierung)
56-
# Das Build-Zeit Framework-Verzeichnis (ESP-IDF Quellen)
5756
if [ -n "$IDF_PATH" ]; then
5857
BUILD_FRAMEWORK_DIR="$IDF_PATH"
5958
elif [ -d "../esp-idf" ]; then
@@ -65,19 +64,16 @@ fi
6564
is_framework_subfolder() {
6665
local potential_subfolder="$1"
6766

68-
# Prüfe ob absoluter Pfad
6967
if [[ "$potential_subfolder" != /* ]]; then
7068
return 1
7169
fi
7270

73-
# Prüfe ob auf gleichem Laufwerk
7471
local sdk_drive="${BUILD_FRAMEWORK_DIR%%:*}"
7572
local sub_drive="${potential_subfolder%%:*}"
7673
if [[ "$sdk_drive" != "$sub_drive" ]]; then
7774
return 1
7875
fi
7976

80-
# Prüfe ob Unterordner (analog zu Python os.path.commonpath)
8177
case "$potential_subfolder" in
8278
"$BUILD_FRAMEWORK_DIR"*)
8379
return 0
@@ -93,39 +89,39 @@ shorten_includes() {
9389
local shortened_includes=""
9490
local generic_includes=""
9591

96-
# Konvertiere Include-String zu Array
9792
IFS=' ' read -ra includes_array <<< "$includes_str"
9893

9994
for inc in "${includes_array[@]}"; do
10095
if [[ -n "$inc" ]]; then
10196
if is_framework_subfolder "$inc"; then
102-
# Mappe auf die kopierte Struktur im Arduino Framework
10397
local rel_path="${inc#$BUILD_FRAMEWORK_DIR}"
104-
rel_path="${rel_path#/}" # Entferne führenden Slash
98+
rel_path="${rel_path#/}"
10599

106-
# Konvertiere ESP-IDF Pfad zu Arduino Framework Pfad
107100
if [[ "$rel_path" == "components/"* ]]; then
108-
# components/freertos/include -> include/freertos
109101
local component_path="${rel_path#components/}"
110102
local component_name="${component_path%%/*}"
111103
local sub_path="${component_path#*/}"
112104
if [[ "$sub_path" == "include" ]]; then
113105
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"
114109
else
115110
shortened_includes+=" -iwithprefix/include/$component_name/$sub_path"
116111
fi
117112
elif [[ "$rel_path" == "managed_components/"* ]]; then
118-
# managed_components/esp32-camera/include -> include/esp32-camera
119113
local component_path="${rel_path#managed_components/}"
120114
local component_name="${component_path%%/*}"
121115
local sub_path="${component_path#*/}"
122116
if [[ "$sub_path" == "include" ]]; then
123117
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"
124121
else
125122
shortened_includes+=" -iwithprefix/include/$component_name/$sub_path"
126123
fi
127124
else
128-
# Andere Pfade direkt mappen
129125
shortened_includes+=" -iwithprefix/$rel_path"
130126
fi
131127
else
@@ -134,7 +130,6 @@ shorten_includes() {
134130
fi
135131
done
136132

137-
# Rückgabe: "generic_includes|shortened_includes"
138133
echo "$generic_includes|$shortened_includes"
139134
}
140135

@@ -177,12 +172,12 @@ fi
177172
# copy zigbee + zboss lib
178173
if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then
179174
cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
180-
EXCLUDE_LIBS+="esp_zb_api_ed;"
175+
EXCLUDE_LIBS+="esp_zb_api.ed;esp_zb_api.zczr;"
181176
fi
182177

183178
if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then
184179
cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
185-
EXCLUDE_LIBS+="zboss_stack.ed;zboss_port.debug;"
180+
EXCLUDE_LIBS+="zboss_stack.ed;zboss_stack.zczr;zboss_port.native;zboss_port.native.debug;zboss_port.remote;zboss_port.remote.debug;"
186181
fi
187182

188183
#collect includes, defines and c-flags
@@ -512,13 +507,15 @@ echo " '-Wl,-Map=\"%s\"' % join(\"\${BUILD_DIR}\", \"\${PROGNAME}.map\")"
512507
echo " ]," >> "$AR_PLATFORMIO_PY"
513508
echo "" >> "$AR_PLATFORMIO_PY"
514509

515-
# CPPPATH nur mit kopierten Headers
510+
# CPPPATH NUR mit Arduino Core - KEINE kopierten Headers!
516511
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"
517516

518-
# Bestehende CPPPATH-Logik für kopierte Headers
519-
REL_INC=""
517+
# Headers kopieren (aber NICHT zu CPPPATH hinzufügen)
520518
set -- $INCLUDES
521-
522519
for item; do
523520
if [[ "$item" != $PWD ]]; then
524521
ipath="$item"
@@ -541,14 +538,8 @@ for item; do
541538

542539
out_sub="${item#*$ipath}"
543540
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
541+
542+
# Headers kopieren
552543
for f in `find "$item" -name '*.h'`; do
553544
rel_f=${f#*$item}
554545
rel_p=${rel_f%/*}
@@ -567,17 +558,14 @@ for item; do
567558
mkdir -p "$out_cpath$rel_p"
568559
cp -n $f "$out_cpath$rel_p/"
569560
done
561+
570562
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
571563
if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then
572564
mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET"
573565
cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h"
574566
fi
575567
fi
576568
done
577-
echo " join($PIO_SDK, board_config.get(\"build.arduino.memory_type\", (board_config.get(\"build.flash_mode\", \"dio\") + \"_qspi\")), \"include\")," >> "$AR_PLATFORMIO_PY"
578-
echo " join(FRAMEWORK_DIR, \"cores\", board_config.get(\"build.core\"))" >> "$AR_PLATFORMIO_PY"
579-
echo " ]," >> "$AR_PLATFORMIO_PY"
580-
echo "" >> "$AR_PLATFORMIO_PY"
581569

582570
AR_LIBS="$LD_LIBS"
583571
PIO_LIBS=""
@@ -636,7 +624,6 @@ DEFINES=`echo "$DEFINES" | tr -s '\'`
636624
FLAGS_DIR="$AR_SDK/flags"
637625
mkdir -p "$FLAGS_DIR"
638626
echo -n "$DEFINES" > "$FLAGS_DIR/defines"
639-
echo -n "$REL_INC" > "$FLAGS_DIR/includes"
640627
echo -n "$C_FLAGS" > "$FLAGS_DIR/c_flags"
641628
echo -n "$CPP_FLAGS" > "$FLAGS_DIR/cpp_flags"
642629
echo -n "$AS_FLAGS" > "$FLAGS_DIR/S_flags"
@@ -712,3 +699,4 @@ done;
712699
# Add IDF versions to sdkconfig
713700
echo "#define CONFIG_ARDUINO_IDF_COMMIT \"$IDF_COMMIT\"" >> "$AR_SDK/$MEMCONF/include/sdkconfig.h"
714701
echo "#define CONFIG_ARDUINO_IDF_BRANCH \"$IDF_BRANCH\"" >> "$AR_SDK/$MEMCONF/include/sdkconfig.h"
702+

0 commit comments

Comments
 (0)