Almost all labels generated by the extracting script are now prefixed with DT_. The only exceptions are: - stuff with 'base_label' specified in yaml bindings - items specified by 'regs_config' and 'name_config' dictionaries in globals.py module - FLASH related labels generated by flash.extract() called separately from generate_node_definitions(), e.g. FLASH_WRITE_BLOCK_SIZE - these are used directly, not through fixups, from existing code so I didn't want to touch them now Labels generated for aliases are additionally prefixed with information from the 'compatible' property, e.g. DT_GPIO_LEDS_LED0_* is generated instead of LED0_*. To provide backward compatibility for code that uses LEDx_* and SWx_* labels in their previous forms, a command line option named 'old-alias-names' is added to the extraction script. This option causes that the labels for aliases are generated in both old and new forms. Currently this option is always enabled in dts.cmake. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
#
|
|
# Copyright (c) 2018 Bobby Noelte
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from extract.globals import *
|
|
from extract.directive import DTDirective
|
|
|
|
##
|
|
# @brief Manage directives in a default way.
|
|
#
|
|
class DTDefault(DTDirective):
|
|
|
|
def __init__(self):
|
|
pass
|
|
|
|
##
|
|
# @brief Extract directives in a default way
|
|
#
|
|
# @param node_address Address of node owning the clockxxx definition.
|
|
# @param yaml YAML definition for the owning node.
|
|
# @param prop property name
|
|
# @param prop type (string, boolean, etc)
|
|
# @param def_label Define label string of node owning the directive.
|
|
#
|
|
def extract(self, node_address, yaml, prop, prop_type, def_label):
|
|
prop_def = {}
|
|
prop_alias = {}
|
|
|
|
if prop_type == 'boolean':
|
|
if prop in reduced[node_address]['props'].keys():
|
|
prop_values = 1
|
|
else:
|
|
prop_values = 0
|
|
else:
|
|
prop_values = reduced[node_address]['props'][prop]
|
|
|
|
if isinstance(prop_values, list):
|
|
for i, prop_value in enumerate(prop_values):
|
|
prop_name = convert_string_to_label(prop)
|
|
label = def_label + '_' + prop_name
|
|
if isinstance(prop_value, str):
|
|
prop_value = "\"" + prop_value + "\""
|
|
prop_def[label + '_' + str(i)] = prop_value
|
|
else:
|
|
prop_name = convert_string_to_label(prop)
|
|
label = def_label + '_' + prop_name
|
|
|
|
if prop_values == 'parent-label':
|
|
prop_values = find_parent_prop(node_address, 'label')
|
|
|
|
if isinstance(prop_values, str):
|
|
prop_values = "\"" + prop_values + "\""
|
|
prop_def[label] = prop_values
|
|
|
|
# generate defs for node aliases
|
|
if node_address in aliases:
|
|
add_prop_aliases(
|
|
node_address,
|
|
yaml,
|
|
lambda alias:
|
|
convert_string_to_label(alias) + '_' + prop_name,
|
|
label,
|
|
prop_alias)
|
|
|
|
insert_defs(node_address, prop_def, prop_alias)
|
|
|
|
##
|
|
# @brief Management information for directives handled by default.
|
|
default = DTDefault()
|