.. default-domain:: python
pw_watch
is similar to file system watchers found in the web development
space. These watchers trigger a web server reload on source change, increasing
iteration. In the embedded space, file system watchers are less prevalent but no
less useful! The Pigweed watcher module makes it easy to instantly compile,
flash, and run tests upon save.
Note
pw_watch
currently only works with Pigweed's GN build.
The simplest way to get started with pw_watch
is to launch it from a shell
using the Pigweed environment.
$ pw watch
By default, pw_watch
will watch for repository changes and then trigger
Ninja builds sequentially for each subdirectory in ${PIGWEED_ROOT}/out
. To
override this behavior, follow pw watch
with paths to Ninja build
directories like so:
$ pw watch out/host out/disco
The --patterns
and --ignore_patterns
arguments can be used to include
and exclude certain file patterns that will trigger rebuilds.
Thanks to GN's understanding of the full dependency tree, only the tests
affected by a file change are run when pw_watch
triggers a build. By
default, host builds using pw_watch
will run unit tests. To run unit tests
on a device as part of pw_watch
, refer to your device's
:ref:`target documentation<chapter-targets>`.