@@ -273,13 +273,15 @@ def load_target_configurations(cmake_codemodel, cmake_api_reply_dir):
273
273
return configs
274
274
275
275
276
- def build_library (default_env , lib_config , project_src_dir , prepend_dir = None ):
276
+ def build_library (
277
+ default_env , lib_config , project_src_dir , prepend_dir = None , debug_allowed = True
278
+ ):
277
279
lib_name = lib_config ["nameOnDisk" ]
278
280
lib_path = lib_config ["paths" ]["build" ]
279
281
if prepend_dir :
280
282
lib_path = os .path .join (prepend_dir , lib_path )
281
283
lib_objects = compile_source_files (
282
- lib_config , default_env , project_src_dir , prepend_dir
284
+ lib_config , default_env , project_src_dir , prepend_dir , debug_allowed
283
285
)
284
286
return default_env .Library (
285
287
target = os .path .join ("$BUILD_DIR" , lib_path , lib_name ), source = lib_objects
@@ -553,11 +555,11 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
553
555
)
554
556
555
557
556
- def prepare_build_envs (config , default_env ):
558
+ def prepare_build_envs (config , default_env , debug_allowed = True ):
557
559
build_envs = []
558
560
target_compile_groups = config .get ("compileGroups" )
559
561
560
- is_build_type_debug = "debug" in env .GetBuildType ()
562
+ is_build_type_debug = "debug" in env .GetBuildType () and debug_allowed
561
563
for cg in target_compile_groups :
562
564
includes = []
563
565
sys_includes = []
@@ -587,8 +589,8 @@ def prepare_build_envs(config, default_env):
587
589
return build_envs
588
590
589
591
590
- def compile_source_files (config , default_env , project_src_dir , prepend_dir = None ):
591
- build_envs = prepare_build_envs (config , default_env )
592
+ def compile_source_files (config , default_env , project_src_dir , prepend_dir = None , debug_allowed = True ):
593
+ build_envs = prepare_build_envs (config , default_env , debug_allowed )
592
594
objects = []
593
595
components_dir = fs .to_unix_path (os .path .join (FRAMEWORK_DIR , "components" ))
594
596
for source in config .get ("sources" , []):
@@ -703,7 +705,7 @@ def find_lib_deps(components_map, elf_config, link_args, ignore_components=None)
703
705
return result
704
706
705
707
706
- def build_bootloader ():
708
+ def build_bootloader (sdk_config ):
707
709
bootloader_src_dir = os .path .join (
708
710
FRAMEWORK_DIR , "components" , "bootloader" , "subproject"
709
711
)
@@ -743,7 +745,15 @@ def build_bootloader():
743
745
target_configs , ["STATIC_LIBRARY" , "OBJECT_LIBRARY" ]
744
746
)
745
747
746
- build_components (bootloader_env , components_map , bootloader_src_dir , "bootloader" )
748
+ # Note: By default the size of bootloader is limited to 0x2000 bytes,
749
+ # in debug mode the footprint size can be easily grow beyond this limit
750
+ build_components (
751
+ bootloader_env ,
752
+ components_map ,
753
+ bootloader_src_dir ,
754
+ "bootloader" ,
755
+ debug_allowed = sdk_config .get ("BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG" , False ),
756
+ )
747
757
link_args = extract_link_args (elf_config )
748
758
extra_flags = filter_args (link_args ["LINKFLAGS" ], ["-T" , "-u" ])
749
759
link_args ["LINKFLAGS" ] = sorted (
@@ -788,10 +798,12 @@ def get_components_map(target_configs, target_types, ignore_components=None):
788
798
return result
789
799
790
800
791
- def build_components (env , components_map , project_src_dir , prepend_dir = None ):
801
+ def build_components (
802
+ env , components_map , project_src_dir , prepend_dir = None , debug_allowed = True
803
+ ):
792
804
for k , v in components_map .items ():
793
805
components_map [k ]["lib" ] = build_library (
794
- env , v ["config" ], project_src_dir , prepend_dir
806
+ env , v ["config" ], project_src_dir , prepend_dir , debug_allowed
795
807
)
796
808
797
809
@@ -1232,7 +1244,7 @@ def _get_installed_pip_packages():
1232
1244
# Compile bootloader
1233
1245
#
1234
1246
1235
- env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , build_bootloader ())
1247
+ env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , build_bootloader (sdk_config ))
1236
1248
1237
1249
#
1238
1250
# Target: ESP-IDF menuconfig
0 commit comments