diff --git a/HISTORY.rst b/HISTORY.rst index 44821cb2..9426f0dd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,7 @@ Release Notes .. |PIOCONF| replace:: `"platformio.ini" `__ configuration file .. |LDF| replace:: `LDF `__ +.. |INTERPOLATION| replace:: `Interpolation of Values `__ .. _release_notes_6: @@ -11,6 +12,13 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** +6.0.1 (2022-05-17) +~~~~~~~~~~~~~~~~~~ + +* Improved support for the renamed configuration options (`issue #4270 `_) +* Fixed an issue when calling the built-in `pio device monitor `__ filters +* Fixed an issue when using |INTERPOLATION| and merging str+int options (`issue #4271 `_) + 6.0.0 (2022-05-16) ~~~~~~~~~~~~~~~~~~ @@ -92,7 +100,7 @@ Please check the `Migration guide from 5.x to 6.0 `__ with ``${this}`` pattern (`issue #3953 `_) + - Extended |INTERPOLATION| with ``${this}`` pattern (`issue #3953 `_) - Embed environment name of the current section in the |PIOCONF| using ``${this.__env__}`` pattern - Renamed the "src_build_flags" project configuration option to the `build_src_flags `__ - Renamed the "src_filter" project configuration option to the `build_src_filter `__ diff --git a/docs b/docs index 6bbb8134..5bf0037c 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6bbb813494d4a28bf6345a478b41c8f92e0b2533 +Subproject commit 5bf0037c6679cccffbb835c30d729cd19120651b diff --git a/platformio/__init__.py b/platformio/__init__.py index f59130aa..097088c0 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (6, 0, 0) +VERSION = (6, 0, 1) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/pioproject.py b/platformio/builder/tools/pioproject.py index 425d6758..bf59d918 100644 --- a/platformio/builder/tools/pioproject.py +++ b/platformio/builder/tools/pioproject.py @@ -15,7 +15,7 @@ from __future__ import absolute_import from platformio.compat import MISSING -from platformio.project.config import ProjectConfig, ProjectOptions +from platformio.project.config import ProjectConfig def GetProjectConfig(env): @@ -31,15 +31,17 @@ def GetProjectOption(env, option, default=MISSING): def LoadProjectOptions(env): - for option, value in env.GetProjectOptions(): - option_meta = ProjectOptions.get("env." + option) + config = env.GetProjectConfig() + section = "env:" + env["PIOENV"] + for option in config.options(section): + option_meta = config.find_option_meta(section, option) if ( not option_meta or not option_meta.buildenvvar or option_meta.buildenvvar in env ): continue - env[option_meta.buildenvvar] = value + env[option_meta.buildenvvar] = config.get(section, option) def exists(_): diff --git a/platformio/commands/lib/command.py b/platformio/commands/lib/command.py index 76210090..7e3f08e1 100644 --- a/platformio/commands/lib/command.py +++ b/platformio/commands/lib/command.py @@ -68,6 +68,14 @@ def get_project_global_lib_dir(): ) @click.pass_context def cli(ctx, **options): + in_silence = PlatformioCLI.in_silence() + if not in_silence: + click.secho( + "\nWARNING!!! This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg` instead.\n", + fg="yellow", + ) + storage_cmds = ("install", "uninstall", "update", "list") # skip commands that don't need storage folder if ctx.invoked_subcommand not in storage_cmds or ( @@ -94,7 +102,6 @@ def cli(ctx, **options): get_project_dir(), get_project_global_lib_dir(), ctx.invoked_subcommand ) - in_silence = PlatformioCLI.in_silence() ctx.meta[CTX_META_PROJECT_ENVIRONMENTS_KEY] = options["environment"] ctx.meta[CTX_META_INPUT_DIRS_KEY] = storage_dirs ctx.meta[CTX_META_STORAGE_DIRS_KEY] = [] diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index b35f056c..ae80566e 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -18,6 +18,7 @@ import os import click +from platformio.commands import PlatformioCLI from platformio.commands.boards import print_boards from platformio.exception import UserSideException from platformio.package.exception import UnknownPackageError @@ -30,7 +31,12 @@ from platformio.platform.factory import PlatformFactory @click.group(short_help="Platform manager", hidden=True) def cli(): - pass + if not PlatformioCLI.in_silence(): + click.secho( + "\nWARNING!!! This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg` instead.\n", + fg="yellow", + ) @cli.command("search", short_help="Search for development platform") diff --git a/platformio/commands/update.py b/platformio/commands/update.py index c0da8055..a4d0e196 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -14,12 +14,6 @@ import click -from platformio.commands.lib.command import CTX_META_STORAGE_DIRS_KEY -from platformio.commands.lib.command import lib_update as cmd_lib_update -from platformio.commands.platform import platform_update as cmd_platform_update -from platformio.package.manager.core import update_core_packages -from platformio.package.manager.library import LibraryPackageManager - @click.command( "update", @@ -36,23 +30,9 @@ from platformio.package.manager.library import LibraryPackageManager @click.option( "--dry-run", is_flag=True, help="Do not update, only check for the new versions" ) -@click.pass_context -def cli(ctx, core_packages, only_check, dry_run): - only_check = dry_run or only_check - - if not only_check: - update_core_packages() - - if core_packages: - return - - click.echo() - click.echo("Platform Manager") - click.echo("================") - ctx.invoke(cmd_platform_update, only_check=only_check) - - click.echo() - click.echo("Library Manager") - click.echo("===============") - ctx.meta[CTX_META_STORAGE_DIRS_KEY] = [LibraryPackageManager().package_dir] - ctx.invoke(cmd_lib_update, only_check=only_check) +def cli(*_, **__): + click.secho( + "This command is deprecated and will be removed in the next releases. \n" + "Please use `pio pkg update` instead.", + fg="yellow", + ) diff --git a/platformio/device/filters/base.py b/platformio/device/filters/base.py index 1c02e8b5..203cdb77 100644 --- a/platformio/device/filters/base.py +++ b/platformio/device/filters/base.py @@ -71,7 +71,7 @@ def register_filters(platform=None, options=None): ) # default filters load_monitor_filters( - os.path.join(fs.get_source_dir(), "commands", "device", "filters"), + os.path.join(fs.get_source_dir(), "device", "filters"), options=options, ) diff --git a/platformio/project/config.py b/platformio/project/config.py index 9b7f43cf..999827d5 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -43,6 +43,8 @@ class ProjectConfigBase(object): INLINE_COMMENT_RE = re.compile(r"\s+;.*$") VARTPL_RE = re.compile(r"\$\{([^\.\}\()]+)\.([^\}]+)\}") + CUSTOM_OPTION_PREFIXES = ("custom_", "board_") + expand_interpolations = True warnings = [] @@ -109,23 +111,6 @@ class ProjectConfigBase(object): self.read(item) def _maintain_renaimed_options(self): - # legacy `lib_extra_dirs` in [platformio] - if self._parser.has_section("platformio") and 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") - self.warnings.append( - "`lib_extra_dirs` configuration option is deprecated in " - "section [platformio]! Please move it to global `env` section" - ) - renamed_options = {} for option in ProjectOptions.values(): if option.oldnames: @@ -143,19 +128,20 @@ class ProjectConfigBase(object): "Please use `%s` instead" % (option, section, renamed_options[option]) ) - # rename on-the-fly - self._parser.set( - section, - renamed_options[option], - self._parser.get(section, option), - ) - self._parser.remove_option(section, option) + # # rename on-the-fly + # self._parser.set( + # section, + # renamed_options[option], + # self._parser.get(section, option), + # ) + # self._parser.remove_option(section, option) continue # unknown unknown_conditions = [ ("%s.%s" % (scope, option)) not in ProjectOptions, - scope != "env" or not option.startswith(("custom_", "board_")), + scope != "env" + or not option.startswith(self.CUSTOM_OPTION_PREFIXES), ] if all(unknown_conditions): self.warnings.append( @@ -237,16 +223,7 @@ class ProjectConfigBase(object): value = "\n" + value self._parser.set(section, option, value) - def getraw(self, section, option, default=MISSING): - try: - return self._getraw(section, option, default) - except configparser.NoOptionError as exc: - renamed_option = self._resolve_renamed_option(section, option) - if renamed_option: - return self._getraw(section, renamed_option, default) - raise exc - - def _resolve_renamed_option(self, section, old_name): + def resolve_renamed_option(self, section, old_name): scope = self.get_section_scope(section) if scope not in ("platformio", "env"): return None @@ -259,19 +236,39 @@ class ProjectConfigBase(object): return option_meta.name return None - def _getraw(self, section, option, default): # pylint: disable=too-many-branches + def find_option_meta(self, section, option): + scope = self.get_section_scope(section) + if scope not in ("platformio", "env"): + return None + option_meta = ProjectOptions.get("%s.%s" % (scope, option)) + if option_meta: + return option_meta + for option_meta in ProjectOptions.values(): + if option_meta.scope == scope and option in (option_meta.oldnames or []): + return option_meta + return None + + def _traverse_for_value(self, section, option, option_meta=None): + for _section, _option in self.walk_options(section): + if _option == option or ( + option_meta + and ( + option_meta.name == _option + or _option in (option_meta.oldnames or []) + ) + ): + return self._parser.get(_section, _option) + return MISSING + + def getraw( + self, section, option, default=MISSING + ): # pylint: disable=too-many-branches if not self.expand_interpolations: return self._parser.get(section, option) - value = MISSING - for sec, opt in self.walk_options(section): - if opt == option: - value = self._parser.get(sec, option) - break + option_meta = self.find_option_meta(section, option) + value = self._traverse_for_value(section, option, option_meta) - option_meta = ProjectOptions.get( - "%s.%s" % (self.get_section_scope(section), option) - ) if not option_meta: if value == MISSING: value = ( @@ -333,7 +330,7 @@ class ProjectConfigBase(object): ) if isinstance(value, list): return "\n".join(value) - return value + return str(value) def get(self, section, option, default=MISSING): value = None @@ -342,9 +339,7 @@ class ProjectConfigBase(object): except configparser.Error as e: raise exception.InvalidProjectConfError(self.path, str(e)) - option_meta = ProjectOptions.get( - "%s.%s" % (self.get_section_scope(section), option) - ) + option_meta = self.find_option_meta(section, option) if not option_meta: return value diff --git a/platformio/shared.py b/platformio/public.py similarity index 100% rename from platformio/shared.py rename to platformio/public.py diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 2792d5c6..ba721792 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -346,6 +346,7 @@ def dump_run_environment(options): "check_tool", "debug_tool", "monitor_filters", + "test_framework", ] safe_options = {k: v for k, v in options.items() if k in non_sensitive_data} if is_platformio_project(os.getcwd()): diff --git a/setup.py b/setup.py index 20585ab3..5df72834 100644 --- a/setup.py +++ b/setup.py @@ -28,9 +28,9 @@ from platformio import ( minimal_requirements = [ "bottle==0.12.*", - "click%s" % (">=8.0.3,<9" if sys.version_info >= (3, 7) else "==8.0.4"), + "click%s" % (">=8.0.4,<9" if sys.version_info >= (3, 7) else "==8.0.4"), "colorama", - "marshmallow==3.*", + "marshmallow==%s" % ("3.*" if sys.version_info >= (3, 7) else "3.14.1"), "pyelftools>=0.27,<1", "pyserial==3.*", "requests==2.*", diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 25b7f545..964c0e67 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -85,6 +85,7 @@ build_flags = -Wl,--gc-sections ${custom.lib_flags} ${custom.debug_flags} + -D SERIAL_BAUD_RATE=${this.monitor_speed} lib_install = 574 [env:extra_2] @@ -101,9 +102,13 @@ debug_flags = -D DEBUG=1 debug_server = ${platformio.packages_dir}/tool-openocd/openocd --help +src_filter = -<*> + + + + [env:extra_2] build_flags = -Og +src_filter = ${custom.src_filter} + """ DEFAULT_CORE_DIR = os.path.join(fs.expanduser("~"), ".platformio") @@ -130,7 +135,7 @@ def test_empty_config(): def test_warnings(config): config.validate(["extra_2", "base"], silent=True) - assert len(config.warnings) == 2 + assert len(config.warnings) == 3 assert "lib_install" in config.warnings[1] with pytest.raises(UnknownEnvNamesError): @@ -213,8 +218,9 @@ def test_options(config): def test_has_option(config): assert config.has_option("env:base", "monitor_speed") assert not config.has_option("custom", "monitor_speed") - assert not config.has_option("env:extra_1", "lib_install") + assert config.has_option("env:extra_1", "lib_install") assert config.has_option("env:test_extends", "lib_compat_mode") + assert config.has_option("env:extra_2", "src_filter") def test_sysenv_options(config): @@ -292,9 +298,9 @@ def test_getraw_value(config): # known assert config.getraw("env:base", "targets") == "" assert config.getraw("env:extra_1", "lib_deps") == "574" - assert ( - config.getraw("env:extra_1", "build_flags") - == "\n-fdata-sections\n-Wl,--gc-sections\n-lc -lm\n-D DEBUG=1" + assert config.getraw("env:extra_1", "build_flags") == ( + "\n-fdata-sections\n-Wl,--gc-sections\n" + "-lc -lm\n-D DEBUG=1\n-D SERIAL_BAUD_RATE=9600" ) # extended @@ -312,6 +318,8 @@ def test_getraw_value(config): assert config.getraw("platformio", "build_dir") == "~/tmp/pio-$PROJECT_HASH" # renamed option + assert config.getraw("env:extra_1", "lib_install") == "574" + assert config.getraw("env:extra_1", "lib_deps") == "574" assert config.getraw("env:base", "debug_load_cmd") == ["load"] @@ -322,6 +330,7 @@ def test_get_value(config): "-Wl,--gc-sections", "-lc -lm", "-D DEBUG=1", + "-D SERIAL_BAUD_RATE=9600", ] assert config.get("env:extra_2", "build_flags") == ["-Og"] assert config.get("env:extra_2", "monitor_speed") == 9600 @@ -349,6 +358,11 @@ def test_get_value(config): ) assert "$PROJECT_HASH" not in config.get("platformio", "build_dir") + # renamed option + assert config.get("env:extra_1", "lib_install") == ["574"] + assert config.get("env:extra_1", "lib_deps") == ["574"] + assert config.get("env:base", "debug_load_cmd") == ["load"] + def test_items(config): assert config.items("custom") == [ @@ -363,6 +377,7 @@ def test_items(config): "\n%s/tool-openocd/openocd\n--help" % os.path.join(DEFAULT_CORE_DIR, "packages"), ), + ("src_filter", "-<*>\n+\n+"), ] assert config.items(env="base") == [ ("build_flags", ["-D DEBUG=1"]), @@ -377,11 +392,18 @@ def test_items(config): assert config.items(env="extra_1") == [ ( "build_flags", - ["-fdata-sections", "-Wl,--gc-sections", "-lc -lm", "-D DEBUG=1"], + [ + "-fdata-sections", + "-Wl,--gc-sections", + "-lc -lm", + "-D DEBUG=1", + "-D SERIAL_BAUD_RATE=9600", + ], ), - ("lib_deps", ["574"]), + ("lib_install", ["574"]), ("monitor_speed", 9600), ("custom_monitor_speed", "115200"), + ("lib_deps", ["574"]), ("lib_ignore", ["LibIgnoreCustom"]), ("custom_builtin_option", "release"), ] @@ -396,6 +418,7 @@ def test_items(config): "--help", ], ), + ("src_filter", ["-<*>", "+", "+ +"]), ("monitor_speed", 9600), ("custom_monitor_speed", "115200"), ("lib_deps", ["Lib1", "Lib2"]), @@ -496,10 +519,10 @@ def test_dump(tmpdir_factory): ( "platformio", [ + ("env_default", ["base", "extra_2"]), ("src_dir", "${custom.src_dir}"), ("build_dir", "${custom.build_dir}"), ("extra_configs", ["extra_envs.ini", "extra_debug.ini"]), - ("default_envs", ["base", "extra_2"]), ], ), (