Fixed an issue with project generator for CLion IDE when 2 environments were used // Resolve #2824

This commit is contained in:
Ivan Kravets
2019-08-30 16:40:44 +03:00
parent 34176f974b
commit f966eeb604
3 changed files with 12 additions and 6 deletions

View File

@ -6,6 +6,11 @@ Release Notes
PlatformIO 4.0
--------------
4.0.4 (2019-??-??)
~~~~~~~~~~~~~~~~~~
* Fixed an issue with project generator for `CLion IDE <http://docs.platformio.org/page/ide/clion.html>`__ when 2 environments were used (`issue #2824 <https://github.com/platformio/platformio-core/issues/2824>`_)
4.0.3 (2019-08-30)
~~~~~~~~~~~~~~~~~~

View File

@ -57,7 +57,7 @@ if (CMAKE_BUILD_TYPE MATCHES "{{ env_name }}")
%end
endif()
% leftover_envs = set(envs) ^ set([env_name])
% leftover_envs = list(set(envs) ^ set([env_name]))
%
% ide_data = {}
% if leftover_envs:

View File

@ -194,10 +194,11 @@ def compute_project_checksum(config):
return checksum.hexdigest()
def load_project_ide_data(project_dir, envs):
def load_project_ide_data(project_dir, env_or_envs):
from platformio.commands.run import cli as cmd_run
assert envs
if not isinstance(envs, (list, tuple, set)):
assert env_or_envs
envs = env_or_envs
if not isinstance(envs, list):
envs = [envs]
args = ["--project-dir", project_dir, "--target", "idedata"]
for env in envs:
@ -217,6 +218,6 @@ def load_project_ide_data(project_dir, envs):
_data = json.loads(line)
if "env_name" in _data:
data[_data['env_name']] = _data
if len(envs) == 1 and envs[0] in data:
return data[envs[0]]
if not isinstance(env_or_envs, list) and env_or_envs in data:
return data[env_or_envs]
return data or None