#naming conventions for projects with multiple binaries

1 messages · Page 1 of 1 (latest)

velvet nexus
#

hey y'all, more of a style question than a technical question. Normally if I was writing a program in zig, I would call the root file main.zig and move on with my life. However, I'm currently working on a project which will build 2 different binaries, a daemon and a control program, and then do IPC between them.

Without getting too far into the details of the project, is there some kind of accepted convention for naming the root source files for 2 differeng binaries? would daemon.zig and control.zig be reasonable names for these?

low sonnet
#

My gut reaction is that your user program is main, and the other daemon or service. Another model is client/server. But choose things that make sense for your domain. It's really no different than naming anything your programs.

smoky pelican
#

Perhaps unhelpful, but I can share how I've set up mine, which works well enough. I have two binaries (one main app and one privileged helper tool) - this is an Apple/MacOS thing. They communicate with each other using an IPC protocol.

Root directory looks like this. build.zig refers to ./src which contains main app, main.zig, all of the files and directories associated with the main app. ./macos-helper contains its own src/ and all related resources.

I'm sure you can make a much smarter build.zig flow by having it build a second binary, but I just have a simple shell script ./bundle-app.sh which enters each directory, does a zig build release for a specific platform, and then copies everything over into a .app bundle and codesigns it for MacOS. Works well enough, tbh. And all code remains properly segregated but in the same repository.