From fe7c93d0042abceac2b2bb2086a3d3e31af3aac1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Mar 2017 17:49:01 +0300 Subject: [PATCH] =?UTF-8?q?Multi-line=20support=20for=20the=20different=20?= =?UTF-8?q?options=20in=20=E2=80=9Cplatformio.ini=E2=80=9D=20//=20Resolve?= =?UTF-8?q?=20#889?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 7 +++++++ platformio/__init__.py | 2 +- platformio/builder/main.py | 10 +++++++--- platformio/commands/run.py | 12 +++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e10513ed..b0d95700 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,13 @@ Release Notes PlatformIO 3.0 -------------- +3.4.0 (2017-??-??) +~~~~~~~~~~~~~~~~~~ + +* Multi-line support for the different options in `Project Configuration File "platformio.ini" `__, + such as: ``build_flags``, ``build_unflags``, etc. + (`issue #889 `_) + 3.3.0 (2017-03-27) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index d5bbee86..1067bc86 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 3, 0) +VERSION = (3, 4, "0a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 5fbc2174..3b9bf46d 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -106,6 +106,8 @@ env = DefaultEnvironment(**DEFAULT_ENV_OPTIONS) for k in commonvars.keys(): if k in env: env[k] = base64.b64decode(env[k]) + if "\n" in env[k]: + env[k] = [v.strip() for v in env[k].split("\n") if v.strip()] if env.GetOption('clean'): env.PioClean(env.subst("$BUILD_DIR")) @@ -121,21 +123,23 @@ for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT", continue if var in ("UPLOAD_PORT", "EXTRA_SCRIPT") or not env.get(var): env[var] = environ.get(k) + elif isinstance(env[var], list): + env.Append(**{var: environ.get(k)}) else: env[var] = "%s%s%s" % (environ.get(k), ", " if var == "LIB_EXTRA_DIRS" else " ", env[var]) # Parse comma separated items for opt in ("PIOFRAMEWORK", "LIB_DEPS", "LIB_IGNORE", "LIB_EXTRA_DIRS"): - if opt not in env: + if opt not in env or isinstance(env[opt], list): continue env[opt] = [l.strip() for l in env[opt].split(", ") if l.strip()] # Configure extra library source directories for LDF if util.get_project_optional_dir("lib_extra_dirs"): + items = util.get_project_optional_dir("lib_extra_dirs") env.Prepend(LIBSOURCE_DIRS=[ - l.strip() - for l in util.get_project_optional_dir("lib_extra_dirs").split(", ") + l.strip() for l in items.split("\n" if "\n" in items else ", ") if l.strip() ]) env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 36e56ff6..9818dd95 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -161,13 +161,15 @@ class EnvironmentProcessor(object): # multi-line values to one line for k, v in self.options.items(): if "\n" in v: - self.options[k] = self.options[k].strip().replace("\n", ", ") + self.options[k] = self.options[k].strip() if not self.silent: - click.echo("[%s] Processing %s (%s)" % ( - datetime.now().strftime("%c"), click.style( - self.name, fg="cyan", bold=True), ", ".join( - ["%s: %s" % (k, v) for k, v in self.options.items()]))) + click.echo("[%s] Processing %s (%s)" % + (datetime.now().strftime("%c"), click.style( + self.name, fg="cyan", bold=True), ", ".join([ + "%s: %s" % (k, v.replace("\n", ", ")) + for k, v in self.options.items() + ]))) click.secho("-" * terminal_width, bold=True) self.options = self._validate_options(self.options)