From 7a40992cc158db926efe38aca5c13b70532be6a1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 26 Jan 2018 19:53:07 +0200 Subject: [PATCH] Add aliases for LDF compatibility modes --- HISTORY.rst | 2 ++ docs | 2 +- platformio/builder/tools/piolib.py | 38 +++++++++++++++++------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 384188b4..86130c76 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ PlatformIO 3.0 3.5.2 (2018-??-??) ~~~~~~~~~~~~~~~~~~ +* Added aliases (off, light, strict) for + `LDF Compatibility Modes `__ * Show device system information (MCU, Frequency, RAM, Flash, Debugging tools) in a build log * Show all available upload protocols before firmware uploading in a build log diff --git a/docs b/docs index ec9ec10d..86ba500a 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ec9ec10dcd7a335729503f4cedd3a2f0c06e5e6d +Subproject commit 86ba500affa389263f4b97e6480192f3544f0041 diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 7c74ab0b..e98e96ed 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -86,8 +86,8 @@ class LibBuilderBase(object): LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"] LDF_MODE_DEFAULT = "chain" - COMPAT_MODES = [0, 1, 2] - COMPAT_MODE_DEFAULT = 1 + COMPAT_MODES = ["off", "light", "strict"] + COMPAT_MODE_DEFAULT = "light" CLASSIC_SCANNER = SCons.Scanner.C.CScanner() ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True) @@ -230,12 +230,15 @@ class LibBuilderBase(object): @staticmethod def validate_compat_mode(mode): - try: - mode = int(mode) - assert mode in LibBuilderBase.COMPAT_MODES + if isinstance(mode, basestring): + mode = mode.strip().lower() + if mode in LibBuilderBase.COMPAT_MODES: return mode - except (AssertionError, ValueError): - return LibBuilderBase.COMPAT_MODE_DEFAULT + try: + return LibBuilderBase.COMPAT_MODES[int(mode)] + except (IndexError, ValueError): + pass + return LibBuilderBase.COMPAT_MODE_DEFAULT def is_platforms_compatible(self, platforms): return True @@ -743,13 +746,13 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches if verbose: sys.stderr.write("Ignored library %s\n" % lb.path) return None - if compat_mode > 1 and not lb.is_platforms_compatible( + if compat_mode == "strict" and not lb.is_platforms_compatible( env['PIOPLATFORM']): if verbose: sys.stderr.write( "Platform incompatible library %s\n" % lb.path) return False - if compat_mode > 0 and "PIOFRAMEWORK" in env and \ + if compat_mode == "light" and "PIOFRAMEWORK" in env and \ not lb.is_frameworks_compatible(env.get("PIOFRAMEWORK", [])): if verbose: sys.stderr.write( @@ -828,20 +831,23 @@ def BuildProjectLibraries(env): if lb.depbuilders: print_deps_tree(lb, level + 1) - print "Collected %d compatible libraries" % len(lib_builders) - print "Scanning dependencies..." - project = ProjectAsLibBuilder(env, "$PROJECT_DIR") project.env = env + ldf_mode = LibBuilderBase.lib_ldf_mode.fget(project) + + print "Library Dependency Finder -> http://bit.ly/configure-pio-ldf" + print "Modes: Finder/%s Compatibility/%s" % (ldf_mode, + project.lib_compat_mode) + print "Collected %d compatible libraries" % len(lib_builders) + + print "Scanning dependencies..." project.search_deps_recursive() - if (LibBuilderBase.validate_ldf_mode( - env.get("LIB_LDF_MODE", LibBuilderBase.LDF_MODE_DEFAULT)) - .startswith("chain") and project.depbuilders): + if ldf_mode.startswith("chain") and project.depbuilders: correct_found_libs() if project.depbuilders: - print "Library Dependency Graph ( http://bit.ly/configure-pio-ldf )" + print "Dependency Graph" print_deps_tree(project) else: print "No dependencies"