From 82864d38e2fa14ee49af01f43aa724d3fef8658d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 27 Jun 2015 15:13:27 +0300 Subject: [PATCH] Fix IDE project generator when board is specified // Resolve #242 --- HISTORY.rst | 2 ++ platformio/__init__.py | 2 +- platformio/builder/tools/piomisc.py | 2 ++ platformio/commands/init.py | 2 +- platformio/ide/projectgenerator.py | 8 ++++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 398550c6..dd3dbf73 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,8 @@ Release History `library.json `__ * Fixed ``stk500v2_command(): command failed`` (`issue #238 `_) +* Fixed IDE project generator when board is specified + (`issue #242 `_) 2.1.2 (2015-06-21) ------------------ diff --git a/platformio/__init__.py b/platformio/__init__.py index cfeb39e7..d69071fd 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 2, "0.dev3") +VERSION = (2, 2, "0.dev4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 80539c09..0098d63b 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -141,6 +141,8 @@ def DumpIDEData(env): # global symbols for item in env.get("CPPDEFINES", []): + if isinstance(item, list): + item = "=".join(item) data['defines'].append(env.subst(item)) # special symbol for Atmel AVR MCU diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 4799d5fc..3346b635 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -86,7 +86,7 @@ def cli(project_dir, board, ide, disable_auto_uploading, env_prefix): project_file, board, disable_auto_uploading, env_prefix) if ide: - pg = ProjectGenerator(project_dir, ide) + pg = ProjectGenerator(project_dir, ide, board[0] if board else None) pg.generate() click.secho( diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index c3ee89c9..3ee2b1e9 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -13,9 +13,10 @@ from platformio import util class ProjectGenerator(object): - def __init__(self, project_dir, ide): + def __init__(self, project_dir, ide, board=None): self.project_dir = project_dir self.ide = ide + self.board = board self._tplvars = {} self._gather_tplvars() @@ -26,6 +27,7 @@ class ProjectGenerator(object): return sorted([d for d in listdir(tpls_dir) if isdir(join(tpls_dir, d))]) + @util.memoized def get_project_env(self): data = {"env_name": "PlatformIO"} with util.cd(self.project_dir): @@ -33,9 +35,11 @@ class ProjectGenerator(object): for section in config.sections(): if not section.startswith("env:"): continue - data['env_name'] = section[4:] + data = {"env_name": section[4:]} for k, v in config.items(section): data[k] = v + if self.board and self.board == data.get("board"): + break return data @util.memoized