Commit Graph

847 Commits

Author SHA1 Message Date
Torsten Rasmussen 1390b99b94 west: topdir marker removed
Topdir marker '.west_topdir' removed.
West now determines the topdir by looking for the '.west' folder.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-15 13:31:18 -07:00
Torsten Rasmussen d287e35f3c project: init command added to west main
Added west init command to west.main to support post-process of
west init.

Added --use-cache to limit network use when cloning manifest project
repository

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-15 13:31:18 -07:00
Torsten Rasmussen 0514c4a781 manifest: Manifest file inside a project repository
- self key introduced in manifest file to support local path location
  for the repository containing the manifest file
- Removed manifest repository under west folder

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-15 13:31:18 -07:00
Torsten Rasmussen 045b591e17 structure: Renamed west toplevel folder to .west
As part of moving manifest file inside a project repository, the west
folder is renamed to .west as it will no longer contain a manifest
repository (and potentially also not west repo in future)

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-15 13:31:18 -07:00
Torsten Rasmussen 572d412d94 manifest: Renamed manifest file from default.yml to west.yml
As part of moving manifest file inside a project reposity, the manifest
file is renamed from default.yml to west.yml

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-15 13:31:18 -07:00
Marti Bolivar f01059a2e5 config.py: add missing copyright and license
Trivial cleanup based on git blame.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-10 10:08:08 -07:00
Marti Bolivar 6ce01bd857 tests: call flake8 from tox
Add a flake8 configuration to the tox testing. This enforces a
consistent style. Clean up remaining issues around the codebase.

Disable a handful of flake8's complaints when the style seems popular
enough among the team members to ignore.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar 18060dd02a tests: use tox and overhaul project testing
To properly test the project commands, it would be best to have a
fresh west bootstrapper package created and installed on PATH, so it
could be used to run commands exactly as they'd happen if we package
and ship the working tree.

To make that easier, add a dependency on tox and use it for testing:

https://tox.readthedocs.io/en/latest/

From now on, we'll test west by running 'tox' from the repository
root.  This has several advantages over running pytest directly:

- "Just run tox": there are no longer any differences in test invocation
  between POSIX OSes and Windows.

- tox creates an sdist package of the current tree using our setup.py
  and installs it into a new virtual environment, then runs tests
  there.  This removes interference from other packages installed on
  the host (like released bootstrappers that are also installed)

- we get to run multiple shell commands in order, should that ever be needed,
  in our test procedures in a way that won't affect users

With that done, we can re-work the multirepo command testing to invoke
the bootstrapper in the virtual environment, adding various tests and
filling in longstanding testing gaps by adding increased checking of
the results (currently, much of the testing just checks whether
commands do or do not error out, which isn't enough).

These changes were made with a view towards the upcoming changes which
are planned before releasing west "into the wild": the test case code
should be mostly the same before and after the changes, so this serves
as a good baseline against regressions introduced by those upcoming
changes.

Signed-off-by: Marti Bolivar <marti@foundries.io>

[wip] debugging shippable results

Signed-off-by: Marti Bolivar <marti@foundries.io>

[wip] just test one py3

shutil.which west is picking up a 3.4 version in the 3.6 test, oddly

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar f9c8e81073 bootstrap: add discovered west early in sys.path
This prevents random wests in developer PYTHONPATHs from coming
first. It's being done for convenience during development and testing.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar 94708ea073 west.main: minor fix to in_multirepo_install argument
Use a real directory instead of a file. This makes debugging easier.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar db744f5fa6 Explicitly include bootstrap schema in west._bootstrap
Otherwise we can't count on it being present in the package.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar b3651495e3 bootstrap: don't check that src is a URL in clone()
Git clone can take a raw file system path instead of a URL when
cloning a repository that is already available locally somewhere else.

When this happens, git tries to use hard links to create the files in
the destination, which is more efficient, so the limitation to URLs is
not good. Remove it.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar dbe6ebbc9b project.py: use ordinary format string keys for shorthands
The _expand_shorthands() helper function allows constructing strings
based on attributes of a project. However, it uses a custom format
string DSL-like syntax instead of picking one of the two which already
exist in Python.

Convert this to use the standard .format() string formatter.

This is mostly a mechanical change. The only thing worth calling out
is that when using .format() to construct something that will get
passed to _expand_shorthands(), we need to double the brackets for the
shorthand keys (so "{{" / "}}" instead of "{" / "}") so that the first
.format interprets them as ordinary brackets, which the call to
.format() in _expand_shorthands() then sees as an access to a format
value by name.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar f0c8b5e55a project.py: flake8 cleanups
Unused import removals, whitespace changes, and line length tweaks.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar 12ede560f0 manifest: miscellaneous improvements
Miscellaneous fixes and improvements to the manifest parsing code.

- remove unused and undocumented 'url' parameter to Project
  constructor: this only matters for SpecialProject instances

- add and fix pydoc parameter documentation for a few classes

- following manifest schema changes, rename the Remote 'url' parameter
  to 'url_base'

- NotImplemented is not an exception; it should be returned, not
  raised

- pass project paths through os.path.normpath() when initializing
  Project instances

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar e55758419f Make test_manifest.py and manifest.py flake8 clean
Just whitespace changes.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar a3fce4c257 tests: delete incorrect comment in invalid manifest file
This is not the default manifest for west ;).

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-09 11:21:05 -07:00
Marti Bolivar ad6a22cf4d main.py: fix monorepo use cases
We need to do another copy of west into Zephyr to get some runner
fixes and features, but some assumptions have crept back into the code
that we're in a multirepo install.

