Commit Graph

512 Commits

Author SHA1 Message Date
Marti 402a10a68c tests: fix test_config.py on windows
'west config' testing is giving false negatives on Windows. To fix:

- canonicalize and fix up global config path testing
- avoid passing paths to cmd(); they don't play well with
  shlex.split() and aren't necessary to make sure the config
  command is behaving properly

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti c20abf8868 util: add canon_path()
We need a common definition for canonicalizing paths; the lack of one
is causing issues on Windows.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar 3f81eb4195 manifest: project names must be unique
It is always possible to satisfy this constraint now that project URLs
may be specified explicitly.

(This restriction will be necessary to make manifest imports work
sensibly -- we should have done this before...).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar 5415292aa4 tests: add test cases for explicit project URLs
Make sure to update comments for existing tests with modified semantics.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar a33d92596b manifest: demote defaults to a kwarg
We don't apply the west default revision correctly if defaults is
None. Since we find it convenient to let west figure out the defaults
for us, demote it to a kwarg as well and let it be None more gracefully.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar d6de81aafb manifest: support explicit project URLs
Allow each project element to explicitly specify its URL. This avoids
forcing users to name projects according to their URLs, which can be
inconvenient (and prevents us from enforcing a rule that project names
are unique).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar 397a731a98 manifest: demote Project remote to a kwarg
We're going to add explicit project URLs to the manifest, so the
remote should no longer be a positional.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar cd9b4fa651 main.py: don't throw away tracebacks
Add a helper for saving the current traceback to a temporary file and
use it appropriately from the exception handlers in main(), This avoid
throwing away information in case the error was nondeterministic.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar b9d6600a66 main: fix CalledProcessError handling
I'm not sure this ever worked; the args field is an empty tuple even
in Python 3.4. Use cmd and returncode attributes appropriately
instead.

Don't offer the 'for a stack trace' message here anymore: this doesn't
indicate a west error, which is what that is meant to capture.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar 1c6d0d3dcb tests: fixture setup optimizations
It takes 20 seconds on my machine to run the full set of tests, which
is slow enough that testing breaks me out of flow state.

On the suspicion that creating git repositories and using the file://
protocol when cloning (which prevents use of hardlinks) is slowing
things down, use some pytest features to avoid creating git
repositories repeatedly. Also let git use hardlinks when they are
available when cloning repositories.

On my system, this brings the average of 10 runs from 20.129 seconds
spent testing to 17.649, a 12% improvement overall. Still not ideal,
but not worth throwing away, either.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar adf7e5bd2c tests: don't test pre-unification features
Don't copy the west tree; tox already installs it for us into the new
virtualenv, and we don't run any code out of a checked out repository
anymore, so doing things related to that is unnecessary.

This also makes the tests run a little bit faster (around a 5% or more
speedup on my system).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar 34de0ad936 tests: remove empty_config.py
It's not clear what this is doing here. It doesn't begin with "test",
so it's not being tested, and it seems to be a copy of test_config.py
with some important features needed to avoid modifying the user's
configuration.

