Skip to content

Commit c12eacb

Browse files
authored
Update copy-libs.sh
1 parent f49e314 commit c12eacb

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

tools/copy-libs.sh

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ PIO_LD_FLAGS=""
7171
PIO_LD_FUNCS=""
7272
PIO_LD_SCRIPTS=""
7373

74+
TOOLCHAIN_PREFIX=""
75+
if [ "$IS_XTENSA" = "y" ]; then
76+
TOOLCHAIN="xtensa-$IDF_TARGET-elf"
77+
else
78+
TOOLCHAIN="riscv32-esp-elf"
79+
fi
80+
7481
#collect includes, defines and c-flags
7582
str=`cat build/compile_commands.json | grep arduino-lib-builder-gcc.c | grep command | cut -d':' -f2 | cut -d',' -f1`
7683
str="${str:2:${#str}-1}" #remove leading space and quotes
@@ -101,7 +108,7 @@ for item in "${@:2:${#@}-5}"; do
101108
elif [ "$prefix" = "-O" ]; then
102109
PIO_CC_FLAGS+="$item "
103110
elif [[ "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" ]]; then
104-
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then
111+
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then
105112
C_FLAGS+="$item "
106113
fi
107114
fi
@@ -115,7 +122,7 @@ set -- $str
115122
for item in "${@:2:${#@}-5}"; do
116123
prefix="${item:0:2}"
117124
if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then
118-
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then
125+
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then
119126
AS_FLAGS+="$item "
120127
if [[ $C_FLAGS == *"$item"* ]]; then
121128
PIO_CC_FLAGS+="$item "
@@ -134,7 +141,7 @@ set -- $str
134141
for item in "${@:2:${#@}-5}"; do
135142
prefix="${item:0:2}"
136143
if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then
137-
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then
144+
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then
138145
CPP_FLAGS+="$item "
139146
if [[ $PIO_CC_FLAGS != *"$item"* ]]; then
140147
PIO_CXX_FLAGS+="$item "
@@ -204,7 +211,7 @@ for item; do
204211
add_next=0
205212
is_script=0
206213
is_dir=0
207-
elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then
214+
elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:19}" != "-fdebug-prefix-map=" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then
208215
LD_FLAGS+="$item "
209216
PIO_LD_FLAGS+="$item "
210217
fi
@@ -402,7 +409,13 @@ for item; do
402409
mkdir -p "$out_cpath$rel_p"
403410
cp -n $f "$out_cpath$rel_p/"
404411
done
405-
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
412+
for f in `find "$item" -name '*.inc'`; do
413+
rel_f=${f#*$item}
414+
rel_p=${rel_f%/*}
415+
mkdir -p "$out_cpath$rel_p"
416+
cp -n $f "$out_cpath$rel_p/"
417+
done
418+
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
406419
if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then
407420
mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET"
408421
cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h"
@@ -478,11 +491,13 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags"
478491
echo -n "$LD_SCRIPTS" > "$FLAGS_DIR/ld_scripts"
479492
echo -n "$AR_LIBS" > "$FLAGS_DIR/ld_libs"
480493

481-
# sr model.bin
482-
if [ -f "build/srmodels/srmodels.bin" ]; then
483-
mkdir -p "$AR_SDK/esp_sr"
484-
cp -f "build/srmodels/srmodels.bin" "$AR_SDK/esp_sr/"
485-
cp -f "partitions.csv" "$AR_SDK/esp_sr/"
494+
# copy zigbee + zboss lib
495+
if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then
496+
cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
497+
fi
498+
499+
if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then
500+
cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
486501
fi
487502

488503
# sdkconfig
@@ -515,6 +530,13 @@ for item; do
515530
done
516531
done
517532

533+
for lib in "openthread" "espressif__esp-tflite-micro" "bt"; do
534+
if [ -f "$AR_SDK/lib/lib$lib.a" ]; then
535+
echo "Stripping $AR_SDK/lib/lib$lib.a"
536+
"$TOOLCHAIN-strip" -g "$AR_SDK/lib/lib$lib.a"
537+
fi
538+
done
539+
518540
# Handle Mem Variants
519541
mkdir -p "$AR_SDK/$MEMCONF/include"
520542
mv "$PWD/build/config/sdkconfig.h" "$AR_SDK/$MEMCONF/include/sdkconfig.h"

0 commit comments

Comments
 (0)