waf: boards: bind get_board() to configure and build contexts

A convenience, since we don't expect the board to change for a given
configuration.
This commit is contained in:
Gustavo Jose de Sousa 2016-05-20 15:36:15 -03:00 committed by Lucas De Marchi
parent 80f03b618b
commit 844222870c
4 changed files with 10 additions and 7 deletions

View File

@ -4,8 +4,7 @@
import boards
def build(bld):
board = boards.get_board(bld.env.BOARD)
if not isinstance(board, boards.linux):
if not isinstance(bld.get_board(), boards.linux):
return
bld.ap_program(

View File

@ -5,6 +5,7 @@ from collections import OrderedDict
import sys
import waflib
from waflib.Configure import conf
_board_classes = {}
@ -160,10 +161,13 @@ def get_boards_names():
return sorted(list(_board_classes.keys()))
_board = None
def get_board(name):
@conf
def get_board(ctx):
global _board
if not _board:
_board = _board_classes[name]()
if not ctx.env.BOARD:
ctx.fatal('BOARD environment variable must be set before first call to get_board()')
_board = _board_classes[ctx.env.BOARD]()
return _board
# NOTE: Keeping all the board definitions together so we can easily

View File

@ -11,7 +11,7 @@ from waflib.Configure import conf
import boards
def configure(cfg):
board = boards.get_board(cfg.env.BOARD)
board = cfg.get_board()
if isinstance(board, boards.px4):
# toolchain is currently broken for gtest
cfg.msg(

View File

@ -92,7 +92,7 @@ def configure(cfg):
cfg.define('WAF_BUILD', 1)
cfg.msg('Setting board to', cfg.options.board)
boards.get_board(cfg.env.BOARD).configure(cfg)
cfg.get_board().configure(cfg)
cfg.load('clang_compilation_database')
cfg.load('waf_unit_test')
@ -266,7 +266,7 @@ def build(bld):
_build_dynamic_sources(bld)
bld.add_group('build')
boards.get_board(bld.env.BOARD).build(bld)
bld.get_board().build(bld)
_build_common_taskgens(bld)
_build_recursion(bld)