mirror of
https://github.com/esphome/esphome.git
synced 2025-09-01 10:52:19 +01:00
[clang] clang tidy support with zephyr (#8352)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
@@ -40,12 +40,37 @@ def clang_options(idedata):
|
||||
else:
|
||||
cmd.append(f"--target={triplet}")
|
||||
|
||||
omit_flags = (
|
||||
"-free",
|
||||
"-fipa-pta",
|
||||
"-fstrict-volatile-bitfields",
|
||||
"-mlongcalls",
|
||||
"-mtext-section-literals",
|
||||
"-mdisable-hardware-atomics",
|
||||
"-mfix-esp32-psram-cache-issue",
|
||||
"-mfix-esp32-psram-cache-strategy=memw",
|
||||
"-fno-tree-switch-conversion",
|
||||
)
|
||||
|
||||
if "zephyr" in triplet:
|
||||
omit_flags += (
|
||||
"-fno-reorder-functions",
|
||||
"-mfp16-format=ieee",
|
||||
"--param=min-pagesize=0",
|
||||
)
|
||||
else:
|
||||
cmd.extend(
|
||||
[
|
||||
# disable built-in include directories from the host
|
||||
"-nostdinc++",
|
||||
]
|
||||
)
|
||||
|
||||
# set flags
|
||||
cmd.extend(
|
||||
[
|
||||
# disable built-in include directories from the host
|
||||
"-nostdinc",
|
||||
"-nostdinc++",
|
||||
# replace pgmspace.h, as it uses GNU extensions clang doesn't support
|
||||
# https://github.com/earlephilhower/newlib-xtensa/pull/18
|
||||
"-D_PGMSPACE_H_",
|
||||
@@ -70,22 +95,7 @@ def clang_options(idedata):
|
||||
)
|
||||
|
||||
# copy compiler flags, except those clang doesn't understand.
|
||||
cmd.extend(
|
||||
flag
|
||||
for flag in idedata["cxx_flags"]
|
||||
if flag
|
||||
not in (
|
||||
"-free",
|
||||
"-fipa-pta",
|
||||
"-fstrict-volatile-bitfields",
|
||||
"-mlongcalls",
|
||||
"-mtext-section-literals",
|
||||
"-mdisable-hardware-atomics",
|
||||
"-mfix-esp32-psram-cache-issue",
|
||||
"-mfix-esp32-psram-cache-strategy=memw",
|
||||
"-fno-tree-switch-conversion",
|
||||
)
|
||||
)
|
||||
cmd.extend(flag for flag in idedata["cxx_flags"] if flag not in omit_flags)
|
||||
|
||||
# defines
|
||||
cmd.extend(f"-D{define}" for define in idedata["defines"])
|
||||
@@ -100,13 +110,16 @@ def clang_options(idedata):
|
||||
# add library include directories using -isystem to suppress their errors
|
||||
for directory in list(idedata["includes"]["build"]):
|
||||
# skip our own directories, we add those later
|
||||
if not directory.startswith(f"{root_path}") or directory.startswith(
|
||||
(
|
||||
f"{root_path}/.pio",
|
||||
f"{root_path}/.platformio",
|
||||
f"{root_path}/.temp",
|
||||
f"{root_path}/managed_components",
|
||||
if (
|
||||
not directory.startswith(f"{root_path}")
|
||||
or directory.startswith(
|
||||
(
|
||||
f"{root_path}/.platformio",
|
||||
f"{root_path}/.temp",
|
||||
f"{root_path}/managed_components",
|
||||
)
|
||||
)
|
||||
or (directory.startswith(f"{root_path}") and "/.pio/" in directory)
|
||||
):
|
||||
cmd.extend(["-isystem", directory])
|
||||
|
||||
|
Reference in New Issue
Block a user