Commit Graph

904 Commits

Author SHA1 Message Date
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
Martí Bolívar a0f390ab23 project.py: fix windows-style paths as manifest URLs
If the manifest URL is a windows-style path,
e.g. C:\Users\marti\my-manifest, then the current code produces a
manifest.path configuration option set to '\Users\marti\my-manifest'
instead of the expected 'my-manifest'.

Fix it by using PurePath so we get PureWindowsPath on windows, instead
of using the low-level posixpath. Note that PurePath is PurePosixPath
on POSIX platforms, so the behavior is the same on those.

Fix the import order while we are here, moving stdlib imports to their
proper section.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar 4f6f060863 manifest: don't take normpath in ManifestProject.__init__
We should be using PurePath comparison if we need to compare paths.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar dbc1a87d84 manifest: fix _manifest_content_at() on Windows
Git is returning empty content for dir\file.yml on Windows.
Using PurePosixPath fixes it there, and can't possibly break anything
on Unix.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar e36901ac8a manifest: one more Project.__repr__ fix
Hopefully the last one.

Note that this "fix" is purely cosmetic, for use when reading debugger
output.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar 1b27696c31 tests: add str(pytest LocalPath) calls in conftest
The LocalPath object is not iterable on at least some versions of
pytest, which means that some checks done in subprocess ("\t" in
some_instance) are throwing exceptions.

Sprinkle some str() calls around to make this go away.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar f9c44f3094 tree-wide: use lists for git calls involving paths
The shlex.split() call done in Project.git() when you pass a string
isn't doing the right thing for Windows-style abspaths. Let's use
lists instead.

This converts all the cases caught by the test suite. Hopefully there
aren't any more.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar 8a1c40e6d1 .gitignore: exclude more coverage files
Catch the .coverage.NNNN.MMMM files too.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 13:12:23 -08:00
Martí Bolívar 831b012d41 west update: add --stats option
This prints performance statistics. Zephyr wants it for figuring out
slowdowns observed in CI.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-05 09:11:33 -08:00
Martí Bolívar 4ab5c08c60 west 0.7.0rc1
At this point, the manifest schema is frozen, so we can also update
west.manifest.SCHEMA_VERSION to 0.7, as this version of west parses
anything that 0.7 will be able to parse.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 08:11:19 -08:00
Martí Bolívar ba9825739a manifest: fix docstring
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 08:11:19 -08:00
Martí Bolívar 2cfcff1816 manifest: tweak logging
"Close the parentheses" when done resolving a project import, and add
project revision information when importing from a project.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 08:11:19 -08:00
Martí Bolívar 92c18ac55a main: move verbose manifest logging to project.py
This kind of verbose detail about the parsed manifest is not always
useful to others.

E.g. downstream in the nRF Connect SDK, this is cluttering up the
output of a west extension that compares mainline zephyr's manifest
repository revisions with NCS's. This seems like an annoyance to me,
so this logging shouldn't be global.

We do, however, need it for debugging when resolving the manifest
and running 'west -vv update'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 08:11:19 -08:00
Martí Bolívar 16e2250e45 manifest: hacky import loop detection
I keep running into edge cases trying to get proper import loop
detection going, so just catch the RecursionError it causes and
convert it to ManifestImportFailed.

Testing this takes a while, so we only will do that from CI for now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 08:11:19 -08:00
Martí Bolívar 52ff93f766 manifest: factor private context into a namedtuple
I want to add more values to the private context we pass around as we
resolve the manifest, but it's annoying to do so one parameter at a
time, since it requires updating a lot of functions.

Let's make a container object for this state and pass it around instead.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-03 07:37:37 -08:00
Martí Bolívar 900711acd0 west update: don't update projects twice
Track which projects we've already updated via update_importer() and
don't do it twice if it's already done.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-03 07:37:37 -08:00