mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Set correct include_dir in platformio.ini (#2999)
This commit is contained in:
parent
193d3e0206
commit
ffea3597f4
2 changed files with 15 additions and 6 deletions
|
@ -5,8 +5,13 @@
|
|||
|
||||
[platformio]
|
||||
default_envs = esp8266, esp32, esp32-idf
|
||||
; Ideally, we want src_dir to be the root directory of the repository, to mimic the runtime build
|
||||
; environment as best as possible. Unfortunately, the ESP-IDF toolchain really doesn't like this
|
||||
; being the root directory. Instead, set esphome/ as the source directory, all our sources are in
|
||||
; there anyway. Set the root directory as the include_dir, so that the esphome/ directory is on the
|
||||
; include path.
|
||||
src_dir = esphome
|
||||
include_dir =
|
||||
include_dir = .
|
||||
|
||||
[runtime]
|
||||
; This are the flags as set by the runtime.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue