@@ -371,7 +371,7 @@ cat configs/pio_start.txt > "$AR_PLATFORMIO_PY"
371
371
# Process include directories and implement include path shortening
372
372
# This is equivalent to the Python shorthen_includes() function
373
373
# We collect shortened include paths and copy all header files to the esp32-arduino-libs
374
- REL_INC=" " # Will contain the shortened include paths
374
+ REL_INC=" " # Will contain the shortened include paths for Windows
375
375
set -- $INCLUDES
376
376
377
377
for item; do
@@ -406,7 +406,7 @@ for item; do
406
406
out_sub=" ${item#* $ipath } "
407
407
out_cpath=" $AR_SDK /include/$fname$out_sub "
408
408
409
- # Add to shortened include paths (using GCC's -iwithprefix mechanism)
409
+ # Add to shortened include paths for Windows (using GCC's -iwithprefix mechanism)
410
410
REL_INC+=" -iwithprefixbefore $fname$out_sub "
411
411
412
412
# Copy all header files to the esp32-arduino-libs include directory
@@ -449,18 +449,21 @@ else
449
449
echo " \" -march=rv32imc\" ," >> " $AR_PLATFORMIO_PY " # RISC-V architecture
450
450
fi
451
451
452
- # Add shortened include paths for assembly files using esp32-arduino-libs structure
452
+ # Add shortened include paths for assembly files only on Windows
453
453
# This implements the same logic as the Python shorthen_includes() function
454
454
if [[ -n " $REL_INC " ]]; then
455
- echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" esp32-arduino-libs\" , \" $IDF_TARGET \" , \" include\" )," >> " $AR_PLATFORMIO_PY "
455
+ echo " # Include path shortening for Windows command line length limits" >> " $AR_PLATFORMIO_PY "
456
+ echo " *([" >> " $AR_PLATFORMIO_PY "
457
+ echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" esp32-arduino-libs\" , \" $IDF_TARGET \" , \" include\" )," >> " $AR_PLATFORMIO_PY "
458
+
456
459
# Parse the REL_INC string and convert -iwithprefixbefore to -iwithprefix
457
460
IFS=' ' read -ra rel_inc_array <<< " $REL_INC"
458
461
i=0
459
462
while [ $i -lt ${# rel_inc_array[@]} ]; do
460
463
if [[ " ${rel_inc_array[$i]} " == " -iwithprefixbefore" ]]; then
461
464
if [ $(( i+ 1 )) -lt ${# rel_inc_array[@]} ]; then
462
465
path=" ${rel_inc_array[$((i+1))]} "
463
- echo " \" -iwithprefix/$path \" ," >> " $AR_PLATFORMIO_PY "
466
+ echo " \" -iwithprefix/$path \" ," >> " $AR_PLATFORMIO_PY "
464
467
i=$(( i+ 2 )) # Skip both flag and path
465
468
else
466
469
i=$(( i+ 1 ))
@@ -469,6 +472,7 @@ if [[ -n "$REL_INC" ]]; then
469
472
i=$(( i+ 1 ))
470
473
fi
471
474
done
475
+ echo " ] if platform.system() == \" Windows\" else [])," >> " $AR_PLATFORMIO_PY "
472
476
fi
473
477
474
478
echo " ]," >> " $AR_PLATFORMIO_PY "
@@ -510,24 +514,27 @@ echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
510
514
echo " ]," >> " $AR_PLATFORMIO_PY "
511
515
echo " " >> " $AR_PLATFORMIO_PY "
512
516
513
- # Generate CCFLAGS (Common C/C++ compiler flags) with shortened include paths
517
+ # Generate CCFLAGS (Common C/C++ compiler flags) with shortened include paths only on Windows
514
518
echo " CCFLAGS=[" >> " $AR_PLATFORMIO_PY "
515
519
set -- $PIO_CC_FLAGS
516
520
for item; do
517
521
echo " \" $item \" ," >> " $AR_PLATFORMIO_PY "
518
522
done
519
523
520
- # Add shortened include paths for C/C++ compilation using esp32-arduino-libs structure
521
- # This is the core of the include path shortening mechanism
524
+ # Add shortened include paths for C/C++ compilation only on Windows
525
+ # This is the core of the include path shortening mechanism for Windows command line limits
522
526
if [[ -n " $REL_INC " ]]; then
523
- echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" esp32-arduino-libs\" , \" $IDF_TARGET \" , \" include\" )," >> " $AR_PLATFORMIO_PY "
527
+ echo " # Include path shortening for Windows command line length limits" >> " $AR_PLATFORMIO_PY "
528
+ echo " *([" >> " $AR_PLATFORMIO_PY "
529
+ echo " \" -iprefix\" , join(FRAMEWORK_DIR, \" tools\" , \" esp32-arduino-libs\" , \" $IDF_TARGET \" , \" include\" )," >> " $AR_PLATFORMIO_PY "
530
+
524
531
IFS=' ' read -ra rel_inc_array <<< " $REL_INC"
525
532
i=0
526
533
while [ $i -lt ${# rel_inc_array[@]} ]; do
527
534
if [[ " ${rel_inc_array[$i]} " == " -iwithprefixbefore" ]]; then
528
535
if [ $(( i+ 1 )) -lt ${# rel_inc_array[@]} ]; then
529
536
path=" ${rel_inc_array[$((i+1))]} "
530
- echo " \" -iwithprefix/$path \" ," >> " $AR_PLATFORMIO_PY "
537
+ echo " \" -iwithprefix/$path \" ," >> " $AR_PLATFORMIO_PY "
531
538
i=$(( i+ 2 ))
532
539
else
533
540
i=$(( i+ 1 ))
@@ -536,6 +543,7 @@ if [[ -n "$REL_INC" ]]; then
536
543
i=$(( i+ 1 ))
537
544
fi
538
545
done
546
+ echo " ] if platform.system() == \" Windows\" else [])," >> " $AR_PLATFORMIO_PY "
539
547
fi
540
548
541
549
echo " \" -MMD\" " >> " $AR_PLATFORMIO_PY " # Generate dependency files
@@ -568,10 +576,47 @@ echo " ]," >> "$AR_PLATFORMIO_PY"
568
576
echo " " >> " $AR_PLATFORMIO_PY "
569
577
570
578
# Generate CPPPATH (Include paths for PlatformIO)
571
- # Only include Arduino Core paths, not framework headers (those use shortened paths)
579
+ # For non-Windows: All include paths go here for best performance
580
+ # For Windows: Only Arduino Core paths, framework headers use shortened paths
572
581
echo " CPPPATH=[" >> " $AR_PLATFORMIO_PY "
573
582
echo " join($PIO_SDK , board_config.get(\" build.arduino.memory_type\" , (board_config.get(\" build.flash_mode\" , \" dio\" ) + \" _qspi\" )), \" include\" )," >> " $AR_PLATFORMIO_PY "
574
- echo " join(FRAMEWORK_DIR, \" cores\" , board_config.get(\" build.core\" ))" >> " $AR_PLATFORMIO_PY "
583
+ echo " join(FRAMEWORK_DIR, \" cores\" , board_config.get(\" build.core\" ))," >> " $AR_PLATFORMIO_PY "
584
+
585
+ # Add full include paths for non-Windows platforms (better performance)
586
+ if [[ -n " $INCLUDES " ]]; then
587
+ echo " # Full include paths for better performance on non-Windows platforms" >> " $AR_PLATFORMIO_PY "
588
+ echo " *([] if platform.system() == \" Windows\" else [" >> " $AR_PLATFORMIO_PY "
589
+
590
+ set -- $INCLUDES
591
+ for item; do
592
+ if [[ " $item " != $PWD ]]; then
593
+ # Skip Arduino and config directories (handled separately)
594
+ ipath=" $item "
595
+ fname=` basename " $ipath " `
596
+ dname=` basename $( dirname " $ipath " ) `
597
+
598
+ if [[ " $fname " == " main" && " $dname " == $( basename " $PWD " ) ]]; then
599
+ continue
600
+ fi
601
+
602
+ # Find component root
603
+ while [[ " $dname " != " components" && " $dname " != " managed_components" && " $dname " != " build" ]]; do
604
+ ipath=` dirname " $ipath " `
605
+ fname=` basename " $ipath " `
606
+ dname=` basename $( dirname " $ipath " ) `
607
+ done
608
+
609
+ if [[ " $fname " == " arduino" || " $fname " == " config" ]]; then
610
+ continue
611
+ fi
612
+
613
+ echo " \" $item \" ," >> " $AR_PLATFORMIO_PY "
614
+ fi
615
+ done
616
+
617
+ echo " ])," >> " $AR_PLATFORMIO_PY "
618
+ fi
619
+
575
620
echo " ]," >> " $AR_PLATFORMIO_PY "
576
621
echo " " >> " $AR_PLATFORMIO_PY "
577
622
0 commit comments