Add an empty file .west_topdir into the top-level west directory
during initialization time, and search for it when trying to locate
that directory in the bootstrap script and west itself.
This avoids ambiguities when other directories in the installation are
also named 'west' (such as zephyr/doc/west), and propagates a fix made
in src/west/util.py to the equivalent bootstrap routine in
src/west/bootstrap/main.py (west installed in the root directory is
now found there too).
Signed-off-by: Marti Bolivar <marti@foundries.io>
This doesn't affect the behavior of the current west, but will be
needed to test an upcoming patch which creates and uses that file.
Signed-off-by: Marti Bolivar <marti@foundries.io>
Change the way the project test case fixtures are set up to create
local git repositories in the temporary directory, and a manifest that
refers to them.
This lets the test cases run without a network connection, which is
faster, and avoids false negatives that occur when the test
environment has a bad network connection.
Signed-off-by: Marti Bolivar <marti@foundries.io>
A tuple was originally used to indicate that the variable was
immutable, but this generates a warning on python 3.7; setuptools
really wants a list.
Signed-off-by: Marti Bolivar <marti@foundries.io>
I was confused by the other design, because I intuitively expected West
metadata to go in .west/. To me the other design feels a little bit like
having an empty /home/foo/user/ directory that marks the /home/foo/
directory as containing the user's files.
Use west/ instead of .west/ to avoid "hiding" the implementation of the
building/flashing commands. I would've preferred to split them from the
repo-like functionality instead, but if they're going to be in the same
repository, then it's a decent comprise.
Remove the code that hides the west directory on Windows (via 'attrib')
as well, since it doesn't make much sense anymore.
This commit also fixes a small bug in west_topdir(): A west/ in the root
directory wasn't found.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
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>