@@ -52,13 +52,25 @@ def process_data(self, pathobj: Path, snippet_data: dict):
5252 '''Process the data in a snippet.yml file, after it is loaded into a
5353 python object and validated by pykwalify.'''
5454 def append_value (variable , value ):
55- if variable in ('EXTRA_DTC_OVERLAY_FILE' , 'EXTRA_CONF_FILE' ):
55+ if variable in ('EXTRA_DTC_OVERLAY_FILE' , 'EXTRA_CONF_FILE' , 'kconfig' ):
5656 path = pathobj .parent / value
5757 if not path .is_file ():
5858 _err (f'snippet file { pathobj } : { variable } : file not found: { path } ' )
59+ if variable == 'kconfig' :
60+ basename = os .path .basename (path )
61+ dirname = os .path .dirname (path )
62+ if basename != 'Kconfig' :
63+ _err (f'snippet file { pathobj } is not a Kconfig' )
64+ return f'"{ path .parent .as_posix ()} "'
5965 return f'"{ path .as_posix ()} "'
6066 if variable in ('DTS_EXTRA_CPPFLAGS' ):
6167 return f'"{ value } "'
68+ if variable in ('cmake' ):
69+ cmake_file = os .path .join (pathobj .parent , value , "CMakeLists.txt" )
70+ if not os .path .isfile (cmake_file ):
71+ _err (f'snippet file { pathobj } file not found: { cmake_file } ' )
72+ cmake_path = os .path .join (pathobj .parent , value )
73+ return Path (cmake_path ).resolve ().as_posix ()
6274 _err (f'unknown append variable: { variable } ' )
6375
6476 for variable , value in snippet_data .get ('append' , {}).items ():
@@ -170,9 +182,15 @@ def print_appends_for_board(self, board: str, appends: Appends):
170182 def print_appends (self , appends : Appends , indent : int ):
171183 space = ' ' * indent
172184 for name , values in appends .items ():
173- for value in values :
174- self .print (f'{ space } zephyr_set({ name } { value } SCOPE snippets APPEND)' )
175-
185+ if name in ('kconfig' ):
186+ for value in values :
187+ self .print (f'list(APPEND kconfig_snippets { value } )' )
188+ elif name in ('cmake' ):
189+ for value in values :
190+ self .print (f'#Fixme: { value } )' )
191+ else :
192+ for value in values :
193+ self .print (f'{ space } zephyr_set({ name } { value } SCOPE snippets APPEND)' )
176194 def print (self , * args , ** kwargs ):
177195 kwargs ['file' ] = self .out_file
178196 print (* args , ** kwargs )
0 commit comments