Skip to content

Commit be120d3

Browse files
committed
Support library archives with the same name
Currently two files named "libmbedtls.a" exist in IDF builds. With this change, one will be renamed and copied with the new name to Arduino.
1 parent aa790cc commit be120d3

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

tools/copy-libs.sh

+30-2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ for item; do
191191
short_name="${item:2}"
192192
if [[ $exclude_libs != *";$short_name;"* && $LD_LIBS_SEARCH != *"lib$short_name.a"* ]]; then
193193
LD_LIBS_SEARCH+="lib$short_name.a "
194+
#echo "lib add: $item"
194195
fi
195196
elif [ "$item" = "-o" ]; then
196197
add_next=0
@@ -225,8 +226,35 @@ for item; do
225226
if [[ "$lname" != "main" && "$lname" != "arduino" ]]; then
226227
lsize=$($SSTAT "$item")
227228
if (( lsize > 8 )); then
228-
LD_LIBS+="-l$lname "
229-
LD_LIB_FILES+="$item "
229+
# do we already have this file?
230+
if [[ $LD_LIB_FILES != *"$item"* ]]; then
231+
# do we already have lib with the same name?
232+
if [[ $LD_LIBS != *"-l$lname"* ]]; then
233+
# echo "collecting lib '$lname' and file: $item"
234+
LD_LIB_FILES+="$item "
235+
LD_LIBS+="-l$lname "
236+
else
237+
# echo "!!! need to rename: '$lname'"
238+
for i in {2..9}; do
239+
n_item="${item:0:${#item}-2}_$i.a"
240+
n_name=$lname"_$i"
241+
if [ -f "$n_item" ]; then
242+
# echo "renamed add: -l$n_name"
243+
LD_LIBS+="-l$n_name "
244+
break
245+
elif [[ $LD_LIB_FILES != *"$n_item"* && $LD_LIBS != *"-l$n_name"* ]]; then
246+
echo "Renaming '$lname' to '$n_name': $item"
247+
cp -f "$item" "$n_item"
248+
LD_LIB_FILES+="$n_item "
249+
LD_LIBS+="-l$n_name "
250+
break
251+
fi
252+
done
253+
fi
254+
else
255+
# echo "just add: -l$lname"
256+
LD_LIBS+="-l$lname "
257+
fi
230258
else
231259
echo "*** Skipping $(basename $item): size too small $lsize"
232260
fi

0 commit comments

Comments
 (0)