Fix clang-tidy with multiple ESP32 toolchains installed (#2998)

This commit is contained in:
Oxan van Leeuwen 2022-01-04 20:34:17 +01:00 committed by GitHub
parent c8f4fbb7dd
commit 193d3e0206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,10 +58,14 @@ def clang_options(idedata):
# defines # defines
cmd.extend(f'-D{define}' for define in idedata['defines']) cmd.extend(f'-D{define}' for define in idedata['defines'])
# add include directories, using -isystem for dependencies to suppress their errors # add toolchain include directories using -isystem
# idedata contains include directories for all toolchains of this platform, only use those from the one in use
toolchain_dir = os.path.normpath(f"{idedata['cxx_path']}/../../")
for directory in idedata['includes']['toolchain']: for directory in idedata['includes']['toolchain']:
if 'xtensa-esp32s2-elf' not in directory: if directory.startswith(toolchain_dir):
cmd.extend(['-isystem', directory]) cmd.extend(['-isystem', directory])
# add include directories, using -isystem for dependencies to suppress their errors
for directory in sorted(set(idedata['includes']['build'])): for directory in sorted(set(idedata['includes']['build'])):
dependency = "framework-arduino" in directory or "/libdeps/" in directory dependency = "framework-arduino" in directory or "/libdeps/" in directory
cmd.extend(['-isystem' if dependency else '-I', directory]) cmd.extend(['-isystem' if dependency else '-I', directory])