mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 10:37:13 +02:00
Added a new build variable (COMPILATIONDB_INCLUDE_TOOLCHAIN) to include toolchain paths in the compilation database // Resolve #3735
This commit is contained in:
@ -48,6 +48,11 @@ PlatformIO Core 5
|
|||||||
- Show project dependency licenses when building in the verbose mode
|
- Show project dependency licenses when building in the verbose mode
|
||||||
- Fixed an issue when `LDF <https://docs.platformio.org/en/latest/librarymanager/ldf.html>`__ ignores the project `lib_deps <https://docs.platformio.org/en/latest/projectconf/section_env_library.html#lib-deps>`__ while resolving library dependencies (`issue #3598 <https://github.com/platformio/platformio-core/issues/3598>`_)
|
- Fixed an issue when `LDF <https://docs.platformio.org/en/latest/librarymanager/ldf.html>`__ ignores the project `lib_deps <https://docs.platformio.org/en/latest/projectconf/section_env_library.html#lib-deps>`__ while resolving library dependencies (`issue #3598 <https://github.com/platformio/platformio-core/issues/3598>`_)
|
||||||
|
|
||||||
|
* **Integration**
|
||||||
|
|
||||||
|
- Added a new build variable (``COMPILATIONDB_INCLUDE_TOOLCHAIN``) to include toolchain paths in the compilation database (`issue #3735 <https://github.com/platformio/platformio-core/issues/3735>`_)
|
||||||
|
- Changed default path for compilation database `compile_commands.json <https://docs.platformio.org/en/latest/integration/compile_commands.html>`__ to the root of the project
|
||||||
|
|
||||||
* **Miscellaneous**
|
* **Miscellaneous**
|
||||||
|
|
||||||
- Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)
|
- Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)
|
||||||
|
2
docs
2
docs
Submodule docs updated: f543ff06f0...7c02d91f4e
@ -61,7 +61,7 @@ DEFAULT_ENV_OPTIONS = dict(
|
|||||||
"piolib",
|
"piolib",
|
||||||
"pioupload",
|
"pioupload",
|
||||||
"piomisc",
|
"piomisc",
|
||||||
"pioide",
|
"piointegration",
|
||||||
"piosize",
|
"piosize",
|
||||||
],
|
],
|
||||||
toolpath=[os.path.join(fs.get_source_dir(), "builder", "tools")],
|
toolpath=[os.path.join(fs.get_source_dir(), "builder", "tools")],
|
||||||
@ -72,7 +72,7 @@ DEFAULT_ENV_OPTIONS = dict(
|
|||||||
BUILD_DIR=os.path.join("$PROJECT_BUILD_DIR", "$PIOENV"),
|
BUILD_DIR=os.path.join("$PROJECT_BUILD_DIR", "$PIOENV"),
|
||||||
BUILD_SRC_DIR=os.path.join("$BUILD_DIR", "src"),
|
BUILD_SRC_DIR=os.path.join("$BUILD_DIR", "src"),
|
||||||
BUILD_TEST_DIR=os.path.join("$BUILD_DIR", "test"),
|
BUILD_TEST_DIR=os.path.join("$BUILD_DIR", "test"),
|
||||||
COMPILATIONDB_PATH=os.path.join("$BUILD_DIR", "compile_commands.json"),
|
COMPILATIONDB_PATH=os.path.join("$PROJECT_DIR", "compile_commands.json"),
|
||||||
LIBPATH=["$BUILD_DIR"],
|
LIBPATH=["$BUILD_DIR"],
|
||||||
PROGNAME="program",
|
PROGNAME="program",
|
||||||
PROG_PATH=os.path.join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX"),
|
PROG_PATH=os.path.join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX"),
|
||||||
@ -228,7 +228,7 @@ if set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS):
|
|||||||
Import("projenv")
|
Import("projenv")
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
projenv = env
|
projenv = env
|
||||||
data = projenv.DumpIDEData(env)
|
data = projenv.DumpIntegrationData(env)
|
||||||
# dump to file for the further reading by project.helpers.load_project_ide_data
|
# dump to file for the further reading by project.helpers.load_project_ide_data
|
||||||
with open(
|
with open(
|
||||||
projenv.subst(os.path.join("$BUILD_DIR", "idedata.json")),
|
projenv.subst(os.path.join("$BUILD_DIR", "idedata.json")),
|
||||||
|
@ -24,27 +24,27 @@ from platformio.package.manager.core import get_core_package_dir
|
|||||||
from platformio.proc import exec_command, where_is_program
|
from platformio.proc import exec_command, where_is_program
|
||||||
|
|
||||||
|
|
||||||
def _dump_includes(env):
|
def DumpIntegrationIncludes(env):
|
||||||
includes = {}
|
result = dict(build=[], compatlib=[], toolchain=[], unity=[])
|
||||||
|
|
||||||
includes["build"] = [
|
result["build"].extend(
|
||||||
|
[
|
||||||
env.subst("$PROJECT_INCLUDE_DIR"),
|
env.subst("$PROJECT_INCLUDE_DIR"),
|
||||||
env.subst("$PROJECT_SRC_DIR"),
|
env.subst("$PROJECT_SRC_DIR"),
|
||||||
]
|
]
|
||||||
includes["build"].extend(
|
)
|
||||||
|
result["build"].extend(
|
||||||
[os.path.abspath(env.subst(item)) for item in env.get("CPPPATH", [])]
|
[os.path.abspath(env.subst(item)) for item in env.get("CPPPATH", [])]
|
||||||
)
|
)
|
||||||
|
|
||||||
# installed libs
|
# installed libs
|
||||||
includes["compatlib"] = []
|
|
||||||
for lb in env.GetLibBuilders():
|
for lb in env.GetLibBuilders():
|
||||||
includes["compatlib"].extend(
|
result["compatlib"].extend(
|
||||||
[os.path.abspath(inc) for inc in lb.get_include_dirs()]
|
[os.path.abspath(inc) for inc in lb.get_include_dirs()]
|
||||||
)
|
)
|
||||||
|
|
||||||
# includes from toolchains
|
# includes from toolchains
|
||||||
p = env.PioPlatform()
|
p = env.PioPlatform()
|
||||||
includes["toolchain"] = []
|
|
||||||
for pkg in p.get_installed_packages(with_optional=False):
|
for pkg in p.get_installed_packages(with_optional=False):
|
||||||
if p.get_package_type(pkg.metadata.name) != "toolchain":
|
if p.get_package_type(pkg.metadata.name) != "toolchain":
|
||||||
continue
|
continue
|
||||||
@ -56,10 +56,9 @@ def _dump_includes(env):
|
|||||||
os.path.join(toolchain_dir, "*", "include*"),
|
os.path.join(toolchain_dir, "*", "include*"),
|
||||||
]
|
]
|
||||||
for g in toolchain_incglobs:
|
for g in toolchain_incglobs:
|
||||||
includes["toolchain"].extend([os.path.abspath(inc) for inc in glob.glob(g)])
|
result["toolchain"].extend([os.path.abspath(inc) for inc in glob.glob(g)])
|
||||||
|
|
||||||
# include Unity framework if there are tests in project
|
# include Unity framework if there are tests in project
|
||||||
includes["unity"] = []
|
|
||||||
auto_install_unity = False
|
auto_install_unity = False
|
||||||
test_dir = env.GetProjectConfig().get("platformio", "test_dir")
|
test_dir = env.GetProjectConfig().get("platformio", "test_dir")
|
||||||
if os.path.isdir(test_dir) and os.listdir(test_dir) != ["README"]:
|
if os.path.isdir(test_dir) and os.listdir(test_dir) != ["README"]:
|
||||||
@ -69,9 +68,9 @@ def _dump_includes(env):
|
|||||||
auto_install=auto_install_unity,
|
auto_install=auto_install_unity,
|
||||||
)
|
)
|
||||||
if unity_dir:
|
if unity_dir:
|
||||||
includes["unity"].append(unity_dir)
|
result["unity"].append(unity_dir)
|
||||||
|
|
||||||
return includes
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _get_gcc_defines(env):
|
def _get_gcc_defines(env):
|
||||||
@ -154,14 +153,14 @@ def _subst_cmd(env, cmd):
|
|||||||
return " ".join([SCons.Subst.quote_spaces(arg) for arg in args])
|
return " ".join([SCons.Subst.quote_spaces(arg) for arg in args])
|
||||||
|
|
||||||
|
|
||||||
def DumpIDEData(env, globalenv):
|
def DumpIntegrationData(env, globalenv):
|
||||||
"""env here is `projenv`"""
|
"""env here is `projenv`"""
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"env_name": env["PIOENV"],
|
"env_name": env["PIOENV"],
|
||||||
"libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()],
|
"libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()],
|
||||||
"defines": _dump_defines(env),
|
"defines": _dump_defines(env),
|
||||||
"includes": _dump_includes(env),
|
"includes": env.DumpIntegrationIncludes(),
|
||||||
"cc_path": where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
|
"cc_path": where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
|
||||||
"cxx_path": where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
|
"cxx_path": where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
|
||||||
"gdb_path": where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
|
"gdb_path": where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
|
||||||
@ -205,5 +204,6 @@ def exists(_):
|
|||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
env.AddMethod(DumpIDEData)
|
env.AddMethod(DumpIntegrationIncludes)
|
||||||
|
env.AddMethod(DumpIntegrationData)
|
||||||
return env
|
return env
|
@ -136,6 +136,13 @@ def ProcessProgramDeps(env):
|
|||||||
if "__test" in COMMAND_LINE_TARGETS:
|
if "__test" in COMMAND_LINE_TARGETS:
|
||||||
env.ConfigureTestTarget()
|
env.ConfigureTestTarget()
|
||||||
|
|
||||||
|
if "compiledb" in COMMAND_LINE_TARGETS and env.get(
|
||||||
|
"COMPILATIONDB_INCLUDE_TOOLCHAIN"
|
||||||
|
):
|
||||||
|
for scope, includes in env.DumpIntegrationIncludes().items():
|
||||||
|
if scope in ("toolchain", "unity"):
|
||||||
|
env.Append(CPPPATH=includes)
|
||||||
|
|
||||||
|
|
||||||
def ProcessProjectDeps(env):
|
def ProcessProjectDeps(env):
|
||||||
project_lib_builder = env.ConfigureProjectLibBuilder()
|
project_lib_builder = env.ConfigureProjectLibBuilder()
|
||||||
|
Reference in New Issue
Block a user