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