1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-05 12:52:19 +01:00

Merge branch 'dev' into integration

This commit is contained in:
J. Nick Koston
2025-07-25 08:42:21 -10:00
112 changed files with 1396 additions and 1107 deletions

View File

@@ -61,9 +61,7 @@ def indent_list(text: str, padding: str = " ") -> list[str]:
"""Indent each line of the given text with the specified padding."""
lines = []
for line in text.splitlines():
if line == "":
p = ""
elif line.startswith("#ifdef") or line.startswith("#endif"):
if line == "" or line.startswith("#ifdef") or line.startswith("#endif"):
p = ""
else:
p = padding
@@ -2388,7 +2386,7 @@ static const char *const TAG = "api.service";
needs_conn = get_opt(m, pb.needs_setup_connection, True)
needs_auth = get_opt(m, pb.needs_authentication, True)
ifdef = message_ifdef_map.get(inp, ifdefs.get(inp, None))
ifdef = message_ifdef_map.get(inp, ifdefs.get(inp))
if ifdef is not None:
hpp += f"#ifdef {ifdef}\n"

View File

@@ -71,11 +71,13 @@ def get_component_names():
skip_components = []
for d in os.listdir(CORE_COMPONENTS_PATH):
if not d.startswith("__") and os.path.isdir(
os.path.join(CORE_COMPONENTS_PATH, d)
if (
not d.startswith("__")
and os.path.isdir(os.path.join(CORE_COMPONENTS_PATH, d))
and d not in component_names
and d not in skip_components
):
if d not in component_names and d not in skip_components:
component_names.append(d)
component_names.append(d)
return sorted(component_names)
@@ -139,11 +141,10 @@ def register_module_schemas(key, module, manifest=None):
for name, schema in module_schemas(module):
register_known_schema(key, name, schema)
if manifest:
if manifest and manifest.multi_conf and S_CONFIG_SCHEMA in output[key][S_SCHEMAS]:
# Multi conf should allow list of components
# not sure about 2nd part of the if, might be useless config (e.g. as3935)
if manifest.multi_conf and S_CONFIG_SCHEMA in output[key][S_SCHEMAS]:
output[key][S_SCHEMAS][S_CONFIG_SCHEMA]["is_list"] = True
output[key][S_SCHEMAS][S_CONFIG_SCHEMA]["is_list"] = True
def register_known_schema(module, name, schema):
@@ -230,7 +231,7 @@ def add_module_registries(domain, module):
reg_type = attr_name.partition("_")[0].lower()
found_registries[repr(attr_obj)] = f"{domain}.{reg_type}"
for name in attr_obj.keys():
for name in attr_obj:
if "." not in name:
reg_entry_name = name
else:
@@ -700,7 +701,7 @@ def is_convertible_schema(schema):
if repr(schema) in ejs.registry_schemas:
return True
if isinstance(schema, dict):
for k in schema.keys():
for k in schema:
if isinstance(k, (cv.Required, cv.Optional)):
return True
return False
@@ -818,7 +819,7 @@ def convert(schema, config_var, path):
elif schema_type == "automation":
extra_schema = None
config_var[S_TYPE] = "trigger"
if automation.AUTOMATION_SCHEMA == ejs.extended_schemas[repr(data)][0]:
if ejs.extended_schemas[repr(data)][0] == automation.AUTOMATION_SCHEMA:
extra_schema = ejs.extended_schemas[repr(data)][1]
if (
extra_schema is not None and len(extra_schema) > 1
@@ -926,9 +927,8 @@ def convert(schema, config_var, path):
config = convert_config(schema_type, path + "/type_" + schema_key)
types[schema_key] = config["schema"]
elif DUMP_UNKNOWN:
if S_TYPE not in config_var:
config_var["unknown"] = repr_schema
elif DUMP_UNKNOWN and S_TYPE not in config_var:
config_var["unknown"] = repr_schema
if DUMP_PATH:
config_var["path"] = path

View File

@@ -66,9 +66,10 @@ def main():
)
args = parser.parse_args()
files = []
for path in git_ls_files(["*.cpp", "*.h", "*.tcc"]):
files.append(os.path.relpath(path, os.getcwd()))
cwd = os.getcwd()
files = [
os.path.relpath(path, cwd) for path in git_ls_files(["*.cpp", "*.h", "*.tcc"])
]
if args.files:
# Match against files specified on command-line

View File

@@ -219,9 +219,8 @@ def main():
)
args = parser.parse_args()
files = []
for path in git_ls_files(["*.cpp"]):
files.append(os.path.relpath(path, os.getcwd()))
cwd = os.getcwd()
files = [os.path.relpath(path, cwd) for path in git_ls_files(["*.cpp"])]
# Print initial file count if it's large
if len(files) > 50:

View File

@@ -365,9 +365,11 @@ def load_idedata(environment: str) -> dict[str, Any]:
platformio_ini = Path(root_path) / "platformio.ini"
temp_idedata = Path(temp_folder) / f"idedata-{environment}.json"
changed = False
if not platformio_ini.is_file() or not temp_idedata.is_file():
changed = True
elif platformio_ini.stat().st_mtime >= temp_idedata.stat().st_mtime:
if (
not platformio_ini.is_file()
or not temp_idedata.is_file()
or platformio_ini.stat().st_mtime >= temp_idedata.stat().st_mtime
):
changed = True
if "idf" in environment:

View File

@@ -41,11 +41,12 @@ CONFIG_NEWLIB_LIBC=y
return include_paths
def extract_defines(command):
defines = []
define_pattern = re.compile(r"-D\s*([^\s]+)")
for match in define_pattern.findall(command):
if match not in ("_ASMLANGUAGE"):
defines.append(match)
defines = [
match
for match in define_pattern.findall(command)
if match not in ("_ASMLANGUAGE")
]
return defines
def find_cxx_path(commands):
@@ -78,13 +79,14 @@ CONFIG_NEWLIB_LIBC=y
return include_paths
def extract_cxx_flags(command):
flags = []
# Extracts CXXFLAGS from the command string, excluding includes and defines.
flag_pattern = re.compile(
r"(-O[0-3s]|-g|-std=[^\s]+|-Wall|-Wextra|-Werror|--[^\s]+|-f[^\s]+|-m[^\s]+|-imacros\s*[^\s]+)"
)
for match in flag_pattern.findall(command):
flags.append(match.replace("-imacros ", "-imacros"))
flags = [
match.replace("-imacros ", "-imacros")
for match in flag_pattern.findall(command)
]
return flags
def transform_to_idedata_format(compile_commands):