mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-10 13:11:59 +00:00
We have agreed to develop a meta-tool named "west", which will be a swiss-army knife of Zephyr development. It will support use cases like building, flashing and debugging; bootloader integration; emulator support; and integration with multiple git repositories. The basic usage for the tool is similar to git(1): west [common opts] <command-name> [command opts] [<command args>] There are common options, such as verbosity control, followed by a mandatory sub-command. The sub-command then takes its own options and arguments. This patch adds the basic framework for this tool, as follows: - a Python 3 package named 'west', in scripts/meta. There is no PyPI integration for now; the tool will be improving quickly, so we need to keep users up to date by having it in tree. - an main entry point, main.py, and a package-level shim, __main__.py - a cmd subpackage, which defines the abstract base class for commands - logging (log.py) - catch-all utilities (util.py) - Windows and Unix launchers so users can type "west" to run the tool after sourcing the appropriate zephyr-env script for their environment. Subsequent patches will start to add individual commands. Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
# Copyright 2018 Open Source Foundries Limited.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
'''Logging module for west
|
|
|
|
Provides common methods for logging messages to display to the user.'''
|
|
|
|
import sys
|
|
|
|
VERBOSE_NONE = 0
|
|
'''Base verbosity level (zero), no verbose messages printed.'''
|
|
|
|
VERBOSE_NORMAL = 1
|
|
'''Base verbosity level, some verbose messages printed.'''
|
|
|
|
VERBOSE_VERY = 2
|
|
'''Very verbose output messages will be printed.'''
|
|
|
|
VERBOSE_EXTREME = 3
|
|
'''Extremely verbose output messages will be printed.'''
|
|
|
|
VERBOSE = VERBOSE_NONE
|
|
'''Global verbosity level. VERBOSE_NONE is the default.'''
|
|
|
|
|
|
def set_verbosity(value):
|
|
'''Set the logging verbosity level.'''
|
|
global VERBOSE
|
|
VERBOSE = int(value)
|
|
|
|
|
|
def dbg(*args, level=VERBOSE_NORMAL):
|
|
'''Print a verbose debug logging message.
|
|
|
|
The message is only printed if level is at least the current
|
|
verbosity level.'''
|
|
if level > VERBOSE:
|
|
return
|
|
print(*args)
|
|
|
|
|
|
def inf(*args):
|
|
'''Print an informational message.'''
|
|
print(*args)
|
|
|
|
|
|
def wrn(*args):
|
|
'''Print a warning.'''
|
|
print('warning:', end=' ', file=sys.stderr, flush=False)
|
|
print(*args, file=sys.stderr)
|
|
|
|
|
|
def err(*args, fatal=False):
|
|
'''Print an error.'''
|
|
if fatal:
|
|
print('fatal', end=' ', file=sys.stderr, flush=False)
|
|
print('error:', end=' ', file=sys.stderr, flush=False)
|
|
print(*args, file=sys.stderr)
|
|
|
|
|
|
def die(*args, exit_code=1):
|
|
'''Print a fatal error, and abort with the given exit code.'''
|
|
print('fatal error:', end=' ', file=sys.stderr, flush=False)
|
|
print(*args, file=sys.stderr)
|
|
sys.exit(exit_code)
|