def include_file(path, basename): parts = basename.split(os.path.sep) dst = CORE.relative_src_path(*parts) copy_file_if_changed(path, dst) _, ext = os.path.splitext(path) if ext in ['.h', '.hpp', '.tcc']: # Header, add include statement cg.add_global(cg.RawStatement(f'#include "{basename}"'))
async def add_arduino_global_workaround(): # The Arduino framework defined these itself in the global # namespace. For the esphome codebase that is not a problem, # but when custom code # 1. writes `millis()` for example AND # 2. has `using namespace esphome;` like our guides suggest # Then the compiler will complain that the call is ambiguous # Define a hacky macro so that the call is never ambiguous # and always uses the esphome namespace one. # See also https://github.com/esphome/issues/issues/2510 # Priority -999 so that it runs before adding includes, as those # also might reference these symbols for line in ARDUINO_GLUE_CODE.splitlines(): cg.add_global(cg.RawStatement(line))