Commit Graph

569 Commits

Author SHA1 Message Date
Martí Bolívar 3580dd2555 test_config: don't use obsolete kwarg
Use configfile, not config_file.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:00:52 -07:00
Martí Bolívar f6331aba4f util: accept PathLike where relevant
Move the PathType type alias from west.manifest to west.util and use
it there to type-annotate individual functions as accepting either str
or an os.PathLike.

Change the source code as needed to make this true. Delete a stale
comment mentioning the long-gone bootstrapper while at it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:00:52 -07:00
Martí Bolívar e637e2ac83 manifest: use a crystal ball to aid the next commit
Add an assertion about a program invariant that will matter when
west.util gets type annotated.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:00:52 -07:00
Martí Bolívar a51b7774e4 manifest: fix Project.git() cwd on windows / 3.6.0
The subprocess's Popen constructor takes a cwd kwarg. Since v3.6, this
can be a PathLike on POSIX operating systems, but Windows didn't
officially get this feature until 3.7. This ability was back-ported
onto the v3.6 series after v3.6.1-rc1, but v3.6.0 doesn't have it.

To handle that, force cwd to a str on versions below 3.6.1 if it isn't
one already. Add a regression test just for fun, though west's CI
uses 3.6.8, so it passes even without the manifest.py patch.

It seems very unlikely to be an issue in practice since nobody should
be using 3.6.0, but I spent the time tracking this down from the docs
and (irrationally) feel like something ought to be done about it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:00:52 -07:00
Martí Bolívar 25d24287a8 .gitignore: add htmlcov/
This includes coverage data in human-readable format. It's generated
by tox.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-30 12:04:35 -07:00
Martí Bolívar 2c0567cb83 manifest: clarify validate() docstring
This is unclear; try to fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar e0eba2b7dc manifest: type annotate Manifest
This completes the initial type annotation of this module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 9492bb62c3 manifest: type annotate Project and ManifestProject
Add missing type annotations. Paths are generally 'str' for now,
though there is one place where we can use the PathType value we
defined in a previous commit.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 0020d8211e manifest: type annotate exception types
As we did for previous patches, Project has to be done as a str at
this part of the file, since we haven't gotten around to defining
Project yet.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 951317b4ae manifest: type annotate public functions
Now that the internal callers are using the right types,
annotate the validate() and manifest_path() arguments.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 84b810c7ff manifest: type annotate internal functions
This is step 1 to annotating the public APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 54e4611389 manifest: type check 'import-context' kwarg
This is used internally to pass along an import context in a way that
can't casually be done by a user, since '-' is not a valid character
in an identifier.

Adding asserts about its value won't hurt, and will help convince the
type checker that this is doing the right thing later on.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 5abde2024f manifest: fix _ManifestImportDepth() call
We should be passing a str filename here. Caught by mypy.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar b613c5d5ea manifest: clean up Project.posixpath logic
The posixpath() property if checks are copy/pasted from abspath, but
they aren't quite right. The _posixpath attribute really cares about
whether self.abspath is None, not self.topdir. Fix it.

This shouldn't affect correctness because self.abspath is non-None
exactly when self.topdir is, but is cleaner readability wise and will
make it easier to type annotate this property.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 743e3efe13 manifest: remove some ManifestProject properties
These are just duplicating functionality already present in the parent
class. The abspath property has to stay because, unlike Project,
ManifestProject might have a self._path set to None (... which,
looking at it again, is yet another reason it's not sensible to treat
it like a Project).

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar d0dd0584ed manifest: fix Project.is_cloned() if abspath is None
The os.path.isdir() function errors out if you pass it None.
Caught by mypy.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 1251612484 manifest: re-work ManifestProject's fake attributes
Change the url, revision, and clone_depth properties to plain old
attributes, changing url from None to the empty string. This will be
used to make it possible to type annotate Project in a subsequent
commit.

