mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-19 03:13:14 +00:00
Read "compatible" from binding files
This commit is contained in:
parent
cc5050b7c6
commit
95f010d3f7
@ -34,6 +34,7 @@ def parse_binding(file_path: str, binding_dirs: list[str]) -> Binding:
|
||||
includes.append(include)
|
||||
|
||||
# Parse local properties
|
||||
compatible = data.get('compatible', None)
|
||||
properties_raw = data.get('properties', {})
|
||||
for name, details in properties_raw.items():
|
||||
prop = BindingProperty(
|
||||
@ -43,9 +44,7 @@ def parse_binding(file_path: str, binding_dirs: list[str]) -> Binding:
|
||||
description=details.get('description', '').strip(),
|
||||
)
|
||||
properties_dict[name] = prop
|
||||
|
||||
filename = os.path.basename(file_path)
|
||||
compatible = filename.removesuffix(".yaml").removesuffix(".yml")
|
||||
return Binding(
|
||||
filename=filename,
|
||||
compatible=compatible,
|
||||
|
||||
@ -18,8 +18,10 @@ def get_device_identifier_safe(device: Device):
|
||||
|
||||
def get_device_type_name(device: Device, bindings: list[Binding]):
|
||||
device_binding = find_device_binding(device, bindings)
|
||||
if device_binding == None:
|
||||
if device_binding is None:
|
||||
raise Exception(f"Binding not found for {device.identifier}")
|
||||
if device_binding.compatible is None:
|
||||
raise Exception(f"Couldn't find compatible binding for {device.identifier}")
|
||||
compatible_safe = device_binding.compatible.split(",")[-1]
|
||||
return compatible_safe.replace("-", "_")
|
||||
|
||||
@ -126,7 +128,6 @@ def write_device_init(file, device: Device, parent_device: Device, bindings: lis
|
||||
if verbose:
|
||||
print(f"Processing device init code for '{device.identifier}'")
|
||||
# Assemble some pre-requisites
|
||||
type_name = get_device_type_name(device, bindings)
|
||||
compatible_property = find_binding_property(device, "compatible")
|
||||
if compatible_property is None:
|
||||
raise Exception(f"Cannot find 'compatible' property for {device.identifier}")
|
||||
|
||||
@ -35,7 +35,7 @@ class BindingProperty:
|
||||
@dataclass
|
||||
class Binding:
|
||||
filename: str
|
||||
compatible: str
|
||||
compatible: list[str]
|
||||
description: str
|
||||
properties: list[BindingProperty]
|
||||
includes: list[str]
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
description: LilyGO T-Lora Pager
|
||||
|
||||
include: ["root.yaml"]
|
||||
|
||||
compatible: "lilygo,tlora-pager"
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
description: ESP32 GPIO Controller
|
||||
|
||||
compatible: "espressif,esp32-gpio"
|
||||
|
||||
include: ["gpio-controller.yaml"]
|
||||
|
||||
@ -2,6 +2,8 @@ description: ESP32 GPIO Controller
|
||||
|
||||
include: ["i2c-controller.yaml"]
|
||||
|
||||
compatible: "espressif,esp32-i2c"
|
||||
|
||||
properties:
|
||||
port:
|
||||
type: int
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
compatible: "root"
|
||||
|
||||
properties:
|
||||
model:
|
||||
required: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user