Fix issue when board is not specified and "idedata" target is called

This commit is contained in:
Ivan Kravets
2017-11-29 22:22:31 +02:00
parent f922fac9d9
commit 10d21595c6
2 changed files with 10 additions and 5 deletions

View File

@ -63,9 +63,13 @@ def dump_defines(env):
# special symbol for Atmel AVR MCU
if env['PIOPLATFORM'] == "atmelavr":
defines.append(
str("__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))
board_mcu = env.get("BOARD_MCU")
if not board_mcu and "BOARD" in env:
board_mcu = env.BoardConfig().get("build.mcu")
if board_mcu:
defines.append(
str("__AVR_%s__" % board_mcu.upper()
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))
return defines

View File

@ -41,8 +41,9 @@ def PioPlatform(env):
def BoardConfig(env, board=None):
p = initPioPlatform(env['PLATFORM_MANIFEST'])
try:
config = p.board_config(board if board else env['BOARD'])
except exception.UnknownBoard as e:
assert env.get("BOARD", board), "BoardConfig: Board is not defined"
config = p.board_config(board if board else env.get("BOARD"))
except (AssertionError, exception.UnknownBoard) as e:
sys.stderr.write("Error: %s\n" % str(e))
env.Exit(1)
return config