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