As discussed internally, we're ready to push this to the 'real'
PyPI (not Test PyPI) now. The version has been incremented several
times previously during testing uploads on Test PyPI. This is no
longer necessary, so set it to the real semantic version we desire for
this stage, which is 0.1.0.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Fail hard when run under Python 2. This catches delegated commands as
well, since those are run by this file.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Use the colorama library to print informational messages from West
project commands in bright green, and all warnings and errors in bright
red. This makes it easier to distinguish them from other output (e.g.
command output from Git).
Colorized output is disabled if stdout is not a terminal. This is
handled by colorama, which wraps sys.stdout and sys.stderr.
colorama also translates ANSI escapes for us on Windows, where they
might not be natively supported.
Fixes: #25
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This pattern was cropping up in a bunch of places:
for project in _projects(args):
if _cloned(project):
...
The new helper replaces it with
for project in _cloned_projects(args):
...
Suggested by Marti Bolivar.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Use this command sequence instead of 'git clone':
git init <path>
In <path>:
git remote add origin <url>
git [--depth n] fetch origin [<branch-or-SHA>, if clone-depth is used]
git update-ref refs/heads/manifest-rev <branch-or-SHA>
git checkout --detach refs/heads/manifest-rev
This has two advantages:
- No local branches are created automatically, giving us better
control over the initial state of the repository
- The final three commands can be reused for fetching changes from an
existing repository, giving a single code path for all fetches
Let the initial state of a repository be a detached HEAD at
'manifest-rev'. We could also have the initial state have nothing at all
checked out, but it causes commands like 'git rebase' to fail, and might
look confusing.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
If the revision is a SHA, we cannot assume the clone command will
fetch anything valid, as the remote HEAD may not have been properly
initialized.
For safety in that case, run a checkout step to ensure the work tree
is properly set up.
Signed-off-by: Marti Bolivar <marti@foundries.io>
_cloned() says it prints a warning if there's an issue with the
project, but it actually calls _die(), which as it turns out is never
what we want it to do at the moment.
Let's fix that by making it a simple predicate that absorbs
_verify_repo()'s conclusions without its sting.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Set a project's URL correctly from the time the manifest is parsed,
rather than fixing it up later. The current scheme is a bit deceptive
with regards to the naming of the Project namedtuple field.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Just a bit of future-proofing; won't affect functionality. Rather than
assuming all defaults pertain to projects, keep a list of defaults
that do and filter the defaults map to just those.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Whitespace changes to appease the linter. Use an implicit continuation
line with parentheses instead of \-continuation while handling
over-indentation complaints.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Introduces a new west command to start a debugging session without
programming the flash. This can be used when you want to debug a Zephyr
application that is already running.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Analogous to running 'git branch', except for all projects. Also lists
the project(s) each branch appears in.
Example output:
$ python3 -m west branch
FIX-FOO zephyr, Kconfiglib
manifest-rev zephyr, net-tools, Kconfiglib
master zephyr, net-tools
zephyr Kconfiglib
I'm planning to change 'git clone' into 'git init' + 'git remote add' +
'git fetch' later, which avoids creating the last two local branches.
Maybe manifest-rev should be hidden as well.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Passes its command as-is to the shell, within the repositories of each
of the specified projects (or all cloned projects by default).
I was thinking of making the shell quoting for long commands optional,
by joining all the words with a space or the like, but it might get
tricky with argparse. Could look into it more later.
Piggyback some cleanup: Make the absolute path of a project available in
project.abspath, to avoid having to do a bunch of join()s with
util.west_topdir().
Fix some copy-paste comment mess-ups in the tests too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The bootstrap script no longer works properly since the src/ directory
was added to support test cases. Fix that.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Checking for a forced CMake due to the presence of CMake-related
arguments should only matter if the build directory already exists and
seems to contain a zephyr build system.
Otherwise, we always need to run CMake.
Once set for any reason, the bit should be sticky, and should be a
bool.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Add simple Google repo-like functionality, for dealing with multiple Git
repositories.
The command set is mirrored after Git. All commands except
'list-projects' accept an optional list of projects, and default to all
(cloned) projects.
- west list-projects
Lists projects and their repositories
- west fetch
Clone/fetch projects. Supports 'clone-depth', for making shallow
clones.
- west rebase
Rebase local branches to the revision specified in the manifest
- west pull
'west fetch' + 'west rebase' (similar to 'sync' in Google repo)
- west branch
Create a new branch in one or more repositories (for working on some
issue)
- west checkout
Check out a branch in each repository that has it. Supports a -b
flag for creating the branch first.
- west diff
Run 'git diff' in each repository
- west status
Run 'git status' in reach repository
There's no way to submit a multi-repository change for review yet.
Currently, a convenience branch 'manifest-rev' is created in each
project, which points to the revision specified for the project in the
manifest. 'manifest-rev' is updated by 'west fetch' and 'west pull'.
Local branches created with 'west branch' are set to track
'manifest-rev'. This makes e.g. a plain 'git status' or 'git pull' work
sensibly even when the manifest revision is an SHA.
We'll see if 'manifest-rev' is too magic later. It's explained in the
help texts of all the relevant commands at least.
It might be nicer to create 'manifest-rev' in e.g. refs/remotes instead
of refs/heads. Git doesn't seem to like trying to create a branch that
tracks a branch in refs/remotes unless it's a "proper" upstream branch
though.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This is an optional convenience wrapper around cmake + ninja (or any
other generator supported by Zephyr). It will never be mandatory to
use this wrapper. Raw CMake and Ninja/Make/etc. will always be
supported.
This command attempts to do what you mean when run from a Zephyr
application source or a pre-existing build directory:
- When "west build" is run from a Zephyr build directory, the source
directory is obtained from the CMake cache, and that build directory
is re-compiled.
- Otherwise, the source directory defaults to the current working
directory, so running "west build" from a Zephyr application's
source directory compiles it.
The source and build directories can be explicitly set with the
--source-dir and --build-dir options. The build directory defaults to
'build' if it is not auto-detected. The build directory is always
created if it does not exist.
This command runs CMake to generate a build system if one is not
present in the build directory, then builds the application.
Subsequent builds try to avoid re-running CMake; you can force it
to run by setting --cmake.
To pass additional options to CMake, give them as extra arguments
after a '--' For example, "west build -- -DOVERLAY_CONFIG=some.conf" sets
an overlay config file. (Doing this forces a CMake run.)
A separate helper library is placed in west.build to make adapting
flash/debug/debugserver workflows play nicer with build in future
patches.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Extend the CMake helper with some extra knowledge needed to support
'west build':
- add run_cmake() for general-purpose invocations of CMake
- teach the CMake cache some more Python protocol methods
Signed-off-by: Marti Bolivar <marti@foundries.io>
This ought to run the tests across a good enough spread of supported
Python versions to get started, and collect coverage statistics.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Add an exhaustive test suite.
Check expected results for all combinations of runner constructor
parameters, both when instantiating the runner directly via its
constructor and when using command line arguments via its create()
method. Ensure consistent results.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Add test coverage for flash, debug, and debugserver commands, using
runners created directly with their constructors, as well as via
command line arguments, with methods that would run syscalls mocked
out.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Follow along with what the cool kids are doing and add py.test
integration.
This patch doesn't add any test cases, but sets up packages to
test the runner classes as additional work.
To run the test suite, use:
$ python3 setup.py test
Since there are no tests, these pass.
Signed-off-by: Marti Bolivar <marti@foundries.io>
NOTE: This applies Zephyr commit 1952c56e7 ("esp32: add abitily to
flash bootloader"), which was merged without going through this
tree first.
'make flash' also flashes the bootloader
Signed-off-by: Gautier Seidel <gautier.seidel@tado.com>
Signed-off-by: Marti Bolivar <marti@foundries.io>
NOTE: This applies the West-specific portions of Zephyr commit
4a8393dd6 ("esp32: add abitily to flash bootloader"), which was
merged without going through this tree first.
add nsim runner in west
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Signed-off-by: Marti Bolivar <marti@foundries.io>
NOTE: This applies Zephyr commit 60e97de58 ("scripts: runner:
nrfjprog: Allow specifying serial number of nrfjprog"), which
was merged without going through this tree first.
This allows for scripts using nrfjrog to specify the serial number of
the attached device to use instead of showing a list of available
devices by adding an optional parameter.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdtech.com>
Signed-off-by: Marti Bolivar <marti@foundries.io>
Add a separate package for bootstrapping West and a Zephyr manifest
repository, and have the setuptools integration install that instead
of the "real" West.
Signed-off-by: Marti Bolivar <marti.f.bolivar@gmail.com>
The setuptools entry_points kwarg can generate platform-specific
scripts to run. These call the entry points with no arguments,
however, so tweak our main() to use sys.argv and its caller to stop
passing it.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This is necessary to properly configure this as a Python package with
setuptools integration.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
By default, use a sector erase to flash boards with nrfjprog.py.
To allow getting the old behavior, add an --erase flag that works the
exact same way as the corresponding jlink.py argument: if present, a
full flash erase is done before programming. If absent, only a sector
erase is done.
Fixeszephyrproject-rtos/zephyr#6147
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Ensure that CmakeCache.get_list() returns an empty list when the cache
entry is the empty string.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This is not strictly necessary for flashing and debugging, and is
causing issues in Linux environments where users run "make flash" as
root instead of installing udev rules.
Fixes: #7676
(Though we will need to revisit this when adding commands that run
CMake).
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Though commands like "west flash -h" now have help for generic runner
configuration options, runner-specific context is not printed.
In order to print this information, we would ideally want to know the
currently available runners from a build directory. Otherwise, we
can't print the current cached configuration, and the user will likely
be overwhelmed by a giant list of options etc. available for all the
runners in the package.
However, we can't print that information out without re-doing the
build, which is not safe to do when the user just gives '--help'.
To provide more complete help without causing side effects in the
default help output, add a new -H/--context option, which explicitly
re-runs the build (unless --skip-rebuild was given), parses the cache,
and prints context-sensitive help. This can be combined with the -r
option to restrict help to a particular runner.
Examples:
- Print context for all available flash runners:
west flash -H --build-dir build-frdm_k64f/
- Print context for just one runner:
west flash -H --build-dir build-frdm_k64f/ -r jlink
- Print context for all available debug runners, if current
working directory is a build directory:
west debug -H
If no context is available because there is no CMake cache file, this
command can still be used to obtain generic information about
runners. It emits a warning in this case.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Add the build directory to the central runner configuration.
This is commonly useful information.
The first place we can use it is to eliminate guessing the current
working directory when building objects to parse .config.
It's not necessary to modify the build system for this, so leave the
relevant command line flag among the general options.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Continue better integration of the runner subpackage into west by
moving the common runner configuration options into the command
core. This allows commands like "west flash -h" to display help for
common overrides like --kernel-hex.
Adjustments needed to make this happen are:
- Change the build system to separate common configuration values from
runner-specific options and arguments
- Prepare the runner core by defining a new RunnerConfig class that
represents the common configuration, and accepting that from a new
create() method, which replaces create_from_args().
- Convert all concrete runner classes to use the new style of
argument parsing and initialization.
- Group the command options appropriately for help output readability
There's still a bit of tool-specific stuff in the common
configuration (gdb and openocd configuration in particular); a more
generic way to deal with that will be necessary to better support
things like non-GDB debuggers, but that's out of scope of this patch.
All the runner-specific options are still in the runner packge, which
currently prevents them from being included in "west flash -h" etc.
Fixing that is also out of scope of this patch.
This has the ancillary benefit of getting rid of the legacy 'debug'
argument to ZephyrBinaryRunner, which is no longer appropriate since
verbose debug logging is handled by log.py in west.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Replace all informational messages with calls to log functions.
Cases which must interact via the terminal and standard output are not
modified.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
There are a few issues with the intel_s1000 runner:
- it doesn't attach to the client when running debug (this is
a part of the command's contract specified in core.py)
- it uses hard-coded sleeps when running subprocesses instead of
waiting for them to terminate
- it re-implements pre-existing popen_ignore_int() functionality (in a
way that is not portable to Windows) rather than using it directly
Fix these issues.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Make the flake8 linter happy, spell the board name with the correct
case in the module docstring, and keep the usual camel case naming
convention used for classes.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>