Delete it.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar e19e7e61b5 tests: flatten the hierarchy
There's no good reason to have these tests in subdirectories. Flatten
them out. Keep the directory of invalid manifests separate to keep the
directory listing clean, though.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-20 11:06:53 +02:00
Marti Bolivar c23549fe33 README: fix link to docs
Fixes: #264
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-16 13:48:29 +02:00
Marti Bolivar cb660b6e28 _bootstrap: remove it
Get rid of the separate bootstrapper. Implement 'west init' as a
regular WestCommand which combines the bootstrapper + PostInit.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar 4b880be54e commands: allow commands which don't require an installation
This will be useful to support init as a regular WestCommand.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar bee4547c81 commands: project: import more from os.path
Save some characters.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar ca19fed267 main.py: don't look for ZEPHYR_BASE if command is init
While this has no effect right now, it will make sense in
general (init --> no topdir --> it's not clear what zephyr you mean)
and will be required for making init a regular command.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar ce9899267a configuration: support read_config() outside of an installation
That's perfectly fine: load the system and global ones.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar 7153520647 setup.py: whitespace cleanup
Trivial.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti Bolivar 8466885412 version: set to 0.5.99
Start v0.6.0 development. We're about to delete the bootstrapper,
which is a big enough change to need a version bump.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-01 15:22:06 -06:00
Marti 1980f707d6 West v0.5.8
This adds a couple of bootstrapper error handling fixes.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-04-09 22:09:04 +02:00
Marti fd53d839e9 bootstrap: check for a missing west.main
Print a more helpful message in case .west/west/src doesn't contain an
importable west.main module. (A trash .west can remain if 'west init'
fails.)

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-04-09 22:09:04 +02:00
Marti bb718c5a78 bootstrap: check for git before running it
Avoid issues seen on Windows where git is installed but not on PATH.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-04-09 22:09:04 +02:00
Marti Bolivar 5113fecc09 West v0.5.7
This includes fixes for API documentation, a configuration option handling
issue, and an improved ZEPHYR_BASE check.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Marti Bolivar f1ca4a1d11 main.py: move west config to its own section in the help
It's not about managing multiple repositories. It's a bit weird to put it on
its own, but that's better than putting it in the wrong section.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Marti Bolivar 619d64032a main: improve ZEPHYR_BASE mismatch check
Fixes: #239
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Marti Bolivar 20d1773439 commands: fix configuration option to disable extensions
We need to be using getboolean() to parse "true" and "false" strings into their
equivalent booleans. This isn't happening, so setting the option to any
nonempty string is continuing to allow extensions to run. Fix that, and move
the config option parsing to extension_commands() to make sure the fix only
needs to happen once.

Fixes: #238
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Marti Bolivar 89c8897554 commands: s/external/extension/
Change "external" to "extension" in variable names and a config option.

This configuration option is undocumented and it isn't working correctly
anyway, so changing its name won't hurt anything. The next patch will fix its
behavior.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Marti Bolivar 988376c5a0 docs and output string fixes
Fix or improve various docstrings so they are usable from Sphinx. Without this
patch, we can't provide API documentation for west from the zephyr docs tree.

Remove comments from the various schema files. We'll move this information into
the zephyr documentation.

Use "extension" instead of "external" in some log messages for consistency with
the final name of the pluggable commands that aren't built-in.

No behavioral changes other than the slightly different printlines.

Fixes: #240
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-28 19:25:19 +01:00
Torsten Rasmussen d5f8caf2c9 West v0.5.6
Release which contain a fix for the major issue in relation to
fetching.
The error could appear upon fetching when remotes are changed or force
pushed.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-20 15:32:30 -06:00
Torsten Rasmussen d98ccf9e80 git: git fetch now uses -f
It has been discovered that in the event that a different remote is
added to manifest file which contains same branches but cannot be
fast forwarded into the local refs space, then a west update will fail
with the error:
 ! [rejected] <branch> -> refs/west/<branch> (non-fast-forward)

This commit fixes this issue by introducing '-f' when fetching.

This commit has additional test for verifying the fix.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-20 15:32:30 -06:00
Marti Bolivar 7ab671189d West v0.5.5
Cut a new version for the latest changes.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-15 13:48:38 +01:00
Marti Bolivar c43c9579e4 bootstrap: clean up messaging
- Use colors (regardless of config -- this should be fixed to use config
  when we merge everything into pypi)

- Align banner output with project.py

- Don't leave a west branch checked out to avoid a warning on first
  self update

Fixes: #201
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-15 13:48:38 +01:00
Marti Bolivar 1b3dc9b596 project.py: post-refactor clean up of logging calls
While reviewing logging calls during the most recent extraction of
project.py code into manifest.py, it became clear that the colorized
and "=== '-prefixed _banner() routine was being called way too often.

Clean this up by adding a new _msg() routine that is prefixed with
"--- " and not colorized. This still lets the output stand out from
git output, but doesn't clutter the output.

Conversely, some _banner() calls were missing, such as in the Diff
class. Fix all that up and make the printing more consistent.

While we are here, normalize various project-related printlines to use
{name} as a prefix for most _msg calls related to a project. The path
was already printed where appropriate in a _banner() call that
happened earlier in these cases.

Fixes: #229
Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-15 13:48:38 +01:00
Marti Bolivar 9488e57c66 More clean up for manifest.py / project.py responsibilities
This commit is further progress on #191, but doesn't fix it entirely.

West's design has always been to split code into reusable libraries
and commands which wrap them. The extra effort is justified since West
is pluggable by extension commands, which often benefit from being
able to use the library pieces.

Although the code in project.py started out self-contained, it's
gradually being refactored to fit the design.

Continue that by factoring two more features into manifest.py: helpers
for running git commands in a project and formatting strings using
project attributes.

This lets us remove almost all of the wrappers around west.log in a
way that makes the code easier to read. The remaining _inf() is
renamed _banner() to make its purpose clearer.

Delete a fair bit of dead code left over from the older multirepo
commands which were deleted from v0.4.0 while we are here.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-15 13:48:38 +01:00
Torsten Rasmussen aa8c183649 zephyr base: fixed west config zephyr.base when relative
Fixes: #231

This commit ensures that zephyr.base will be joined with west_topdir()
when a relative path is used in west config.

The previous solution was using os.path.abspath which would give
different results depending on current location when invoking west
command.

The advantage of allowing relative path in .west/config over requiring
an absolute path, is that it allows a user to rename a project's parent
folders without having to update zephyr.base.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-14 12:30:39 +01:00
Torsten Rasmussen fdb634fd8f config: Fallback to project with path 'zephyr'
This commit allows fallback to set zephyr base to point to the project
which has the path zephyr.
If zephyr base in not set in any way and no project has path 'zephyr'
then an error is printed.

Having the fallback mechanism in an independent commit allows to easily
rollback the commit when it is considered that a project always will
have zephyr base defined as part of west installation.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-12 09:33:48 -06:00
Torsten Rasmussen 701e5198de zephyr-base: ZEPHYR_BASE env takes precedence over config settings
This commit changes the order of precedence so that environment setting
takes precedence over west config option.
It also introduces a new config file setting, to allow to specify which
setting: environment or configfile that will take precedence.
To simplify search for ZEPHYR_BASE, this setting will now be written to
the local .west/config during init and selfupdate, if non-existing.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-12 09:33:48 -06:00
Torsten Rasmussen 9168e44b8a config: Fallback to configparser if configobj is missing
This commit allows fallback to python standard configparser in case
configobj package is not installed.

This allows `west config` to work with existing bootstrappers.

Having the fallback mechanism in an independent commit allows to easily
rollback the commit when it is considered that all has configobj as
part of west installation.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-11 14:59:26 -06:00
Torsten Rasmussen 397bc5bac0 command: Added `west config` command for handling of west config files
Fixes: #198 #213

This commit add the command `west config` for getting and setting of
key - value pairs in:
- Project specific: `<project>/.west/config`
- Global specific: `~/.westconfig`
- System specific, Linux:`/etc/westconfig`
                   MacOS: `/usr/local/etc/westconfig`
                   Windows: `%PROGRAMDATA%/west/config`
It also includes corresponding test cases.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-11 14:59:26 -06:00
Torsten Rasmussen 52f151b346 config: renaming of config.py into configuration.py
As part of introducing 'west config' command, the current config.py is
renamed into configuration.py in order to have distinct name for each
module as west commands have module named same as command.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-03-11 14:59:26 -06:00
Marti Bolivar 8aeca9dfef main.py: fix extra newline in west --help
Remove trailing whitespace from the format_help() return value. This
prevents an extra blank line from appearing in the west --help output.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-03-10 16:27:43 -06:00
Carles Cufi cc5a05fec5 bootstrap: Use normpath() to avoid initializing in wrong folder
On Windows 10, with Python 3.7.1, the following was not working:

west init -l zephyr/
or
west init -l zephyr\

because of the trailing (back)slash being interpreted as an additional
folder and west initializing itself inside the zephyr folder instead of
doing it in the enclosing one.

By normalizing the path we avoid this issue entirely.
Note that this is actually due to a regression that was fixed:
https://bugs.python.org/issue31047

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-03-05 14:26:05 +01:00
Torsten Rasmussen 786fa35647 init: Handling of missing west.yml when loading extension commands.
Fixes: #214

This commit ensures that west built-in commands are still accessible
even if west.yml cannot be found.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-02-28 09:54:14 +01:00
Torsten Rasmussen 2598c0585a init: fixed issue with self.path section missing in west.yml
Fixes: #218

Using empty string instead of None as None results in error when
instantiating Manifest project as special project.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-02-28 09:54:14 +01:00
Torsten Rasmussen 2f68481485 init: Init will allow cloning a project when ZEPHYR_BASE is set.
Fixes: #212

If ZEPHYR_BASE was set in environment, `west init` fails.
This commit ensures `west init` can still run, as long as it is
invoked outside of a west managed project tree.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-02-25 12:53:58 +01:00
Carles Cufi b9e8b46f47 project: Rename --no-update to --exclude-west
Since excluding west from an update procedure is limited to a single
command now (west update), clarify that in the code and use a more
explicit flag name.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-02-21 15:40:55 +01:00
Marti Bolivar 90f27c1bcc main.py: trivial comment fix
Delete some # characters left over from an improperly reflowed paragraph.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-21 12:20:05 +01:00
Carles Cufi f8ad2d4fb9 scripts: Update bash completion to match current set
Update the list of commands and their flags so that the bash completion
is actually useful.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-02-21 10:27:23 +01:00