Skip to content

Commit

Permalink
fix(zigbee): Unlink the zigbee libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Nov 6, 2024
1 parent 8ece5fa commit bb45bf0
Showing 1 changed file with 39 additions and 25 deletions.
64 changes: 39 additions & 25 deletions tools/copy-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ AS_FLAGS=""
INCLUDES=""
DEFINES=""

EXCLUDE_LIBS=";"

LD_FLAGS=""
LD_LIBS=""
LD_LIB_FILES=""
Expand All @@ -78,6 +80,17 @@ else
TOOLCHAIN="riscv32-esp-elf"
fi

# copy zigbee + zboss lib
if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then
cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
EXCLUDE_LIBS+="esp_zb_api_ed;"
fi

if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then
cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
EXCLUDE_LIBS+="zboss_stack.ed;zboss_port.debug;"
fi

#collect includes, defines and c-flags
str=`cat build/compile_commands.json | grep arduino-lib-builder-gcc.c | grep command | cut -d':' -f2 | cut -d',' -f1`
str="${str:2:${#str}-1}" #remove leading space and quotes
Expand Down Expand Up @@ -200,12 +213,14 @@ for item; do
add_next=1
LD_FLAGS+="$item "
elif [ "${item:0:2}" = "-l" ]; then # -l[lib_name]
LD_LIBS+="$item "
exclude_libs=";m;c;gcc;stdc++;"
short_name="${item:2}"
if [[ $exclude_libs != *";$short_name;"* && $LD_LIBS_SEARCH != *"lib$short_name.a"* ]]; then
LD_LIBS_SEARCH+="lib$short_name.a "
#echo "lib add: $item"
if [[ $EXCLUDE_LIBS != *";$short_name;"* ]]; then
LD_LIBS+="$item "
exclude_libs=";m;c;gcc;stdc++;"
if [[ $exclude_libs != *";$short_name;"* && $LD_LIBS_SEARCH != *"lib$short_name.a"* ]]; then
LD_LIBS_SEARCH+="lib$short_name.a "
#echo "1. lib add: $item"
fi
fi
elif [ "$item" = "-o" ]; then
add_next=0
Expand Down Expand Up @@ -244,30 +259,38 @@ for item; do
if [[ $LD_LIB_FILES != *"$item"* ]]; then
# do we already have lib with the same name?
if [[ $LD_LIBS != *"-l$lname"* ]]; then
# echo "collecting lib '$lname' and file: $item"
LD_LIB_FILES+="$item "
LD_LIBS+="-l$lname "
if [[ $EXCLUDE_LIBS != *";$lname;"* ]]; then
#echo "2. collecting lib '$lname' and file: $item"
LD_LIB_FILES+="$item "
LD_LIBS+="-l$lname "
fi
else
# echo "!!! need to rename: '$lname'"
for i in {2..9}; do
n_item="${item:0:${#item}-2}_$i.a"
n_name=$lname"_$i"
if [ -f "$n_item" ]; then
# echo "renamed add: -l$n_name"
LD_LIBS+="-l$n_name "
if [[ $EXCLUDE_LIBS != *";$lname;"* ]]; then
#echo "3. renamed add: -l$n_name"
LD_LIBS+="-l$n_name "
fi
break
elif [[ $LD_LIB_FILES != *"$n_item"* && $LD_LIBS != *"-l$n_name"* ]]; then
echo "Renaming '$lname' to '$n_name': $item"
cp -f "$item" "$n_item"
LD_LIB_FILES+="$n_item "
LD_LIBS+="-l$n_name "
if [[ $EXCLUDE_LIBS != *";$lname;"* ]]; then
#echo "4. Renaming '$lname' to '$n_name': $item"
cp -f "$item" "$n_item"
LD_LIB_FILES+="$n_item "
LD_LIBS+="-l$n_name "
fi
break
fi
done
fi
else
# echo "just add: -l$lname"
LD_LIBS+="-l$lname "
if [[ $EXCLUDE_LIBS != *";$lname;"* ]]; then
#echo "5. just add: -l$lname"
LD_LIBS+="-l$lname "
fi
fi
else
echo "*** Skipping $(basename $item): size too small $lsize"
Expand Down Expand Up @@ -493,15 +516,6 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags"
echo -n "$LD_SCRIPTS" > "$FLAGS_DIR/ld_scripts"
echo -n "$AR_LIBS" > "$FLAGS_DIR/ld_libs"

# copy zigbee + zboss lib
if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then
cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
fi

if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then
cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/"
fi

if [ -d "managed_components/espressif__esp32-camera/driver/private_include/" ]; then
cp -r "managed_components/espressif__esp32-camera/driver/private_include/cam_hal.h" "$AR_SDK/include/espressif__esp32-camera/driver/include/"
fi
Expand Down

0 comments on commit bb45bf0

Please sign in to comment.