From 8b121a1ccb49900e4d6535e20f1ac7ca902c57c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 28 Nov 2016 23:24:21 +0200 Subject: [PATCH] Fix LDF C/C++ Preprocessor for conditional syntax // Resolve #837 --- HISTORY.rst | 3 ++- platformio/builder/tools/piolib.py | 20 ++++++++++++++------ platformio/commands/remote.py | 5 +---- platformio/managers/platform.py | 3 +-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 58602317..dd23ed95 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -31,7 +31,8 @@ PlatformIO 3.0 * Improved handling of library dependencies specified in ``library.json`` manifest (`issue #814 `_) * Improved `Library Dependency Finder (LDF) `__ - for circular dependencies + for circular dependencies and fixed LDF C/C++ Preprocessor for conditional syntax + (`issue #837 `_) * Fixed issue with ``PATH`` auto-configuring for upload tools * Fixed ``99-platformio-udev.rules`` checker for Linux OS diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 16822453..40fd15a8 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -13,6 +13,7 @@ # limitations under the License. # pylint: disable=no-member, no-self-use, unused-argument +# pylint: disable=too-many-instance-attributes, too-many-public-methods from __future__ import absolute_import @@ -76,12 +77,11 @@ class LibBuilderFactory(object): return [] -# pylint: disable=too-many-instance-attributes, too-many-public-methods - - class LibBuilderBase(object): - INC_SCANNER = SCons.Scanner.C.CScanner() + CLASSIC_SCANNER = SCons.Scanner.C.CScanner() + INTELLISENSE_SCANNER = SCons.Scanner.C.SConsCPPScannerWrapper("CScanner", + "CPPPATH") INC_DIRS_CACHE = None def __init__(self, env, path, manifest=None, verbose=False): @@ -280,8 +280,16 @@ class LibBuilderBase(object): result = [] for path in self._validate_search_paths(search_paths): - for inc in self.env.File(path).get_found_includes( - self.env, LibBuilderBase.INC_SCANNER, tuple(inc_dirs)): + try: + assert isinstance(self, ProjectAsLibBuilder) or \ + self.lib_ldf_mode == 2 + incs = self.env.File(path).get_found_includes( + self.env, LibBuilderBase.INTELLISENSE_SCANNER, + tuple(inc_dirs)) + except: # pylint: disable=bare-except + incs = self.env.File(path).get_found_includes( + self.env, LibBuilderBase.CLASSIC_SCANNER, tuple(inc_dirs)) + for inc in incs: if inc not in result: result.append(inc) return result diff --git a/platformio/commands/remote.py b/platformio/commands/remote.py index 64973ee1..1d57d913 100644 --- a/platformio/commands/remote.py +++ b/platformio/commands/remote.py @@ -47,10 +47,7 @@ def remote_agent(): "--working-dir", envvar="PLATFORMIO_REMOTE_AGENT_DIR", type=click.Path( - file_okay=False, - dir_okay=True, - writable=True, - resolve_path=True)) + file_okay=False, dir_okay=True, writable=True, resolve_path=True)) def remote_agent_start(**kwargs): pioplus_call(sys.argv[1:]) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index a7e997c7..f431bd0a 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -477,8 +477,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): } if "tool-scons" not in self.packages: self.packages['tool-scons'] = { - "version": self._manifest.get("engines", {}).get( - "scons", ">=2.3.0,<2.6.0"), + "version": "~3.20401.1", "optional": False }