Closed martinling closed 1 month ago
Note: Cargo doesn't currently support platform-specific binary targets. So we have to build packetry-cli
on the other operating systems too, even though it's a no-op wrapper.
I think this is the right choice though, because it means that scripts and documentation can be written to always use packetry-cli
for command line operations, and everything should then work unmodified on all systems.
This is necessary on Windows, where we can't have the same binary serve as both a GUI and a console program, due to the constraints of the PE binary format. See e.g. this post by Raymond Chen, and this StackOverflow discussion.
Instead, we add a new
packetry-cli
console binary which simply acts as a wrapper around the main GUI binary.The wrapper sets the
PACKETRY_ATTACH_CONSOLE
environment variable, which tells the main process to attach to the wrapping parent's console. The wrapper waits for the child to complete, and mirrors its exit code.Thanks to @pointy56 for investigating and prototyping this solution.