Skip to content

Commit 1daa36b

Browse files
authored
strip libs
1 parent aa3c03b commit 1daa36b

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tools/copy-libs.sh

+29-2
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
@@ -402,13 +409,13 @@ for item; do
402409
mkdir -p "$out_cpath$rel_p"
403410
cp -n $f "$out_cpath$rel_p/"
404411
done
405-
for f in `find "$item" -name '*.inc'`; do
412+
for f in `find "$item" -name '*.inc'`; do
406413
rel_f=${f#*$item}
407414
rel_p=${rel_f%/*}
408415
mkdir -p "$out_cpath$rel_p"
409416
cp -n $f "$out_cpath$rel_p/"
410417
done
411-
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
418+
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
412419
if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then
413420
mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET"
414421
cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h"
@@ -434,6 +441,8 @@ done
434441

435442
set -- $LD_LIB_FILES
436443
for item; do
444+
#echo "***** Stripping $item"
445+
"$TOOLCHAIN-strip" -g "$item"
437446
cp "$item" "$AR_SDK/lib/"
438447
done
439448

@@ -484,6 +493,15 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags"
484493
echo -n "$LD_SCRIPTS" > "$FLAGS_DIR/ld_scripts"
485494
echo -n "$AR_LIBS" > "$FLAGS_DIR/ld_libs"
486495

496+
# copy zigbee + zboss lib
497+
if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then
498+
cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
499+
fi
500+
501+
if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then
502+
cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
503+
fi
504+
487505
# sdkconfig
488506
cp -f "sdkconfig" "$AR_SDK/sdkconfig"
489507

@@ -498,6 +516,7 @@ function copy_precompiled_lib(){
498516
lib_file="$1"
499517
lib_name="$(basename $lib_file)"
500518
if [[ $LD_LIBS_SEARCH == *"$lib_name"* ]]; then
519+
"$TOOLCHAIN-strip" -g "$lib_file"
501520
cp "$lib_file" "$AR_SDK/ld/"
502521
fi
503522
}
@@ -514,6 +533,13 @@ for item; do
514533
done
515534
done
516535

536+
for lib in "openthread" "espressif__esp-tflite-micro" "bt" "espressif__esp_modem" "espressif__esp-zboss-lib" "espressif__esp-zigbee-lib" "espressif__mdns" "espressif__esp-dsp" "joltwallet__littlefs"; do
537+
if [ -f "$AR_SDK/lib/lib$lib.a" ]; then
538+
echo "Stripping $AR_SDK/lib/lib$lib.a"
539+
"$TOOLCHAIN-strip" -g "$AR_SDK/lib/lib$lib.a"
540+
fi
541+
done
542+
517543
# Handle Mem Variants
518544
mkdir -p "$AR_SDK/$MEMCONF/include"
519545
mv "$PWD/build/config/sdkconfig.h" "$AR_SDK/$MEMCONF/include/sdkconfig.h"
@@ -529,6 +555,7 @@ for mem_variant in `jq -c '.mem_variants_files[]' configs/builds.json`; do
529555
file=$(echo "$mem_variant" | jq -c '.file' | tr -d '"')
530556
out=$(echo "$mem_variant" | jq -c '.out' | tr -d '"')
531557
mv "$AR_SDK/$out" "$AR_SDK/$MEMCONF/$file"
558+
"$TOOLCHAIN-strip" -g "$AR_SDK/$MEMCONF/$file"
532559
fi
533560
done;
534561

0 commit comments

Comments
 (0)