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

Set correct include_dir in platformio.ini (#2999)

This commit is contained in:
Oxan van Leeuwen
2022-01-04 21:59:34 +01:00
committed by GitHub
parent 193d3e0206
commit ffea3597f4
2 changed files with 15 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from helpers import print_error_for_file, get_output, filter_grep, \
build_all_include, temp_header_file, git_ls_files, filter_changed, load_idedata, basepath
build_all_include, temp_header_file, git_ls_files, filter_changed, load_idedata, root_path, basepath
import argparse
import click
import colorama
@@ -58,17 +58,21 @@ def clang_options(idedata):
# defines
cmd.extend(f'-D{define}' for define in idedata['defines'])
# add toolchain include directories using -isystem
# add toolchain include directories using -isystem to suppress their errors
# 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']:
if directory.startswith(toolchain_dir):
cmd.extend(['-isystem', directory])
# add include directories, using -isystem for dependencies to suppress their errors
# add library include directories using -isystem to suppress their errors
for directory in sorted(set(idedata['includes']['build'])):
dependency = "framework-arduino" in directory or "/libdeps/" in directory
cmd.extend(['-isystem' if dependency else '-I', directory])
# skip our own directories, we add those later
if not directory.startswith(f"{root_path}/") or directory.startswith(f"{root_path}/.pio/"):
cmd.extend(['-isystem', directory])
# add the esphome include directory using -I
cmd.extend(['-I', root_path])
return cmd