Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open a communication channel between the build system and application #20604

Open
andrewrk opened this issue Jul 13, 2024 · 1 comment
Open
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

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:

  • The application could learn when has been rebuilt, and restart gracefully.
  • The application could learn when a hot code swap (hot code swapping #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.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Jul 13, 2024
@andrewrk andrewrk added this to the 0.14.0 milestone Jul 13, 2024
@mnemnion
Copy link

Will the use of a protocol-specific pipe open the door for a fix for #15091/#18111 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

2 participants