@@ -46,6 +46,37 @@ def build_target(target_name: str, ctx: Context, args: PropertyDict) -> None:
4646 ensure_build_directory (args , ctx .info_name )
4747 run_target (target_name , args , force_progression = GENERATORS [args .generator ].get ('force_progression' , False ))
4848
49+ def confserver_target (target_name : str , ctx : Context , args : PropertyDict , buffer_size : int ) -> None :
50+ """
51+ Execute the idf.py confserver command with the specified buffer size.
52+ """
53+ ensure_build_directory (args , ctx .info_name )
54+ if buffer_size < 2048 :
55+ yellow_print (
56+ f'WARNING: The specified buffer size { buffer_size } KB is less than the '
57+ 'recommended minimum of 2048 KB for idf.py confserver. Consider increasing it to at least 2048 KB '
58+ 'by setting environment variable IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
59+ 'idf.py confserver --buffer-size <buffer size in KB>.'
60+ )
61+ try :
62+ run_target (
63+ target_name ,
64+ args ,
65+ force_progression = GENERATORS [args .generator ].get ('force_progression' , False ),
66+ buffer_size = buffer_size ,
67+ )
68+ except ValueError as e :
69+ if str (e ) == 'Separator is not found, and chunk exceed the limit' :
70+ # Buffer size too small/one-line output of the command too long
71+ raise FatalError (
72+ f'ERROR: Command failed with an error message "{ e } ". '
73+ 'Try increasing the buffer size to 2048 (or higher) by setting environment variable '
74+ 'IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
75+ 'idf.py confserver --buffer-size <buffer size in KB>.'
76+ )
77+ else :
78+ raise
79+
4980 def size_target (
5081 target_name : str , ctx : Context , args : PropertyDict , output_format : str , output_file : str , diff_map_file : str
5182 ) -> None :
@@ -481,9 +512,22 @@ def help_and_exit(action: str, ctx: Context, param: list, json_option: bool, add
481512 ],
482513 },
483514 'confserver' : {
484- 'callback' : build_target ,
515+ 'callback' : confserver_target ,
485516 'help' : 'Run JSON configuration server.' ,
486- 'options' : global_options ,
517+ 'options' : global_options
518+ + [
519+ {
520+ 'names' : ['--buffer-size' ],
521+ 'help' : (
522+ 'Set the buffer size (in KB) in order to accommodate initial confserver response.'
523+ 'Default value and recommended minimum is 2048 (KB), but it might need to be '
524+ 'increased for very large projects.'
525+ ),
526+ 'type' : int ,
527+ 'default' : 2048 ,
528+ 'envvar' : 'IDF_CONFSERVER_BUFFER_SIZE' ,
529+ }
530+ ],
487531 },
488532 'size' : {
489533 'callback' : size_target ,
0 commit comments