@@ -50,6 +50,37 @@ def build_target(target_name: str, ctx: Context, args: PropertyDict) -> None:
5050 ensure_build_directory (args , ctx .info_name )
5151 run_target (target_name , args , force_progression = GENERATORS [args .generator ].get ('force_progression' , False ))
5252
53+ def confserver_target (target_name : str , ctx : Context , args : PropertyDict , buffer_size : int ) -> None :
54+ """
55+ Execute the idf.py confserver command with the specified buffer size.
56+ """
57+ ensure_build_directory (args , ctx .info_name )
58+ if buffer_size < 2048 :
59+ yellow_print (
60+ f'WARNING: The specified buffer size { buffer_size } KB is less than the '
61+ 'recommended minimum of 2048 KB for idf.py confserver. Consider increasing it to at least 2048 KB '
62+ 'by setting environment variable IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
63+ 'idf.py confserver --buffer-size <buffer size in KB>.'
64+ )
65+ try :
66+ run_target (
67+ target_name ,
68+ args ,
69+ force_progression = GENERATORS [args .generator ].get ('force_progression' , False ),
70+ buffer_size = buffer_size ,
71+ )
72+ except ValueError as e :
73+ if str (e ) == 'Separator is not found, and chunk exceed the limit' :
74+ # Buffer size too small/one-line output of the command too long
75+ raise FatalError (
76+ f'ERROR: Command failed with an error message "{ e } ". '
77+ 'Try increasing the buffer size to 2048 (or higher) by setting environment variable '
78+ 'IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
79+ 'idf.py confserver --buffer-size <buffer size in KB>.'
80+ )
81+ else :
82+ raise
83+
5384 def size_target (
5485 target_name : str ,
5586 ctx : Context ,
@@ -520,9 +551,22 @@ def help_and_exit(action: str, ctx: Context, param: List, json_option: bool, add
520551 ],
521552 },
522553 'confserver' : {
523- 'callback' : build_target ,
554+ 'callback' : confserver_target ,
524555 'help' : 'Run JSON configuration server.' ,
525- 'options' : global_options ,
556+ 'options' : global_options
557+ + [
558+ {
559+ 'names' : ['--buffer-size' ],
560+ 'help' : (
561+ 'Set the buffer size (in KB) in order to accommodate initial confserver response.'
562+ 'Default value and recommended minimum is 2048 (KB), but it might need to be '
563+ 'increased for very large projects.'
564+ ),
565+ 'type' : int ,
566+ 'default' : 2048 ,
567+ 'envvar' : 'IDF_CONFSERVER_BUFFER_SIZE' ,
568+ }
569+ ],
526570 },
527571 'size' : {
528572 'callback' : size_target ,
0 commit comments