@@ -422,6 +422,35 @@ def build_arduino_framework():
422
422
)
423
423
424
424
425
+ def configure_exceptions (sdk_params ):
426
+ # Exceptions might be configured using a special PIO macro or
427
+ # directly in sdkconfig.h
428
+ cppdefines = env .Flatten (env .get ("CPPDEFINES" , []))
429
+ pio_exceptions = "PIO_FRAMEWORK_ESP_IDF_ENABLE_EXCEPTIONS" in cppdefines
430
+ config_exceptions = int (sdk_params .get ("CONFIG_CXX_EXCEPTIONS" , 0 )) != 0
431
+
432
+ if pio_exceptions or config_exceptions :
433
+ # remove unnecessary flag defined in main.py that disables exceptions
434
+ try :
435
+ index = env ['CXXFLAGS' ].index ("-fno-exceptions" )
436
+ if index > 0 :
437
+ env ['CXXFLAGS' ].remove ("-fno-exceptions" )
438
+ except IndexError :
439
+ pass
440
+
441
+ env .Append (CXXFLAGS = ["-fexceptions" ])
442
+
443
+ if pio_exceptions :
444
+ env .Append (
445
+ CPPDEFINES = [
446
+ ("CONFIG_CXX_EXCEPTIONS" , 1 ),
447
+ ("CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE" , 0 )
448
+ ]
449
+ )
450
+ else :
451
+ env .Append (LINKFLAGS = ["-u" , "__cxx_fatal_exception" ])
452
+
453
+
425
454
env .Prepend (
426
455
CPPPATH = [
427
456
join (FRAMEWORK_DIR , "components" , "app_trace" , "include" ),
@@ -569,31 +598,6 @@ def build_arduino_framework():
569
598
]
570
599
)
571
600
572
- cppdefines = env .Flatten (env .get ("CPPDEFINES" , []))
573
-
574
- if "PIO_FRAMEWORK_ESP_IDF_ENABLE_EXCEPTIONS" in cppdefines :
575
-
576
- # remove unnecessary flag defined in main.py that disables exceptions
577
- try :
578
- index = env ['CXXFLAGS' ].index ("-fno-exceptions" )
579
- if index > 0 :
580
- env ['CXXFLAGS' ].remove ("-fno-exceptions" )
581
- except IndexError :
582
- pass
583
-
584
- env .Append (
585
- CPPDEFINES = [
586
- ("CONFIG_CXX_EXCEPTIONS" , 1 ),
587
- ("CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE" , 0 )
588
- ],
589
-
590
- CXXFLAGS = ["-fexceptions" ]
591
- )
592
-
593
- else :
594
- env .Append (LINKFLAGS = ["-u" , "__cxx_fatal_exception" ])
595
-
596
-
597
601
#
598
602
# ESP-IDF doesn't need assembler-with-cpp option
599
603
#
@@ -631,6 +635,8 @@ def build_arduino_framework():
631
635
632
636
sdk_params = get_sdk_configuration (sdk_config_file )
633
637
638
+ configure_exceptions (sdk_params )
639
+
634
640
#
635
641
# Generate partition table
636
642
#
0 commit comments