1.. _module-pw_watch: 2 3.. rst-class:: with-subtitle 4 5======== 6pw_watch 7======== 8.. pigweed-module:: 9 :name: pw_watch 10 11 * **Automatically trigger build actions when source files change** 12 13---------- 14Background 15---------- 16In the web development space, file system watchers like `nodemon 17<https://www.npmjs.com/package/nodemon>`_ and `watchman 18<https://facebook.github.io/watchman/>`_ are prevalent. These watchers trigger 19actions when files change (such as reloading a web server), making development 20much faster. In the embedded space, file system watchers are less prevalent but 21no less useful! 22 23.. _module-pw_watch-design: 24 25------------ 26Our solution 27------------ 28``pw_watch`` is similar to file system watchers found in web development 29tooling but is focused around embedded development use cases. After changing 30source code, ``pw_watch`` can instantly compile, flash, and run tests. 31 32.. figure:: https://storage.googleapis.com/pigweed-media/pw_watch_test_demo2.gif 33 :width: 1420 34 :alt: ``pw watch`` running in fullscreen mode and displaying errors 35 36 ``pw watch`` running in fullscreen mode and displaying errors. 37 38Combined with the GN-based build which expresses the full dependency tree, 39only the exact tests affected by source changes are run. 40 41The demo below shows ``pw_watch`` building for a STMicroelectronics 42STM32F429I-DISC1 development board, flashing the board with the affected test, 43and verifying the test runs as expected. Once this is set up, you can attach 44multiple devices to run tests in a distributed manner to reduce the time it 45takes to run tests. 46 47.. figure:: https://storage.googleapis.com/pigweed-media/pw_watch_on_device_demo.gif 48 :width: 800 49 :alt: pw_watch running on-device tests 50 51.. _module-pw_watch-get-started: 52 53----------- 54Get started 55----------- 56.. code-block:: bash 57 58 cd ~/pigweed 59 source activate.sh 60 pw watch 61 62The simplest way to get started with ``pw_watch`` is to launch it from a shell 63using the Pigweed environment as ``pw watch``. By default, ``pw_watch`` watches 64for repository changes and triggers the default Ninja build target at ``//out``. 65To override this behavior, provide the ``-C`` argument to ``pw watch``. 66 67See :ref:`module-pw_watch-guide` for more examples and 68:ref:`module-pw_watch-cli` for detailed CLI usage information. 69 70.. toctree:: 71 :hidden: 72 :maxdepth: 1 73 74 guide 75 cli 76