When the build system spawns a child process via a Run step, unless opted out, give it an environment variable that communicates a file descriptor which is a pipe. For example, ZIG_BUILD=4. This file descriptor is an open pipe so that the application can speak the zig build system protocol, which will be available in the Zig standard library for convenience.
This will enable the following use cases:
The application could learn when has been rebuilt, and restart gracefully.
The application could learn when a hot code swap (#68) is available, and then request it at an opportune moment, such as between game frames or web server requests.
The application could be notified that certain assets have been freshly built, and reload them. For example, perhaps the application is a web server, and the static html file asset changes. It could send a message to connected clients telling them to reload the page. This makes --watch extend into arbitrary environments, with a little bit of cooperation from application developers.
Of course, applications are free to simply ignore this open pipe as well, just like they can ignore stdin, stdout, or stderr.
Extracted from #20580.
When the build system spawns a child process via a
Run
step, unless opted out, give it an environment variable that communicates a file descriptor which is a pipe. For example,ZIG_BUILD=4
. This file descriptor is an open pipe so that the application can speak the zig build system protocol, which will be available in the Zig standard library for convenience.This will enable the following use cases:
--watch
extend into arbitrary environments, with a little bit of cooperation from application developers.Of course, applications are free to simply ignore this open pipe as well, just like they can ignore stdin, stdout, or stderr.