Fix IDE project generator when board is specified // Resolve #242

This commit is contained in:
Ivan Kravets
2015-06-27 15:13:27 +03:00
parent 43205b8cd5
commit 82864d38e2
5 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,8 @@ Release History
`library.json <http://docs.platformio.org/en/latest/librarymanager/config.html>`__
* Fixed ``stk500v2_command(): command failed``
(`issue #238 <https://github.com/platformio/platformio/issues/238>`_)
* Fixed IDE project generator when board is specified
(`issue #242 <https://github.com/platformio/platformio/issues/242>`_)
2.1.2 (2015-06-21)
------------------

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
VERSION = (2, 2, "0.dev3")
VERSION = (2, 2, "0.dev4")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -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

View File

@ -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(

View File

@ -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