@@ -48,11 +48,11 @@ class Snippet:
4848 appends : Appends = field (default_factory = _new_append )
4949 board2appends : Dict [str , Appends ] = field (default_factory = _new_board2appends )
5050
51- def process_data (self , pathobj : Path , snippet_data : dict ):
51+ def process_data (self , pathobj : Path , snippet_data : dict , sysbuild : bool ):
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 ('SB_EXTRA_CONF_FILE' , ' EXTRA_DTC_OVERLAY_FILE' , 'EXTRA_CONF_FILE' ):
5656 path = pathobj .parent / value
5757 if not path .is_file ():
5858 _err (f'snippet file { pathobj } : { variable } : file not found: { path } ' )
@@ -62,14 +62,18 @@ def append_value(variable, value):
6262 _err (f'unknown append variable: { variable } ' )
6363
6464 for variable , value in snippet_data .get ('append' , {}).items ():
65- self .appends [variable ].append (append_value (variable , value ))
65+ if (sysbuild is True and variable [0 :3 ] == 'SB_' ) or \
66+ (sysbuild is False and variable [0 :3 ] != 'SB_' ):
67+ self .appends [variable ].append (append_value (variable , value ))
6668 for board , settings in snippet_data .get ('boards' , {}).items ():
6769 if board .startswith ('/' ) and not board .endswith ('/' ):
6870 _err (f"snippet file { pathobj } : board { board } starts with '/', so "
6971 "it must end with '/' to use a regular expression" )
7072 for variable , value in settings .get ('append' , {}).items ():
71- self .board2appends [board ][variable ].append (
72- append_value (variable , value ))
73+ if (sysbuild is True and variable [0 :3 ] == 'SB_' ) or \
74+ (sysbuild is False and variable [0 :3 ] != 'SB_' ):
75+ self .board2appends [board ][variable ].append (
76+ append_value (variable , value ))
7377
7478class Snippets (UserDict ):
7579 '''Type for all the information we have discovered about all snippets.
@@ -212,6 +216,8 @@ def parse_args():
212216 parser .add_argument ('--cmake-out' , type = Path ,
213217 help = '''file to write cmake output to; include()
214218 this file after calling this script''' )
219+ parser .add_argument ('--sysbuild' , action = "store_true" ,
220+ help = '''set if this is running as sysbuild''' )
215221 return parser .parse_args ()
216222
217223def setup_logging ():
@@ -234,7 +240,7 @@ def process_snippets(args: argparse.Namespace) -> Snippets:
234240 # Process each path in snippet_root in order, adjusting
235241 # snippets as needed for each one.
236242 for root in args .snippet_root :
237- process_snippets_in (root , snippets )
243+ process_snippets_in (root , snippets , args . sysbuild )
238244
239245 return snippets
240246
@@ -250,11 +256,11 @@ def find_snippets_in_roots(requested_snippets, snippet_roots) -> Snippets:
250256 # Process each path in snippet_root in order, adjusting
251257 # snippets as needed for each one.
252258 for root in snippet_roots :
253- process_snippets_in (root , snippets )
259+ process_snippets_in (root , snippets , False )
254260
255261 return snippets
256262
257- def process_snippets_in (root_dir : Path , snippets : Snippets ) -> None :
263+ def process_snippets_in (root_dir : Path , snippets : Snippets , sysbuild : bool ) -> None :
258264 '''Process snippet.yml files in *root_dir*,
259265 updating *snippets* as needed.'''
260266
@@ -276,7 +282,7 @@ def process_snippets_in(root_dir: Path, snippets: Snippets) -> None:
276282 name = snippet_data ['name' ]
277283 if name not in snippets :
278284 snippets [name ] = Snippet (name = name )
279- snippets [name ].process_data (snippet_yml , snippet_data )
285+ snippets [name ].process_data (snippet_yml , snippet_data , sysbuild )
280286 snippets .paths .add (snippet_yml )
281287
282288def load_snippet_yml (snippet_yml : Path ) -> dict :
0 commit comments