Initialize a new project or update existing passing working environment name and its options // Resolve #3686

This commit is contained in:
Ivan Kravets
2020-10-29 22:59:48 +02:00
parent da6cde5cbd
commit 5a1b0e19b2
4 changed files with 27 additions and 10 deletions

View File

@ -11,6 +11,7 @@ PlatformIO Core 5
5.0.2 (2020-09-??)
~~~~~~~~~~~~~~~~~~
- Initialize a new project or update existing passing working environment name and its options (`issue #3686 <https://github.com/platformio/platformio-core/issues/3686>`_)
- Automatically build PlatformIO Core extra Python dependencies on a host machine if they are missed in the registry (`issue #3700 <https://github.com/platformio/platformio-core/issues/3700>`_)
- Improved "core.call" RPC for PlatformIO Home (`issue #3671 <https://github.com/platformio/platformio-core/issues/3671>`_)
- Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps <https://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option (`issue #3664 <https://github.com/platformio/platformio-core/issues/3664>`_)

2
docs

Submodule docs updated: 500b826845...bc6c9b2e4c

View File

@ -174,8 +174,10 @@ def project_init(
if is_new_project:
init_base_project(project_dir)
if board:
fill_project_envs(
if environment:
update_project_env(project_dir, environment, project_option)
elif board:
update_board_envs(
ctx, project_dir, board, project_option, env_prefix, ide is not None
)
@ -358,7 +360,7 @@ def init_cvs_ignore(project_dir):
fp.write(".pio\n")
def fill_project_envs(
def update_board_envs(
ctx, project_dir, board_ids, project_option, env_prefix, force_download
):
config = ProjectConfig(
@ -417,6 +419,26 @@ def _install_dependent_platforms(ctx, platforms):
)
def update_project_env(project_dir, environment, project_option):
if not project_option:
return
config = ProjectConfig(
os.path.join(project_dir, "platformio.ini"), parse_extra=False
)
section = "env:%s" % environment
if not config.has_section(section):
config.add_section(section)
for item in project_option:
if "=" not in item:
continue
_name, _value = item.split("=", 1)
config.set(section, _name.strip(), _value.strip())
config.save()
def get_best_envname(config, board_ids=None):
envname = None
default_envs = config.default_envs()

View File

@ -358,12 +358,6 @@ class ProjectConfigBase(object):
click.secho("Warning! %s" % warning, fg="yellow")
return True
def remove_option(self, section, option):
return self._parser.remove_option(section, option)
def remove_section(self, section):
return self._parser.remove_section(section)
class ProjectConfigDirsMixin(object):
def _get_core_dir(self, exists=False):