Drop support for "lib_extra_dirs" in "platformio" section

This commit is contained in:
Ivan Kravets
2019-05-20 21:12:45 +03:00
parent c46643f0fd
commit f29a74042f
4 changed files with 46 additions and 27 deletions

2
docs

Submodule docs updated: c7591d260b...374f5e110f

View File

@ -31,11 +31,11 @@ from SCons.Script import Variables # pylint: disable=import-error
from platformio import util
from platformio.compat import PY2, path_to_unicode
from platformio.proc import get_pythonexe_path
from platformio.project.config import ProjectConfig
from platformio.project.helpers import (
get_project_dir, get_project_optional_dir, get_projectbuild_dir,
get_projectdata_dir, get_projectinclude_dir, get_projectlib_dir,
get_projectlibdeps_dir, get_projectsrc_dir, get_projecttest_dir,
get_projectworkspace_dir)
get_project_dir, get_projectbuild_dir, get_projectdata_dir,
get_projectinclude_dir, get_projectlib_dir, get_projectlibdeps_dir,
get_projectsrc_dir, get_projecttest_dir, get_projectworkspace_dir)
AllowSubstExceptions(NameError)
@ -144,7 +144,7 @@ for k in list(commonvars.keys()):
if isinstance(env[k], bytes):
env[k] = env[k].decode()
if k in MULTILINE_VARS:
env[k] = util.parse_conf_multi_values(env[k])
env[k] = ProjectConfig.parse_multi_values(env[k])
if env.GetOption('clean'):
env.PioClean(env.subst("$BUILD_DIR"))
@ -161,18 +161,15 @@ for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPTS",
if var in ("UPLOAD_PORT", ):
env[var] = environ.get(k)
continue
env.Append(**{var: util.parse_conf_multi_values(environ.get(k))})
env.Append(**{var: ProjectConfig.parse_multi_values(environ.get(k))})
# Configure extra library source directories for LDF
if get_project_optional_dir("lib_extra_dirs"):
env.Prepend(
LIBSOURCE_DIRS=util.parse_conf_multi_values(
get_project_optional_dir("lib_extra_dirs")))
env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", []))
env['LIBSOURCE_DIRS'] = [
expanduser(d) if d.startswith("~") else d for d in env['LIBSOURCE_DIRS']
]
print(env['LIBSOURCE_DIRS'])
env.LoadPioPlatform(commonvars)
env.SConscriptChdir(0)

View File

@ -161,8 +161,8 @@ class EnvironmentProcessor(object):
for k, v in self.options.items():
self.options[k] = self.options[k].strip()
if self.verbose or k in self.DEFAULT_DUMP_OPTIONS:
env_dump.append(
"%s: %s" % (k, ", ".join(util.parse_conf_multi_values(v))))
env_dump.append("%s: %s" % (k, ", ".join(
ProjectConfig.parse_multi_values(v))))
if not self.silent:
click.echo("Processing %s (%s)" % (click.style(
@ -230,7 +230,7 @@ class EnvironmentProcessor(object):
if "lib_deps" in self.options:
_autoinstall_libdeps(
self.cmd_ctx,
util.parse_conf_multi_values(self.options['lib_deps']),
ProjectConfig.parse_multi_values(self.options['lib_deps']),
self.verbose)
try:

View File

@ -54,8 +54,7 @@ KNOWN_PLATFORMIO_OPTIONS = [
"build_dir",
"data_dir",
"test_dir",
"boards_dir",
"lib_extra_dirs"
"boards_dir"
]
KNOWN_ENV_OPTIONS = [
@ -275,17 +274,40 @@ class ProjectConfig(object):
return self.validate_options() if validate_options else True
def validate_options(self):
warnings = set()
# check [platformio] section
if self._parser.has_section("platformio"):
unknown = set(k for k, _ in self.items("platformio")) - set(
KNOWN_PLATFORMIO_OPTIONS)
if unknown:
warnings.add(
"Ignore unknown `%s` options in section `[platformio]`" %
", ".join(unknown))
return (self._validate_platformio_options()
and self._validate_env_options())
def _validate_platformio_options(self):
if not self._parser.has_section("platformio"):
return True
warnings = set()
# legacy `lib_extra_dirs`
if self._parser.has_option("platformio", "lib_extra_dirs"):
if not self._parser.has_section("env"):
self._parser.add_section("env")
self._parser.set("env", "lib_extra_dirs",
self._parser.get("platformio", "lib_extra_dirs"))
self._parser.remove_option("platformio", "lib_extra_dirs")
warnings.add(
"`lib_extra_dirs` option is deprecated in section "
"`platformio`! Please move it to global `env` section")
unknown = set(k for k, _ in self.items("platformio")) - set(
KNOWN_PLATFORMIO_OPTIONS)
if unknown:
warnings.add(
"Ignore unknown `%s` options in section `[platformio]`" %
", ".join(unknown))
for warning in warnings:
click.secho("Warning! %s" % warning, fg="yellow")
return True
def _validate_env_options(self):
warnings = set()
# check [env:*] sections
for section in self._parser.sections():
if section != "env" and not section.startswith("env:"):
continue