diff --git a/HISTORY.rst b/HISTORY.rst index e5f4e304..fece4e97 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -39,6 +39,7 @@ PlatformIO 4.0 - Print platform package details, such as version, VSC source and commit (`issue #2155 `_) - Override default `"platformio.ini" (Project Configuration File) `__ with a custom using ``-c, --project-conf`` option for `platformio run `__, `platformio debug `__, or `platformio test `__ commands (`issue #1913 `_) - Override default development platform upload command with a custom `upload_command `__ (`issue #2599 `_) + - Configure a shared folder for the derived files (objects, firmwares, ELFs) from a build system using `build_cache_dir `__ option (`issue #2674 `_) - Fixed an issue when ``-U`` in ``build_flags`` does not remove macro previously defined via ``-D`` flag (`issue #2508 `_) * **Infrastructure** diff --git a/docs b/docs index 668c8b0d..6ca558b2 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 668c8b0d89fa0248e8384545538a14261531c980 +Subproject commit 6ca558b253058d4176be8dc894fdc439bb844c32 diff --git a/platformio/builder/main.py b/platformio/builder/main.py index e1ac0bd0..8fa012d0 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import environ -from os.path import join +from os import environ, makedirs +from os.path import isdir, join from time import time import click @@ -67,6 +67,7 @@ DEFAULT_ENV_OPTIONS = dict( PROJECTTEST_DIR=project_helpers.get_project_test_dir(), PROJECTDATA_DIR=project_helpers.get_project_data_dir(), PROJECTBUILD_DIR=project_helpers.get_project_build_dir(), + BUILDCACHE_DIR=project_helpers.get_project_optional_dir("build_cache_dir"), BUILD_DIR=join("$PROJECTBUILD_DIR", "$PIOENV"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), BUILDTEST_DIR=join("$BUILD_DIR", "test"), @@ -96,6 +97,11 @@ env.Replace( for key in list(clivars.keys()) if key in env }) +if env.subst("$BUILDCACHE_DIR"): + if not isdir(env.subst("$BUILDCACHE_DIR")): + makedirs(env.subst("$BUILDCACHE_DIR")) + env.CacheDir("$BUILDCACHE_DIR") + if int(ARGUMENTS.get("ISATTY", 0)): # pylint: disable=protected-access click._compat.isatty = lambda stream: True diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 65596d10..1e01d59e 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -210,6 +210,8 @@ def _delete_file(path): @util.memoized() def _get_compiler_type(env): + if env.subst("$CC").endswith("-gcc"): + return "gcc" try: sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) diff --git a/platformio/project/options.py b/platformio/project/options.py index 1b49bf42..bc2f5c3d 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -66,6 +66,8 @@ ProjectOptions = OrderedDict([ sysenvvar="PLATFORMIO_PACKAGES_DIR"), ConfigPlatformioOption(name="cache_dir", sysenvvar="PLATFORMIO_CACHE_DIR"), + ConfigPlatformioOption(name="build_cache_dir", + sysenvvar="PLATFORMIO_BUILD_CACHE_DIR"), ConfigPlatformioOption(name="workspace_dir", sysenvvar="PLATFORMIO_WORKSPACE_DIR"), ConfigPlatformioOption(name="build_dir",