diff --git a/HISTORY.rst b/HISTORY.rst index 2adfdf86..76c53d72 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -24,6 +24,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) +* Rectified an issue where ``${platformio.name}`` erroneously represented ``None`` as the default `project name `__ (`issue #4717 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) diff --git a/platformio/project/options.py b/platformio/project/options.py index 70f3219e..51611d24 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -110,6 +110,7 @@ ProjectOptions = OrderedDict( group="generic", name="name", description="A project name", + default=lambda: os.path.basename(os.getcwd()), ), ConfigPlatformioOption( group="generic", diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 47c8f283..6880dd7c 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -624,6 +624,30 @@ custom_option = ${this.board} assert config.get("env:myenv", "build_flags") == ["-Dmyenv"] +def test_project_name(tmp_path: Path): + project_dir = tmp_path / "my-project-name" + project_dir.mkdir() + project_conf = project_dir / "platformio.ini" + project_conf.write_text( + """ +[env:myenv] + """ + ) + with fs.cd(str(project_dir)): + config = ProjectConfig(str(project_conf)) + assert config.get("platformio", "name") == "my-project-name" + + # custom name + project_conf.write_text( + """ +[platformio] +name = custom-project-name + """ + ) + config = ProjectConfig(str(project_conf)) + assert config.get("platformio", "name") == "custom-project-name" + + def test_nested_interpolation(tmp_path: Path): project_conf = tmp_path / "platformio.ini" project_conf.write_text(