@@ -173,6 +173,9 @@ def update_sdkconfig_from_board_types(self, device_types: Set[str], peripheral_t
173173 self .logger .info (f" Successfully updated sdkconfig with { len (result ['enabled' ])} changes" )
174174 else :
175175 self .logger .info (f' Successfully created/updated sdkconfig file' )
176+
177+ # Delete build/config/sdkconfig.json after updating sdkconfig
178+ self ._delete_sdkconfig_json (sdkconfig_path )
176179 except Exception as e :
177180 self .logger .error (f'Error writing sdkconfig: { e } ' )
178181 return result
@@ -542,3 +545,25 @@ def _apply_target_updates(self, sdkconfig_content: str, chip_name: str) -> Tuple
542545
543546 return sdkconfig_content , changes
544547
548+ def _delete_sdkconfig_json (self , sdkconfig_path : str ) -> None :
549+ """
550+ Delete build/config/sdkconfig.json file after updating sdkconfig.
551+
552+ Args:
553+ sdkconfig_path: Path to sdkconfig file
554+ """
555+ try :
556+ # Get project root directory from sdkconfig path
557+ sdkconfig_file = Path (sdkconfig_path )
558+ project_root = sdkconfig_file .parent
559+ # Build path to build/config/sdkconfig.json
560+ sdkconfig_json_path = project_root / 'build' / 'config' / 'sdkconfig.json'
561+ # Delete the file if it exists
562+ if sdkconfig_json_path .exists ():
563+ sdkconfig_json_path .unlink ()
564+ self .logger .debug (f' Deleted { sdkconfig_json_path } ' )
565+ else :
566+ self .logger .debug (f' { sdkconfig_json_path } does not exist, skipping deletion' )
567+ except Exception as e :
568+ # Log warning but don't fail the operation
569+ self .logger .warning (f'⚠️ Failed to delete build/config/sdkconfig.json: { e } ' )
0 commit comments