Skip to content

Commit 08cbc3c

Browse files
authored
Update copy-libs.sh
1 parent f9dd3ca commit 08cbc3c

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

tools/copy-libs.sh

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ function get_actual_path(){
5252
fi
5353
}
5454

55-
# Include-Pfad-Verkürzung Funktionen (basierend auf pioarduino Python-Implementierung)
56-
IS_INTEGRATION_DUMP=${IS_INTEGRATION_DUMP:-false}
57-
58-
# Das Framework SDK Verzeichnis für PlatformIO (Runtime)
59-
FRAMEWORK_SDK_DIR="$AR_SDK"
60-
61-
# Das Build-Zeit Framework-Verzeichnis (ESP-IDF)
55+
# Include-Pfad-Verkürzung Funktionen (für statische Generierung)
56+
# Das Build-Zeit Framework-Verzeichnis (ESP-IDF Quellen)
6257
if [ -n "$IDF_PATH" ]; then
6358
BUILD_FRAMEWORK_DIR="$IDF_PATH"
6459
elif [ -d "../esp-idf" ]; then
@@ -70,19 +65,19 @@ fi
7065
is_framework_subfolder() {
7166
local potential_subfolder="$1"
7267

73-
# Prüfe ob absoluter Pfad (analog zu os.path.isabs)
68+
# Prüfe ob absoluter Pfad
7469
if [[ "$potential_subfolder" != /* ]]; then
7570
return 1
7671
fi
7772

78-
# Prüfe ob auf gleichem Laufwerk (analog zu os.path.splitdrive)
73+
# Prüfe ob auf gleichem Laufwerk
7974
local sdk_drive="${BUILD_FRAMEWORK_DIR%%:*}"
8075
local sub_drive="${potential_subfolder%%:*}"
8176
if [[ "$sdk_drive" != "$sub_drive" ]]; then
8277
return 1
8378
fi
8479

85-
# Prüfe ob Unterordner (analog zu os.path.commonpath)
80+
# Prüfe ob Unterordner (analog zu Python os.path.commonpath)
8681
case "$potential_subfolder" in
8782
"$BUILD_FRAMEWORK_DIR"*)
8883
return 0
@@ -95,13 +90,6 @@ is_framework_subfolder() {
9590

9691
shorten_includes() {
9792
local includes_str="$1"
98-
99-
# Für IDE-Integration keine Verkürzung (analog zur Python-Funktion)
100-
if [[ "$IS_INTEGRATION_DUMP" == "true" ]]; then
101-
echo "$includes_str||"
102-
return
103-
fi
104-
10593
local shortened_includes=""
10694
local generic_includes=""
10795

@@ -111,9 +99,9 @@ shorten_includes() {
11199
for inc in "${includes_array[@]}"; do
112100
if [[ -n "$inc" ]]; then
113101
if is_framework_subfolder "$inc"; then
114-
# Berechne relativen Pfad (analog zu os.path.relpath)
102+
# Berechne relativen Pfad (analog zu Python os.path.relpath)
115103
local rel_path="${inc#$BUILD_FRAMEWORK_DIR}"
116-
rel_path="${rel_path#/}"
104+
rel_path="${rel_path#/}" # Entferne führenden Slash
117105
if [[ -n "$rel_path" ]]; then
118106
shortened_includes+=" -iwithprefix/$rel_path"
119107
fi
@@ -123,8 +111,8 @@ shorten_includes() {
123111
fi
124112
done
125113

126-
# Rückgabe: "generic_includes|shortened_includes|framework_dir"
127-
echo "$generic_includes|$shortened_includes|$BUILD_FRAMEWORK_DIR"
114+
# Rückgabe: "generic_includes|shortened_includes"
115+
echo "$generic_includes|$shortened_includes"
128116
}
129117

130118
#
@@ -213,12 +201,10 @@ for item in "${@:2:${#@}-5}"; do
213201
fi
214202
done
215203

216-
# Wende Include-Verkürzung an (analog zur Python-Funktion)
204+
# Wende Include-Verkürzung an
217205
SHORTENED_RESULT=$(shorten_includes "$INCLUDES_RAW")
218-
GENERIC_INCLUDES="${SHORTENED_RESULT%%|*}"
206+
GENERIC_INCLUDES="${SHORTENED_RESULT%|*}"
219207
SHORTENED_INCLUDES="${SHORTENED_RESULT#*|}"
220-
SHORTENED_INCLUDES="${SHORTENED_INCLUDES%%|*}"
221-
USED_FRAMEWORK_DIR="${SHORTENED_RESULT##*|}"
222208

223209
#collect asm-flags
224210
str=`cat build/compile_commands.json | grep arduino-lib-builder-as.S | grep command | cut -d':' -f2 | cut -d',' -f1`
@@ -408,15 +394,15 @@ mkdir -p "$AR_SDK"
408394
AR_PLATFORMIO_PY="$AR_SDK/pioarduino-build.py"
409395
cat configs/pio_start.txt > "$AR_PLATFORMIO_PY"
410396

411-
# ASFLAGS mit Include-Verkürzung (analog zur Python-Funktion)
397+
# ASFLAGS mit statischer Include-Verkürzung
412398
echo " ASFLAGS=[" >> "$AR_PLATFORMIO_PY"
413399
if [ "$IS_XTENSA" = "y" ]; then
414400
echo " \"-mlongcalls\"" >> "$AR_PLATFORMIO_PY"
415401
else
416402
echo " \"-march=rv32imc\"" >> "$AR_PLATFORMIO_PY"
417403
fi
418404

419-
# Füge verkürzte Includes hinzu (analog zur Python-Implementierung)
405+
# Füge statische Include-Verkürzung hinzu
420406
if [[ -n "$SHORTENED_INCLUDES" ]]; then
421407
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
422408
IFS=' ' read -ra shortened_array <<< "$SHORTENED_INCLUDES"
@@ -463,14 +449,14 @@ echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
463449
echo " ]," >> "$AR_PLATFORMIO_PY"
464450
echo "" >> "$AR_PLATFORMIO_PY"
465451

466-
# CCFLAGS mit Include-Verkürzung (analog zur Python-Funktion)
452+
# CCFLAGS mit statischer Include-Verkürzung
467453
echo " CCFLAGS=[" >> "$AR_PLATFORMIO_PY"
468454
set -- $PIO_CC_FLAGS
469455
for item; do
470456
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
471457
done
472458

473-
# Füge verkürzte Includes hinzu (analog zur Python-Implementierung)
459+
# Füge statische Include-Verkürzung hinzu
474460
if [[ -n "$SHORTENED_INCLUDES" ]]; then
475461
echo " \"-iprefix\", join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\")," >> "$AR_PLATFORMIO_PY"
476462
IFS=' ' read -ra shortened_array <<< "$SHORTENED_INCLUDES"
@@ -503,10 +489,10 @@ echo " '-Wl,-Map=\"%s\"' % join(\"\${BUILD_DIR}\", \"\${PROGNAME}.map\")"
503489
echo " ]," >> "$AR_PLATFORMIO_PY"
504490
echo "" >> "$AR_PLATFORMIO_PY"
505491

506-
# CPPPATH nur mit generischen Includes (analog zur Python-Funktion)
492+
# CPPPATH nur mit generischen Includes und Arduino Core
507493
echo " CPPPATH=[" >> "$AR_PLATFORMIO_PY"
508494

509-
# Füge generische Includes hinzu (nicht-Framework Pfade)
495+
# Füge generische (nicht-Framework) Includes hinzu
510496
if [[ -n "$GENERIC_INCLUDES" ]]; then
511497
IFS=' ' read -ra generic_array <<< "$GENERIC_INCLUDES"
512498
for inc in "${generic_array[@]}"; do
@@ -516,7 +502,7 @@ if [[ -n "$GENERIC_INCLUDES" ]]; then
516502
done
517503
fi
518504

519-
# Bestehende Include-Verarbeitung für kopierte Headers
505+
# Bestehende CPPPATH-Logik für kopierte Headers
520506
REL_INC=""
521507
set -- $INCLUDES
522508

0 commit comments

Comments
 (0)