This seems like even more evidence that ManifestProject is not a
Project in a subtyping sense, should not have been treated like one,
and should be removed (#327).

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 1edc4511d2 manifest: validate: fix error handling
We should be passing the actual version string to
ManifestVersionError, not the parsed version object.
Do the same in the f-string just for consistency.

Caught by mypy.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 57ab1a5a91 manifest: make Project.west_commands a list always
We were forced to allow multiple values into west_commands during the
west 0.7 dev cycle as a result of the way manifest imports work, but
the way it was implemented needs a bit of fixing up.

Make sure that Project and ManifestProject can take either a list or
a string of west_commands and that the resulting object attribute is
always a list, for consistency. Fix the docstrings to make clear
what's going on. Adjust users in commands.py -- this is cleaner now.

Callers have had to cope with the possibility that this could be a
list since v0.7 was released, so this shouldn't break any up-to-date
extensions.

This patch also enables a schema relaxation where we could support
multiple extension spec YAML files in a single manifest written by
hand. But let's defer that work until someone actually asks for it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar d611af332b manifest: make _flags_ok() always return bool
This will make its type signature cleaner.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 8c51e8b852 manifest: fix abstraction violation
The SchemaError type's error message should be accessed via the msg()
property, not the underlying private instance variable.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar fd53bf6086 manifest: refactor the file
This is partially being done to clean up and reorganize, but the
specific goal in mind is making it easier to add type information
to more functions and methods.

- make Manifest.projects a property, and ensure the underlying
  _projects attribute is always a list

- move code around so that definitions of types are visible more
  often when variables of those types are used. For instance, move
  the Project definition above Manifest, because many variables
  in the Manifest methods have type Project, List[Project], etc.

  This is in my opinion a readability improvement, and also will allow
  using the token Project as a type name from the Manifest class
  definition later. Similar comments apply to named tuple definitions,
  etc.

No functionality changes expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-24 09:59:27 -07:00
Martí Bolívar 618020d197 Revert "app: make main() in west.app.main module public API"
This reverts commit 5843eef713. We
figured out another way to accomplish the goal that this was done for,
so there's no reason to expose these details to the user now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-18 13:49:20 -07:00
Torsten Rasmussen 5843eef713 app: make main() in west.app.main module public API
Added documentation to main() as it is now officially supported to
directly call main from west.app.main module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-17 14:46:57 -07:00
Gerard Marull-Paretas 26b69f987e west: initial support for type hints
These changes introduce initial support for type hints. Support for mypy
static analysis on GitHub workflows has also been enabled.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-06-02 10:58:40 -07:00
Martí Bolívar b93ad74893 lint: flake8 fixes
Some new flake8 errors are enabled by default now; fix them up:

./src/west/manifest.py:1633:47: E741 ambiguous variable name 'l'
./src/west/app/project.py:802:21: F541 f-string is missing placeholders

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-06-01 14:26:27 -07:00
Martí Bolívar f80b8cfde2 west manifest: add --path action
This prints the absolute path of the manifest file.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-31 12:46:09 -07:00
Martí Bolívar a53ec10cf2 west diff: only print output for projects with nonempty diffs
The output is kind of cluttered when many projects are available.
Let's silence output for projects with no diff when not in verbose mode.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 12:39:10 -07:00
Martí Bolívar 8e01b5294a log: add use_color() API function
This is like the internal routine _use_colors(), but it never warns.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 12:39:10 -07:00
Martí Bolívar 95c2eaa0f2 MAINTAINERS.rst: add note for starting next version
We need a .99 patchlevel during development.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-09 17:37:08 +01:00
Martí Bolívar a27941e036 init: fix error message when init directory already exists
The wording here is wrong. Just print the real cause.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-09 17:37:08 +01:00
Martí Bolívar 1232f27b4c version: 0.7.99
This is now the west 0.8 development branch.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-09 17:37:08 +01:00
Martí Bolívar f8674ed786 MAINTAINERS.rst: make copy pasting commands easier
Remove the $ prefixes so the commands can just be copy pasted line by
line during testing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-28 16:45:54 +01:00
Martí Bolívar d6ef7ad9ef MAINTAINERS.rst: some changes from going through this once
A few process changes from doing a point release, mainly that we'll
cut an alpha release instead of an RC. That's being done because
uploading an alpha is something a maintainer can just do, without
having to go through the usual "bump version.py" review process.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-28 16:45:54 +01:00
Martí Bolívar 8ed75547ed manifest: filter duplicates when merging west-commands
If the user imports a manifest, and specifies its west-commands, like
this:

    - name: zephyr
      west-commands: scripts/west-commands.yml

where zephyr/west.yml also specifies a west-commands, then they get
warnings when the manifest is parsed, like this:

    WARNING: ignoring project zephyr extension command "completion"; command "completion" is already defined as extension command
    WARNING: ignoring project zephyr extension command "boards"; command "boards" is already defined as extension command
    WARNING: ignoring project zephyr extension command "build"; command "build" is already defined as extension command
    WARNING: ignoring project zephyr extension command "sign"; command "sign" is already defined as extension command
    WARNING: ignoring project zephyr extension command "flash"; command "flash" is already defined as extension command
    WARNING: ignoring project zephyr extension command "debug"; command "debug" is already defined as extension command
    WARNING: ignoring project zephyr extension command "debugserver"; command "debugserver" is already defined as extension command
    WARNING: ignoring project zephyr extension command "attach"; command "attach" is already defined as extension command

Filter duplicates when merging west commands during manifest parsing
to avoid this outcome.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-24 06:08:45 -08:00
Martí Bolívar aded97277e commands: add WestCommandSpec __repr__
This is just for debugging the extension command internals.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-24 06:08:45 -08:00
Martí Bolívar 04d20c2adb update: make output more helpful
Make the 'west update' output more helpful:

- If --keep-descendants is given, also run 'git status' to highlight a
  dirty tree, etc. Also make the west output prefixed by 'west update';
  it's clear what project is being worked on due to the earlier banner.

- if --rebase is given, do the same change to just use 'west update'
  as an output prefix.

- if neither is given, remove --quiet and the small_banner() call. This
  also shows information about a dirty tree.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-14 09:25:21 -08:00
Martí Bolívar 429e68c1bd project.py: delete dead code
Nobody is using the MANIFEST variable.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-14 09:25:21 -08:00
Torsten Rasmussen e02243488d zephyr base: Fixes issue with failing to discover Zephyr base
Fixes: #378

When Zephyr is also the manifest repository then west fails to identify
ZEPHYR_BASE correctly as the project name is manifest, with path zephyr.

Therefore, before checking projects with path `zephyr` we first check if
the manifest repository has path == zephyr.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-02-13 06:08:10 -08:00
Martí Bolívar b73900510b Add MAINTAINERS.rst
This is where we'll put notes for west maintainers.

For now, it includes information on cutting a release.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-10 11:02:16 -08:00
Martí Bolívar b48077837c West 0.7.1
Includes a 'west topdir' change needed to make zephyr's use of this
command work properly.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-10 06:44:14 -08:00
Torsten Rasmussen 5762e04241 topdir: west topdir prints posix style path.
Fixes: #374

This commit ensures that west topdir always prints in posix style and
thus fixes an issue in windows where CMake fails to parse the path when
'\' is used as separator.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-02-10 12:24:19 +01:00
Martí Bolívar 0e8b1650cf west update: refactor update() method
With all the statistics gathering, this is getting pretty long and
hard to read. Let's factor it out into some new methods.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-07 09:57:21 -08:00
Martí Bolívar b2d739b29e west update: 'initializing', not 'cloning and initializing'
We aren't really cloning the project in this step. Let's fix the
output so it's more clear.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-07 09:57:21 -08:00
Martí Bolívar c73725d45d project.py: more west update --stats
Track all operations which invoke a subprocess.

Track the total time in the update() call, and print out time spent
doing work not explicitly tracked.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-07 09:57:21 -08:00
Martí Bolívar 9219704069 West 0.7.0
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-06 19:10:07 -08:00
Martí Bolívar 69945dbca3 West v0.7.0rc2
Now with Windows and macOS passing tox.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Kumar Gala 3a36e2c51a github: change workflow to not fail-fast
Try and build on all matrix cfg regardless if one of them happens to
fail.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 13:12:23 -08:00
Kumar Gala df68644bce github: Fix workflow to run on differents host (mac, win)
Fix copy/paste issue in which the 'runs-on' was always ubuntu-latest so
we didn't actually do anything with the matrix.os to run on mac or
windows.

Also cleanup some minor formatting and report the sys.platform so we can
verify in the future we are on the correct platform.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 13:12:23 -08:00
Martí Bolívar 1a9721b062 tests: relax check_proj_consistency url checks on windows
The test_import_project*() cases in test_project.py are failing on
windows for reasons that are irrelevant and ultimately down to path
comparisons not being canonicalized for that platform.

Rather than fix tests I don't really think are broken, check if the
expected URL is an actual directory and fall back on PurePath
comparisons instead.

Keep the behavior the same for macOS and Linux.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00