zephyr/scripts/schemas/snippet-schema.yml

46 lines
939 B
YAML
Raw Normal View History

snippets: initial snippet.yml support Add a new script, snippets.py, which is responsible for searching SNIPPET_ROOT for snippet definitions, validating them, and informing the build system about what needs doing as a result. Use this script in snippets.cmake to: - validate any discovered snippet.yml files - error out on undefined snippets - add a 'snippets' build system target that prints all snippet names (analogous to 'boards' and 'shields' targets) - handle any specific build system settings properly, by include()-ing a file it generates With this patch, you can define or extend a snippet in a snippet.yml file anywhere underneath a directory in SNIPPET_ROOT. The snippet.yml file format has a schema whose initial definition is in a new file, snippet-schema.yml. This initial snippet.yml file format supports adding .overlay and .conf files, like this: name: foo append: DTC_OVERLAY_FILE: foo.overlay OVERLAY_CONFIG: foo.conf boards: myboard: append: DTC_OVERLAY_FILE: myboard.overlay OVERLAY_CONFIG: myboard.conf /my-regular-expression-over-board-names/: append: DTC_OVERLAY_FILE: myregexp.overlay OVERLAY_CONFIG: myregexp.conf (Note that since the snippet feature is intended to be extensible, the same snippet name may appear in multiple files throughout any directory in SNIPPET_ROOT, with each addition augmenting prior ones.) This initial syntax aligns with the following snippet design goals: - extensible: you can add board-specific support for an existing snippet in another module - able to combine multiple types of configuration: we can now apply a .overlay and .conf at the same time - specializable: this allows you to define settings that only apply to a selectable set of boards (including with regular expression support for matching against multiple similar boards that follow a naming convention) - DRY: you can use regular expressions to apply the same snippet settings to multiple boards like this: /(board1|board2|...)/ This patch is not trying to design and implement everything up front. Additional features can and will be added to the snippet.yml format over time; using YAML as a format allows us to make backwards-compatible extensions as needed. Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-08 07:27:07 +08:00
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2022, Nordic Semiconductor ASA
# A pykwalify schema for basic validation of the snippet.yml format.
schema;append-schema:
# Sub-schema for appending onto CMake list variables.
# See uses under 'append:' keys below.
type: map
mapping:
DTC_OVERLAY_FILE:
type: str
OVERLAY_CONFIG:
type: str
type: map
mapping:
name:
required: true
type: str
append:
example: |
Snippet-wide appending can be done here:
name: foo
append:
DTC_OVERLAY_FILE: m3.overlay
include: append-schema
boards:
example: |
Board-specific appending can be done here:
name: foo
boards:
qemu_cortex_m3:
append:
DTC_OVERLAY_FILE: m3.overlay
type: map
mapping:
regex;(.*):
type: map
mapping:
append:
include: append-schema