blob: b5e78cc7ce88c50453e45d6762cbdef63b9f10b2 [file] [log] [blame]
Armando Montanezbcc194b2020-03-10 10:23:18 -07001.. default-domain:: python
2
3.. highlight:: sh
4
5.. _chapter-watch:
6
7--------
8pw_watch
9--------
10
Armando Montanez0054a9b2020-03-13 13:06:24 -070011``pw_watch`` is similar to file system watchers found in the web development
12space. These watchers trigger a web server reload on source change, increasing
Armando Montanezbcc194b2020-03-10 10:23:18 -070013iteration. In the embedded space, file system watchers are less prevalent but no
14less useful! The Pigweed watcher module makes it easy to instantly compile,
15flash, and run tests upon save.
16
17.. image:: doc_resources/pw_watch_on_device_demo.gif
18
19.. note::
20
Armando Montanez0054a9b2020-03-13 13:06:24 -070021 ``pw_watch`` currently only works with Pigweed's GN build.
Armando Montanezbcc194b2020-03-10 10:23:18 -070022
23Module Usage
24============
25
Armando Montanez0054a9b2020-03-13 13:06:24 -070026The simplest way to get started with ``pw_watch`` is to launch it from a shell
27using the Pigweed environment.
Armando Montanezbcc194b2020-03-10 10:23:18 -070028
29
30.. code:: sh
31
32 $ pw watch
33
Armando Montanez0054a9b2020-03-13 13:06:24 -070034By default, ``pw_watch`` will watch for repository changes and then trigger
35Ninja builds sequentially for each subdirectory in ``${PIGWEED_ROOT}/out``. To
Armando Montanezbcc194b2020-03-10 10:23:18 -070036override this behavior, follow ``pw watch`` with paths to Ninja build
37directories like so:
38
39.. code:: sh
40
Armando Montanez7366d5a2020-06-17 15:04:43 -070041 $ pw watch out/host
42
43 # Alternatively,
44 $ pw watch --build-directory out/host --build-directory out/disco
Armando Montanezbcc194b2020-03-10 10:23:18 -070045
46The ``--patterns`` and ``--ignore_patterns`` arguments can be used to include
47and exclude certain file patterns that will trigger rebuilds.
48
Chenghanc4c46b62020-05-08 17:43:23 -040049The ``--exclude_list`` argument can be used to exclude directories from
50being watched by your system. This can decrease the inotify number in Linux
51system.
52
Armando Montanezbcc194b2020-03-10 10:23:18 -070053Unit Test Integration
54=====================
55
56Thanks to GN's understanding of the full dependency tree, only the tests
Armando Montanez0054a9b2020-03-13 13:06:24 -070057affected by a file change are run when ``pw_watch`` triggers a build. By
58default, host builds using ``pw_watch`` will run unit tests. To run unit tests
59on a device as part of ``pw_watch``, refer to your device's
Armando Montanezbcc194b2020-03-10 10:23:18 -070060:ref:`target documentation<chapter-targets>`.