diff --git a/HISTORY.rst b/HISTORY.rst index 35418484..0e0ee9ab 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,8 @@ PlatformIO 3.0 and `platformio platform install `__ commands (`issue #778 `_) +* Handle missed dependency and provide a help how to find it using PlatformIO Library Registry + (`issue #781 `_) * `Library Dependency Finder (LDF) `__: diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index c97d62c2..b3090705 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -18,6 +18,7 @@ import re from imp import load_source from multiprocessing import cpu_count from os.path import basename, dirname, isdir, isfile, join +from urllib import quote import click import semantic_version @@ -394,6 +395,12 @@ class PlatformRunMixin(object): is_error = self.LINE_ERROR_RE.search(line) is not None self._echo_line(line, level=3 if is_error else 2) + a_pos = line.find("fatal error:") + b_pos = line.rfind(": No such file or directory") + if a_pos == -1 or b_pos == -1: + return + self._echo_missed_dependency(line[a_pos + 12:b_pos].strip()) + def _echo_line(self, line, level): if line.startswith("scons: "): line = line[7:] @@ -405,6 +412,27 @@ class PlatformRunMixin(object): fg = "green" click.secho(line, fg=fg, err=level > 1) + @staticmethod + def _echo_missed_dependency(filename): + if "/" in filename or not filename.endswith((".h", ".hpp")): + return + banner = """ +{dots} +* Looking for {filename_styled} dependency? Check our library registry! +* +* CLI > platformio lib search "header:{filename}" +* Web > {link} +* +{dots} +""".format(filename=filename, + filename_styled=click.style(filename, fg="cyan"), + link=click.style( + "http://platformio.org/lib/search?query=header:%s" % quote( + filename, safe=""), + fg="blue"), + dots="*" * (55 + len(filename))) + click.echo(banner, err=True) + @staticmethod def get_job_nums(): try: