Pigweed AI summary: The pw_watch module is an embedded development file system watcher that automatically triggers build actions when source files change. It is similar to file system watchers found in web development tooling but is focused around embedded development use cases. The module can instantly compile, flash, and run tests after changing source code. It can also run tests in a distributed manner to reduce the time it takes to run tests. The simplest way to get started with pw_watch is to launch it from a shell using the Pigweed environment as

Stable

  • Automatically trigger build actions when source files change

Background#

Pigweed AI summary: The use of file system watchers like nodemon and watchman is common in web development, as they trigger actions when files change, making development faster. However, these watchers are also useful in the embedded space, despite being less prevalent.

In the web development space, file system watchers like nodemon and watchman are prevalent. These watchers trigger actions when files change (such as reloading a web server), making development much faster. In the embedded space, file system watchers are less prevalent but no less useful!

Our solution#

Pigweed AI summary: The solution presented is called "pw_watch" and is similar to file system watchers used in web development, but is focused on embedded development. After changing source code, pw_watch can instantly compile, flash, and run tests. Combined with the GN-based build, only the exact tests affected by source changes are run. The demo shows pw_watch building for a STMicroelectronics development board, flashing the board with the affected test, and verifying the test runs as expected. Multiple devices can be attached to run

pw_watch is similar to file system watchers found in web development tooling but is focused around embedded development use cases. After changing source code, pw_watch can instantly compile, flash, and run tests.

``pw watch`` running in fullscreen mode and displaying errors

pw watch running in fullscreen mode and displaying errors.#

Combined with the GN-based build which expresses the full dependency tree, only the exact tests affected by source changes are run.

The demo below shows pw_watch building for a STMicroelectronics STM32F429I-DISC1 development board, flashing the board with the affected test, and verifying the test runs as expected. Once this is set up, you can attach multiple devices to run tests in a distributed manner to reduce the time it takes to run tests.

pw_watch running on-device tests

Get started#

Pigweed AI summary: The article explains how to use the Pigweed environment to launch pw_watch from a shell. By default, pw_watch watches for repository changes and triggers the default Ninja build target at //out. The article also provides a link to a pw_watch how-to guide for more examples and a pw_watch CLI reference for detailed CLI usage information.

cd ~/pigweed
source activate.sh
pw watch

The simplest way to get started with pw_watch is to launch it from a shell using the Pigweed environment as pw watch. By default, pw_watch watches for repository changes and triggers the default Ninja build target at //out. To override this behavior, provide the -C argument to pw watch.

See pw_watch how-to guide for more examples and pw_watch CLI reference for detailed CLI usage information.