Skip to content

Commit d84c03c

Browse files
authored
Update copy-libs.sh
1 parent 9566b60 commit d84c03c

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

tools/copy-libs.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# config
33

44
IDF_TARGET=$1
5+
IS_XTENSA=$4
56
OCT_FLASH=
67
OCT_PSRAM=
78
if [ "$2" = "y" ]; then
@@ -191,6 +192,7 @@ for item; do
191192
short_name="${item:2}"
192193
if [[ $exclude_libs != *";$short_name;"* && $LD_LIBS_SEARCH != *"lib$short_name.a"* ]]; then
193194
LD_LIBS_SEARCH+="lib$short_name.a "
195+
#echo "lib add: $item"
194196
fi
195197
elif [ "$item" = "-o" ]; then
196198
add_next=0
@@ -225,8 +227,35 @@ for item; do
225227
if [[ "$lname" != "main" && "$lname" != "arduino" ]]; then
226228
lsize=$($SSTAT "$item")
227229
if (( lsize > 8 )); then
228-
LD_LIBS+="-l$lname "
229-
LD_LIB_FILES+="$item "
230+
# do we already have this file?
231+
if [[ $LD_LIB_FILES != *"$item"* ]]; then
232+
# do we already have lib with the same name?
233+
if [[ $LD_LIBS != *"-l$lname"* ]]; then
234+
# echo "collecting lib '$lname' and file: $item"
235+
LD_LIB_FILES+="$item "
236+
LD_LIBS+="-l$lname "
237+
else
238+
# echo "!!! need to rename: '$lname'"
239+
for i in {2..9}; do
240+
n_item="${item:0:${#item}-2}_$i.a"
241+
n_name=$lname"_$i"
242+
if [ -f "$n_item" ]; then
243+
# echo "renamed add: -l$n_name"
244+
LD_LIBS+="-l$n_name "
245+
break
246+
elif [[ $LD_LIB_FILES != *"$n_item"* && $LD_LIBS != *"-l$n_name"* ]]; then
247+
echo "Renaming '$lname' to '$n_name': $item"
248+
cp -f "$item" "$n_item"
249+
LD_LIB_FILES+="$n_item "
250+
LD_LIBS+="-l$n_name "
251+
break
252+
fi
253+
done
254+
fi
255+
else
256+
# echo "just add: -l$lname"
257+
LD_LIBS+="-l$lname "
258+
fi
230259
else
231260
echo "*** Skipping $(basename $item): size too small $lsize"
232261
fi
@@ -253,6 +282,15 @@ cat pio_start.txt > "$AR_PLATFORMIO_PY"
253282
rm pio_end.txt 1pio_start.txt pio_start.txt
254283

255284
echo " ASFLAGS=[" >> "$AR_PLATFORMIO_PY"
285+
if [ "$IS_XTENSA" = "y" ]; then
286+
echo " \"-mlongcalls\"" >> "$AR_PLATFORMIO_PY"
287+
else
288+
echo " \"-march=rv32imc\"" >> "$AR_PLATFORMIO_PY"
289+
fi
290+
echo " ]," >> "$AR_PLATFORMIO_PY"
291+
echo "" >> "$AR_PLATFORMIO_PY"
292+
293+
echo " ASPPFLAGS=[" >> "$AR_PLATFORMIO_PY"
256294
set -- $PIO_AS_FLAGS
257295
for item; do
258296
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"

0 commit comments

Comments
 (0)