Lines Matching full:snippets

7 '''Internal snippets tool.
8 This is part of the build system's support for snippets.
78 class Snippets(UserDict): class
79 '''Type for all the information we have discovered about all snippets.
81 Any additional global attributes about all snippets go here as
96 '''Helper class for printing a Snippets's semantics to a .cmake
97 include file for use by snippets.cmake.'''
99 def __init__(self, snippets: Snippets, out_file): argument
100 self.snippets = snippets
107 snippets = self.snippets
108 snippet_names = sorted(snippets.keys())
112 snippets.paths = set(map(lambda x: str(PurePosixPath(x)), snippets.paths))
114 for this_snippet in snippets:
115 for snippet_append in (snippets[this_snippet].appends):
116 snippets[this_snippet].appends[snippet_append] = \
118 snippets[this_snippet].appends[snippet_append]))
121 sorted(f'"{path}"' for path in snippets.paths))
126 # This file contains build system settings derived from your snippets.
128 # of Zephyr's snippets CMake module.
130 # See the Snippets guide in the Zephyr documentation for more information.
135 # Global information about all snippets.
143 # Create variable scope for snippets build variables
144 zephyr_create_scope(snippets)
147 for snippet_name in snippets.requested:
148 self.print_cmake_for(snippets[snippet_name])
178 self.print(f'{space}zephyr_set({name} {value} SCOPE snippets APPEND)')
190 # The name of the file which contains metadata about the snippets
202 LOG = logging.getLogger('snippets')
208 parser = argparse.ArgumentParser(description='snippets helper',
213 parser.add_argument('--snippet', dest='snippets', default=[], action='append',
231 def process_snippets(args: argparse.Namespace) -> Snippets:
233 by recursive search. Return a Snippets object describing
236 # This will contain information about all the snippets
238 snippets = Snippets(requested=args.snippets)
241 # snippets as needed for each one.
243 process_snippets_in(root, snippets, args.sysbuild)
245 return snippets
247 def find_snippets_in_roots(requested_snippets, snippet_roots) -> Snippets:
249 by recursive search. Return a Snippets object describing
252 # This will contain information about all the snippets
254 snippets = Snippets(requested=requested_snippets)
257 # snippets as needed for each one.
259 process_snippets_in(root, snippets, False)
261 return snippets
263 def process_snippets_in(root_dir: Path, snippets: Snippets, sysbuild: bool) -> None: argument
265 updating *snippets* as needed.'''
272 snippets_dir = root_dir / 'snippets'
283 if name not in snippets:
284 snippets[name] = Snippet(name=name)
285 snippets[name].process_data(snippet_yml, snippet_data, sysbuild)
286 snippets.paths.add(snippet_yml)
297 _err(f'snippets file {snippet_yml} is invalid YAML')
320 def check_for_errors(snippets: Snippets) -> None: argument
321 unknown_snippets = sorted(snippet for snippet in snippets.requested
322 if snippet not in snippets)
324 all_snippets = '\n '.join(sorted(snippets))
326 snippets not found: {', '.join(unknown_snippets)}
327 Please choose from among the following snippets:
330 def write_cmake_out(snippets: Snippets, cmake_out: Path) -> None: argument
332 reflects the information in *snippets*.
335 detail and are not meant to be used outside of snippets.cmake.'''
339 SnippetToCMakePrinter(snippets, f).print_cmake()
345 snippets = process_snippets(args)
346 check_for_errors(snippets)
350 write_cmake_out(snippets, args.cmake_out)