Fix these so we can use flash and debug commands in a monorepo Zephyr
installation.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-03 20:15:07 +01:00
Carles Cufi d00fb2bb21 runners: jlink: Default to correct JLink executable
On Microsoft Windows, the default name of the JLink executable is
"JLink.exe", while on *NIX it is instead "JLinkExe". Detect and
correctly set the default name based on the platform.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 10:13:05 -07:00
Torsten Rasmussen 9874122997 project: Fixed issue with fetching revision SHA
Fixes: #139

Fixes the issue of fetching SHAs when specified in manifest file.
It is checked if a revision is a SHA, in which case the fetch is
performed on the url and afterwards the manifest-rev reference is
updated to the SHA.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2018-12-19 14:19:56 -07:00
Marti Bolivar 8b4a08d6ac west: 0.4.1
Fixing the behavior of 'west debug' requires users to update their
bootstrap installation. Bump the minor release number to make that
possible.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-18 10:19:37 +01:00
Marti Bolivar 124c64d3d7 bootstrap: fix 'west debug' regression
Commit f8bd521 ("Add self-update for West and the manifest") switched
from importing the west module and invoking main directly from the
same process as the bootstrapper to invoking it as a subprocess.
This breaks 'west debug'.

Runners which run GDB directly to debug a target need to be able to
ignore SIGINT while GDB is running, as Ctrl-C halts the target and
returns control to the (gdb) prompt instead of terminating the program
as usual.

Because of that, the runner code must be running in the same process
as the bootstrapper, or the parent (bootstrap) process, which doesn't
ignore the signal, means the control C at the shell gets delivered to
a process which uses the default handler to exit the program.

Fix it by going back to the mechanism the bootstrapper originally
used to delegate a command to the installed west.

Fixes: #135
Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-18 10:19:37 +01:00
Marti Bolivar c852a5d498 bootstrap: flake8 and typo cleanups
Fix a typo and handle some flake8 code style issues.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-18 10:19:37 +01:00
Marti Bolivar 2cff25e88c west: main: fix incorrect use of sys.argv
The argument array to main is in the argv argument, *not* sys.argv.
Fix this.

(Using sys.argv directly prevents the main function from getting its
arguments from an arbitrary value specified by the caller.)

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-18 10:19:37 +01:00
Tavish Naruka b1959be7d3 runners: blackmagicprobe: fix refrence to kernel_*
Renames kernel_elf to elf_file, and handles cases where
it is not specified.

Signed-off-by: Tavish Naruka <tavishnaruka@gmail.com>
2018-12-17 17:48:58 -07:00
Tavish Naruka 487a03cfa1 runners: Black Magic Probe runner
Based on #6829 by @diytronic, updated and added
debug and attach commands.

Signed-off-by: Tavish Naruka <tavishnaruka@gmail.com>
2018-12-10 12:01:25 -08:00
Marti Bolivar 1844cbe92d commands: build: improve command line help
It's not clear from the help how the source and build directories are
determined. Fix that and sentence-case the other help text while we're
here.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-29 10:38:27 -07:00
Marti Bolivar 11c79e70ce West v0.4.0
Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-28 10:16:25 -07:00
Carles Cufi ebc17b9623 West 0.4.0rc1
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-28 11:20:52 +01:00
Torsten Rasmussen 7d5251ae32 git: Updating use of show-ref to work with older git versions
Fixes: #119

