mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 21:22:22 +01:00
feat(core): Add support for <...> includes (#8132)
This commit is contained in:
@@ -72,6 +72,9 @@ def validate_hostname(config):
|
||||
|
||||
|
||||
def valid_include(value):
|
||||
# Look for "<...>" includes
|
||||
if value.startswith("<") and value.endswith(">"):
|
||||
return value
|
||||
try:
|
||||
return cv.directory(value)
|
||||
except cv.Invalid:
|
||||
@@ -360,7 +363,19 @@ async def to_code(config):
|
||||
CORE.add_job(add_arduino_global_workaround)
|
||||
|
||||
if config[CONF_INCLUDES]:
|
||||
CORE.add_job(add_includes, config[CONF_INCLUDES])
|
||||
# Get the <...> includes
|
||||
system_includes = []
|
||||
other_includes = []
|
||||
for include in config[CONF_INCLUDES]:
|
||||
if include.startswith("<") and include.endswith(">"):
|
||||
system_includes.append(include)
|
||||
else:
|
||||
other_includes.append(include)
|
||||
# <...> includes should be at the start
|
||||
for include in system_includes:
|
||||
cg.add_global(cg.RawStatement(f"#include {include}"), prepend=True)
|
||||
# Other includes should be at the end
|
||||
CORE.add_job(add_includes, other_includes)
|
||||
|
||||
if project_conf := config.get(CONF_PROJECT):
|
||||
cg.add_define("ESPHOME_PROJECT_NAME", project_conf[CONF_NAME])
|
||||
|
Reference in New Issue
Block a user