blob: 0cb8de152a74ae597e43fbb0eca6908b488929e1 [file] [log] [blame]
.. default-domain:: python
.. highlight:: sh
.. _chapter-watch:
--------
pw_watch
--------
``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.
.. image:: doc_resources/pw_watch_on_device_demo.gif
.. note::
``pw_watch`` currently only works with Pigweed's GN build.
Module Usage
============
The simplest way to get started with ``pw_watch`` is to launch it from a shell
using the Pigweed environment.
.. code:: sh
$ 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:
.. code:: sh
$ 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.
Unit Test Integration
=====================
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>`.