This commit changes the way show-ref is executed in order to determine
whether HEAD is pointing to a valid reference or if the repository is
in initialized stated.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2018-11-28 09:40:57 +01:00
Torsten Rasmussen 64ecfa82c2 manifest: url for remotes changed to url-base
This commit uses url-base instead of url to avoid confusion for users
as url in west section of manifest is full url, where url-base in manifest
section will be concatenated with project name to for clone url.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Torsten Rasmussen 1c56d88aa4 manifest: Encode west section as a project
In order to simplify and add consistency to the parsing of the manifest
file, represent the west section and the special project it represents
by using a subclass of the standard Project class.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Carles Cufi a0bc48342e tests: Fix and add tests for west url/revision in manifest
After switching from command-line parameters to a special section in the
manifest file, rework the tests so that they verify the new scheme of
things and add a new invalid manifest that can be tested in order to
verify that the schema qualification is working correctly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Carles Cufi cb5f2108a8 projects: Retrieve west url and revision from manifest
Since the metadata associated with west itself (url and revision) is no
longer provided via command-line parameters but rather using a special
section in the manifest file, convert project.py to make use of the new
capabilities in the manifest parsing code and drop the metadata from the
configuration file, where it no longer belongs.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Carles Cufi f4c360c126 manifest: Support both west and manifest sections
Rework the manifest parsing in order to support both the manifest and
west sections that can now be present in the yaml file.
This enables the manifest to be parsed fully and include both the
project information from the manifest section and also the special
metadata associated with west itself.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Carles Cufi c4365915e1 bootstrap: Take west url and revision from manifest
In order to support encoding the required west URL and revision when
tagging a manifest for a release, move the metadata regarding west
itself (url and revision) from the command-line to the manifest.
This involves:

- Adding a new "west" section to the manifest that includes the metadata
- Removing the "-w" and "--wr" command-line options
- Parsing the "west" section of the manifest directly in the
bootstrapper

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-27 20:44:23 -07:00
Torsten Rasmussen 4e1cb804e3 git: split pull into fetch+merge
Older versions of git lack support for --rebase=false
Thus splitting pull into a fetch and merge is safer, as well as it
provides better help on which steps are failing.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2018-11-22 11:51:17 +01:00
Marti Bolivar cb7d4143e3 main: fix --zephyr-base help
This has gone stale.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-20 21:01:18 +01:00
Marti Bolivar ab4ffcc51d Be more helpful to newcomers.
The error output when the bootstrapper is called without arguments or
with -h is lacking. Try to improve it.

Tweak the output when called without arguments when an installation is
found as well, in the same spirit.

Finally, change the print_usage() to a print_help() when no command is
given, to get additional context.

Fixes: #108

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-20 21:01:18 +01:00
Ulf Magnusson 47b328a05e tests: project: Add tests for 'west update'
Create some dummy manifest, west, and project upstream repositories, and
a simple configuration file that points to them. Use this setup to test
--reset/update-manifest, --reset/update-west, and --reset-projects.

The --reset-* flags are used by 'west init' when reinitializing an
existing west installation. Also test that the correct --reset-* flags
are generated when calling the bootstrapper to reinitialize an
installation.

