diff --git a/HISTORY.rst b/HISTORY.rst index aedd7358..fe6efe0f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -48,6 +48,11 @@ PlatformIO Core 5 - Show project dependency licenses when building in the verbose mode - Fixed an issue when `LDF `__ ignores the project `lib_deps `__ while resolving library dependencies (`issue #3598 `_) +* **Integration** + + - Added a new build variable (``COMPILATIONDB_INCLUDE_TOOLCHAIN``) to include toolchain paths in the compilation database (`issue #3735 `_) + - Changed default path for compilation database `compile_commands.json `__ to the root of the project + * **Miscellaneous** - Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 `_) diff --git a/docs b/docs index f543ff06..7c02d91f 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f543ff06f03f8f5d12aea232098a75bf6a070fb9 +Subproject commit 7c02d91f4ee1de1afbb4bbee061dbde6d6012467 diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 84d6ba9f..49fb0612 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -61,7 +61,7 @@ DEFAULT_ENV_OPTIONS = dict( "piolib", "pioupload", "piomisc", - "pioide", + "piointegration", "piosize", ], 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_SRC_DIR=os.path.join("$BUILD_DIR", "src"), 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"], PROGNAME="program", PROG_PATH=os.path.join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX"), @@ -228,7 +228,7 @@ if set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS): Import("projenv") except: # pylint: disable=bare-except projenv = env - data = projenv.DumpIDEData(env) + data = projenv.DumpIntegrationData(env) # dump to file for the further reading by project.helpers.load_project_ide_data with open( projenv.subst(os.path.join("$BUILD_DIR", "idedata.json")), diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/piointegration.py similarity index 90% rename from platformio/builder/tools/pioide.py rename to platformio/builder/tools/piointegration.py index adb5844b..2e9f9fc5 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/piointegration.py @@ -24,27 +24,27 @@ from platformio.package.manager.core import get_core_package_dir from platformio.proc import exec_command, where_is_program -def _dump_includes(env): - includes = {} +def DumpIntegrationIncludes(env): + result = dict(build=[], compatlib=[], toolchain=[], unity=[]) - includes["build"] = [ - env.subst("$PROJECT_INCLUDE_DIR"), - env.subst("$PROJECT_SRC_DIR"), - ] - includes["build"].extend( + result["build"].extend( + [ + env.subst("$PROJECT_INCLUDE_DIR"), + env.subst("$PROJECT_SRC_DIR"), + ] + ) + result["build"].extend( [os.path.abspath(env.subst(item)) for item in env.get("CPPPATH", [])] ) # installed libs - includes["compatlib"] = [] for lb in env.GetLibBuilders(): - includes["compatlib"].extend( + result["compatlib"].extend( [os.path.abspath(inc) for inc in lb.get_include_dirs()] ) # includes from toolchains p = env.PioPlatform() - includes["toolchain"] = [] for pkg in p.get_installed_packages(with_optional=False): if p.get_package_type(pkg.metadata.name) != "toolchain": continue @@ -56,10 +56,9 @@ def _dump_includes(env): os.path.join(toolchain_dir, "*", "include*"), ] 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 - includes["unity"] = [] auto_install_unity = False test_dir = env.GetProjectConfig().get("platformio", "test_dir") 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, ) if unity_dir: - includes["unity"].append(unity_dir) + result["unity"].append(unity_dir) - return includes + return result 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]) -def DumpIDEData(env, globalenv): +def DumpIntegrationData(env, globalenv): """env here is `projenv`""" data = { "env_name": env["PIOENV"], "libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()], "defines": _dump_defines(env), - "includes": _dump_includes(env), + "includes": env.DumpIntegrationIncludes(), "cc_path": where_is_program(env.subst("$CC"), 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']}")), @@ -205,5 +204,6 @@ def exists(_): def generate(env): - env.AddMethod(DumpIDEData) + env.AddMethod(DumpIntegrationIncludes) + env.AddMethod(DumpIntegrationData) return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 61274dc7..6f9f4729 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -136,6 +136,13 @@ def ProcessProgramDeps(env): if "__test" in COMMAND_LINE_TARGETS: 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): project_lib_builder = env.ConfigureProjectLibBuilder()