Skip to content

Commit

Permalink
scripts: avoid unnecessary 'west build --force'
Browse files Browse the repository at this point in the history
Commit 88fb8ba ("scripts: improve west build's board handling")
lets us specify the board with a build.board config or BOARD
environment variable.

However, under some conditions, e.g. if the use has
build.pristine=auto and build.board=some_board, the following fails a
check_force call:

west build samples/hello_world
west build samples/philosophers

The problem is that the check_force wasn't made aware of the other
places a board can come from. Fix that.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
  • Loading branch information
mbolivar-nordic authored and carlescufi committed May 24, 2019
1 parent f5f1b22 commit 8b9b7e7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scripts/west_commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def do_add_parser(self, parser_adder):

def do_run(self, args, remainder):
self.args = args # Avoid having to pass them around
self.config_board = config_get('board', None)
log.dbg('args: {} remainder: {}'.format(args, remainder),
level=log.VERBOSE_EXTREME)
# Store legacy -s option locally
Expand Down Expand Up @@ -169,16 +170,15 @@ def do_run(self, args, remainder):

def _find_board(self):
board, origin = None, None
config_board = config_get('board', None)
if self.cmake_cache:
board, origin = (self.cmake_cache.get('CACHED_BOARD'),
'CMakeCache.txt')
elif self.args.board:
board, origin = self.args.board, 'command line'
elif 'BOARD' in os.environ:
board, origin = os.environ['BOARD'], 'env'
elif config_board is not None:
board, origin = config_board, 'configfile'
elif self.config_board is not None:
board, origin = self.config_board, 'configfile'
return board, origin

def _parse_remainder(self, remainder):
Expand Down Expand Up @@ -301,17 +301,21 @@ def _sanity_check(self):
if apps_mismatched:
self.run_cmake = True # If they insist, we need to re-run cmake.

# If CACHED_BOARD is not defined, we need --board from the
# command line.
# If CACHED_BOARD is not defined, we need some other way to
# find the board.
cached_board = self.cmake_cache.get('CACHED_BOARD')
log.dbg('CACHED_BOARD:', cached_board, level=log.VERBOSE_EXTREME)
# If app_mismatched and pristine are true we will run pristine on the
# build, invalidating the cached board. Whenever we run pristine we
# require the user to provide all the require inputs again.
# If apps_mismatched and self.auto_pristine are true, we will
# run pristine on the build, invalidating the cached
# board. In that case, we need some way of getting the board.
self.check_force((cached_board and
not (apps_mismatched and self.auto_pristine))
or self.args.board,
'Cached board not defined, please provide --board')
or self.args.board or self.config_board or
os.environ.get('BOARD'),
'Cached board not defined, please provide it '
'(provide --board, set default with '
'"west config build.board <BOARD>", or set '
'BOARD in the environment)')

# Check consistency between cached board and --board.
boards_mismatched = (self.args.board and cached_board and
Expand Down

0 comments on commit 8b9b7e7

Please sign in to comment.