Some simple helper functions were added for creating repositories,
adding commits, and getting the subject of a repository's HEAD commit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-11-20 09:20:41 -07:00
Ulf Magnusson 75f21d968d tests: project: Clean up tests a bit
Simplify the projects tests to make them easier to understand and work
with:

 - py.path (https://py.readthedocs.io/en/latest/path.html) functions
   like mkdir() return the resulting path, so operations can be chained

 - py.path paths have a write() method. Use it to write the manifest.
   Get rid of the separate file.

 - Switch to the following directory layout, which is simpler and makes
   the manifest easier to locate:

     <tmpdir>/repos/{kconfiglib,net-tools}
     <tmpdir>/west/.west_marker
     <tmpdir>/manifest.yml

   <tmpdir> is used directly as the working directory.

 - Add some more comments

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-11-20 09:20:41 -07:00
Ulf Magnusson a5bc638bb0 commands: project: Allow changing configuration options with 'west init'
Support rerunning 'west init' in an already initialized West
installation to update configuration values in west/config.

Only arguments that are explicitly passed are changed. For example,
'west init --mr foo' will update the manifest revision to 'foo', leaving
all other settings unchanged. Passing no arguments when reinitializing
is a no-op, and prints an error.

The initial west/config creation is treated as an update that happens to
set all configuration values, to reuse some code.

Updating the manifest URL or revision via 'west init' automatically
resets the manifest to the new revision (after fetching it). This is
implemented with a new 'west update --reset-manifest' flag. Updating the
manifest also resets all (cloned) projects, via a new
'west update --reset-projects' flag.

Updating the west URL/revision resets the west repository, via a new
'west update --reset-west' flag.

All resetting is done with 'git reset --keep', which is a bit safer than
'git reset --hard', as it never discards uncommitted changes.

The reset behavior can be suppressed by passing --no-reset to
'west init'.

This commit also adds more comprehensive documentation for the behavior
of 'west init'.

Piggyback some small cleanup:

 - Rename WEST/MANIFEST_DEFAULT to WEST/MANIFEST_URL_DEFAULT. There's
   already WEST/MANIFEST_REV_DEFAULT.

 - Rename find_west_topdir() to west_topdir(). This is what the version
   in the main West code is called (would be nice to reuse things
   directly from there in the future).

   Also make west_topdir() implicitly default to the working directory.

Fixes: #77

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-11-20 09:20:41 -07:00
Marti Bolivar f3c10bb809 flash: fix a typo in the command description
Fixes: #112

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-20 09:06:55 -07:00
Marti Bolivar e9938c5f2f runners: jlink: debug log commander script contents
We intend that 'west -v flash' provides sufficient information for the
motivaed user to stop using west if they so choose. The use of a
temporary file in the jlink runner whose contents are deleted as west
exits prevents that. Print its contents so we can let people get back
to work without west.

Fixes: #113

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-20 09:06:55 -07:00
Sebastian Bøe 1e9f34fe1c commands: Be compatible with more Zephyr versions
Check for multiple versions of names to be compatible with more
versions of Zephyr.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-20 08:52:28 -07:00
Ulf Magnusson 35be4f3ba3 commands: project: Allow projects to be specified via their path
Make commands that accept project names also accept project paths. For
example, 'west branch fix-foo .' can be run inside the zephyr/
directory, instead of running 'west branch fix-foo zephyr'.

Paths are mapped to projects by checking if the realpath (canonicalized
absolute) of any project is a prefix of the realpath of the supplied
path. That method will map subdirectories of projects to the project as
well.

Switch to using realpath() to calculate project.abspath as well, which
streamlines things and gets rid of gotchas related to symbolic links.

Project names and paths can be mixed in the same command. If both a
project name and a path matches, the name takes precedence (this can
always be worked around with './foo').

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-11-20 15:57:54 +01:00
Sebastian Bøe c466a5617f cmake: west: Take the 'kernel' name out of the .bin/.hex/.elf file
Rename variables to make west more agnostic, and therefore potentially
more flexible, to what it is flashing.

This is a small step towards solving #7868 and other similair issues
in Zephyr. Essentially, sometimes, for instance when a bootloader is
used, or a dual-core platform is used, we need to flash multiple
images/application's, not just the 'kernel'.

To prepare 'west' for this future feature we make it agnostic to what
kind of hex/bin/elf file it is flashing by taking the 'kernel' name
out of the variables. This allows the hex file to contain not just the
kernel, but also a bootloader, or a second image.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-15 20:51:45 -07:00
Carles Cufi 2bf720b982 version: Set post-release version to 0.3.99
After releasing 0.3.0, set the .99 marker.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-13 18:18:23 +01:00
Marti Bolivar 1fc5f0b761 manifest: forbid naming projects "west" or "manifest"
Now that we can list west and the manifest, it's worth restricting the
project namespace to prevent overlap. Note that it's still okay to
name a remote "west" or "manifest".

Add testing to make sure this doesn't regress.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-08 16:33:27 +01:00
Marti Bolivar 6db352b005 commands: list: add --format, --all options
Add a -f / --format option that allows users to list projects exactly how
they want them.

Also add a -a / --all flag that does not ignore the west or manifest
repositories in the listing. This is by analogy with the ls command;
we are treating west and the manifest as if they were hidden.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-08 16:33:27 +01:00