diff mbox series

[RFC,3/5] schemas: Add bitbake-setup JSON schema

Message ID 20251017231444.374436-4-yoann.congal@smile.fr
State New
Headers show
Series Bitbake-setup configuration schema | expand

Commit Message

Yoann Congal Oct. 17, 2025, 11:14 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

This schema validates configurations in default-registry as well as the
configurations used in bitbake-setup selftests.

Note: it uses a reference to the layers schema for the "sources"
section.

One can validate a bitbake-setup configuration with:
  pip install check-jsonschema
  check-jsonschema --schemafile ./schemas/bitbake-setup.schema.json --base-uri=file://. $BB_SETUP_CONF

RFC: I don't know how strict/loose I should make the schema. I've tried to match
what does accept/reject the current bitbake-setup:
* If present, a "bb-layer" can be an empty array.
* bb-setup accepts "configurations = []" but it results in a impossible
  choice in interactive mode. I rejected that in the schema and plan to
  fix that in bb-setup as well.
* In each configuration, "name" and "description" are optional but the
  flatten configuration must have them. I don't know if we can/want to
  represent that in the schema.
* bb-setup need at least one of "bb-layers" or "oe-template", that is
  not enforced in the current schema.
* '"additionalProperties": false' makes "comments":"..." impossible
  right now, I plan to add them later.

Also, I'm not sure this is the right path to store schemas.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 schemas/bitbake-setup.schema.json | 108 ++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 schemas/bitbake-setup.schema.json
diff mbox series

Patch

diff --git a/schemas/bitbake-setup.schema.json b/schemas/bitbake-setup.schema.json
new file mode 100644
index 000000000..a5cef7633
--- /dev/null
+++ b/schemas/bitbake-setup.schema.json
@@ -0,0 +1,108 @@ 
+{
+    "$schema": "https://json-schema.org/draft/2020-12/schema",
+    "description": "Schema for bitbake-setup configuration files",
+    "type": "object",
+    "required": [
+        "description",
+        "bitbake-setup",
+        "version"
+    ],
+    "properties": {
+        "description": {
+            "type": "string",
+            "description": "Description of the bitbake-setup configuration file"
+        },
+        "sources": {
+            "$ref": "/schemas/layers.schema.json#/properties/sources"
+        },
+        "bitbake-setup": {
+            "type": "object",
+            "description": "BitBake-setup configurations",
+            "required": [
+                "configurations"
+            ],
+            "properties": {
+                "configurations": {
+                    "type": "array",
+                    "minItems": 1,
+                    "$anchor": "configurations",
+                    "items": {
+                        "type": "object",
+                        "properties": {
+                            "name": {
+                                "type": "string",
+                                "description": "Name of the configuration"
+                            },
+                            "description": {
+                                "type": "string",
+                                "description": "Human-readable description of the configuration"
+                            },
+                            "bb-layers": {
+                                "type": "array",
+                                "description": "List of BitBake layers to include",
+                                "items": {
+                                    "type": "string"
+                                }
+                            },
+                            "oe-template": {
+                                "type": "string",
+                                "description": "OE-template configuration"
+                            },
+                            "oe-fragments": {
+                                "$anchor": "oe-fragments",
+                                "type": "array",
+                                "description": "List of BitBake configuration fragments to enable",
+                                "items": {
+                                    "type": "string"
+                                }
+                            },
+                            "oe-fragments-one-of": {
+                                "type": "object",
+                                "description": "Mutually exclusive bitbake configuration fragment",
+                                "patternProperties": {
+                                    ".*": {
+                                        "type": "object",
+                                        "required": [
+                                            "description",
+                                            "options"
+                                        ],
+                                        "properties": {
+                                            "description": {
+                                                "type": "string",
+                                                "description": "Human-readable description of the fragment category"
+                                            },
+                                            "options": {
+                                                "$ref": "#oe-fragments"
+                                            }
+                                        },
+                                        "additionalProperties": false
+                                    }
+                                },
+                                "additionalProperties": false
+                            },
+                            "configurations": {
+                                "$ref": "#configurations"
+                            },
+                            "bb-env-passthrough-additions": {
+                                "type": "array",
+                                "description": "List of environment variables to include in BB_ENV_PASSTHROUGH_ADDITIONS",
+                                "items": {
+                                    "type": "string"
+                                }
+                            }
+                        },
+                        "additionalProperties": false
+                    }
+                }
+            },
+            "additionalProperties": false
+        },
+        "version": {
+            "description": "The version of this document; currently '1.0'",
+            "enum": [
+                "1.0"
+            ]
+        }
+    },
+    "additionalProperties": false
+}