Skip to content

Commit d4074fb

Browse files
authored
Update copy-libs.sh
1 parent 45bb453 commit d4074fb

File tree

1 file changed

+87
-60
lines changed

1 file changed

+87
-60
lines changed

tools/copy-libs.sh

Lines changed: 87 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,83 @@ mkdir -p "$AR_SDK"
322322
AR_PLATFORMIO_PY="$AR_SDK/pioarduino-build.py"
323323
cat configs/pio_start.txt > "$AR_PLATFORMIO_PY"
324324

325-
# ASFLAGS mit Prefix-Optionen für flags/includes
325+
# include dirs - SAMMLE REL_INC für Include-Verkürzung
326+
REL_INC=""
327+
set -- $INCLUDES
328+
329+
for item; do
330+
if [[ "$item" != $PWD ]]; then
331+
ipath="$item"
332+
fname=`basename "$ipath"`
333+
dname=`basename $(dirname "$ipath")`
334+
if [[ "$fname" == "main" && "$dname" == $(basename "$PWD") ]]; then
335+
continue
336+
fi
337+
while [[ "$dname" != "components" && "$dname" != "managed_components" && "$dname" != "build" ]]; do
338+
ipath=`dirname "$ipath"`
339+
fname=`basename "$ipath"`
340+
dname=`basename $(dirname "$ipath")`
341+
done
342+
if [[ "$fname" == "arduino" ]]; then
343+
continue
344+
fi
345+
if [[ "$fname" == "config" ]]; then
346+
continue
347+
fi
348+
349+
out_sub="${item#*$ipath}"
350+
out_cpath="$AR_SDK/include/$fname$out_sub"
351+
REL_INC+="-iwithprefixbefore $fname$out_sub "
352+
353+
# KOPIERE HEADER-DATEIEN
354+
for f in `find "$item" -name '*.h'`; do
355+
rel_f=${f#*$item}
356+
rel_p=${rel_f%/*}
357+
mkdir -p "$out_cpath$rel_p"
358+
cp -n $f "$out_cpath$rel_p/"
359+
done
360+
for f in `find "$item" -name '*.hpp'`; do
361+
rel_f=${f#*$item}
362+
rel_p=${rel_f%/*}
363+
mkdir -p "$out_cpath$rel_p"
364+
cp -n $f "$out_cpath$rel_p/"
365+
done
366+
for f in `find "$item" -name '*.inc'`; do
367+
rel_f=${f#*$item}
368+
rel_p=${rel_f%/*}
369+
mkdir -p "$out_cpath$rel_p"
370+
cp -n $f "$out_cpath$rel_p/"
371+
done
372+
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
373+
if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then
374+
mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET"
375+
cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h"
376+
fi
377+
fi
378+
done
379+
380+
# ASFLAGS mit Include-Verkürzung basierend auf REL_INC
326381
echo " ASFLAGS=[" >> "$AR_PLATFORMIO_PY"
327382
if [ "$IS_XTENSA" = "y" ]; then
328383
echo " \"-mlongcalls\"," >> "$AR_PLATFORMIO_PY"
329384
else
330385
echo " \"-march=rv32imc\"," >> "$AR_PLATFORMIO_PY"
331386
fi
332-
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
333-
echo " \"@\" + join(\$PIO_SDK, \"flags\", \"includes\")" >> "$AR_PLATFORMIO_PY"
387+
388+
# Füge Include-Verkürzung aus REL_INC hinzu
389+
if [[ -n "$REL_INC" ]]; then
390+
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
391+
# Konvertiere -iwithprefixbefore zu -iwithprefix
392+
IFS=' ' read -ra rel_inc_array <<< "$REL_INC"
393+
for flag in "${rel_inc_array[@]}"; do
394+
if [[ "$flag" == "-iwithprefixbefore"* ]]; then
395+
# Konvertiere zu -iwithprefix
396+
converted_flag="${flag//-iwithprefixbefore/-iwithprefix}"
397+
echo " \"$converted_flag\"," >> "$AR_PLATFORMIO_PY"
398+
fi
399+
done
400+
fi
401+
334402
echo " ]," >> "$AR_PLATFORMIO_PY"
335403
echo "" >> "$AR_PLATFORMIO_PY"
336404

@@ -367,14 +435,27 @@ echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
367435
echo " ]," >> "$AR_PLATFORMIO_PY"
368436
echo "" >> "$AR_PLATFORMIO_PY"
369437

370-
# CCFLAGS mit Prefix-Optionen für flags/includes
438+
# CCFLAGS mit Include-Verkürzung basierend auf REL_INC
371439
echo " CCFLAGS=[" >> "$AR_PLATFORMIO_PY"
372440
set -- $PIO_CC_FLAGS
373441
for item; do
374442
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
375443
done
376-
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
377-
echo " \"@\" + join(\$PIO_SDK, \"flags\", \"includes\")," >> "$AR_PLATFORMIO_PY"
444+
445+
# Füge Include-Verkürzung aus REL_INC hinzu
446+
if [[ -n "$REL_INC" ]]; then
447+
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
448+
# Konvertiere -iwithprefixbefore zu -iwithprefix
449+
IFS=' ' read -ra rel_inc_array <<< "$REL_INC"
450+
for flag in "${rel_inc_array[@]}"; do
451+
if [[ "$flag" == "-iwithprefixbefore"* ]]; then
452+
# Konvertiere zu -iwithprefix
453+
converted_flag="${flag//-iwithprefixbefore/-iwithprefix}"
454+
echo " \"$converted_flag\"," >> "$AR_PLATFORMIO_PY"
455+
fi
456+
done
457+
fi
458+
378459
echo " \"-MMD\"" >> "$AR_PLATFORMIO_PY"
379460
echo " ]," >> "$AR_PLATFORMIO_PY"
380461
echo "" >> "$AR_PLATFORMIO_PY"
@@ -404,60 +485,6 @@ echo " join(FRAMEWORK_DIR, \"cores\", board_config.get(\"build.core\"))"
404485
echo " ]," >> "$AR_PLATFORMIO_PY"
405486
echo "" >> "$AR_PLATFORMIO_PY"
406487

407-
# KOPIERE HEADER-DATEIEN (nach der Include-Sammlung)
408-
REL_INC=""
409-
set -- $INCLUDES
410-
for item; do
411-
if [[ "$item" != $PWD ]]; then
412-
ipath="$item"
413-
fname=`basename "$ipath"`
414-
dname=`basename $(dirname "$ipath")`
415-
if [[ "$fname" == "main" && "$dname" == $(basename "$PWD") ]]; then
416-
continue
417-
fi
418-
while [[ "$dname" != "components" && "$dname" != "managed_components" && "$dname" != "build" ]]; do
419-
ipath=`dirname "$ipath"`
420-
fname=`basename "$ipath"`
421-
dname=`basename $(dirname "$ipath")`
422-
done
423-
if [[ "$fname" == "arduino" ]]; then
424-
continue
425-
fi
426-
if [[ "$fname" == "config" ]]; then
427-
continue
428-
fi
429-
430-
out_sub="${item#*$ipath}"
431-
out_cpath="$AR_SDK/include/$fname$out_sub"
432-
REL_INC+="-iwithprefixbefore $fname$out_sub "
433-
434-
# KOPIERE HEADER-DATEIEN
435-
for f in `find "$item" -name '*.h'`; do
436-
rel_f=${f#*$item}
437-
rel_p=${rel_f%/*}
438-
mkdir -p "$out_cpath$rel_p"
439-
cp -n $f "$out_cpath$rel_p/"
440-
done
441-
for f in `find "$item" -name '*.hpp'`; do
442-
rel_f=${f#*$item}
443-
rel_p=${rel_f%/*}
444-
mkdir -p "$out_cpath$rel_p"
445-
cp -n $f "$out_cpath$rel_p/"
446-
done
447-
for f in `find "$item" -name '*.inc'`; do
448-
rel_f=${f#*$item}
449-
rel_p=${rel_f%/*}
450-
mkdir -p "$out_cpath$rel_p"
451-
cp -n $f "$out_cpath$rel_p/"
452-
done
453-
# Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17
454-
if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then
455-
mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET"
456-
cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h"
457-
fi
458-
fi
459-
done
460-
461488
AR_LIBS="$LD_LIBS"
462489
PIO_LIBS=""
463490
set -- $LD_LIBS

0 commit comments

Comments
 (0)