I have a project (this one) which produces two binaries, a client and server. They currently build from one Cargo.toml and share some code in the form of a lib.rs.
I would like to publish both the client and server to crates.io so that a single cargo install my-thing will install both binaries.
Do I just add a
[[bin]]
name = "my-cool-binary"
path = "src/my-cool-binary.rs"
You don't need to make any changes; just publish your project as-is. cargo install always installs all binaries from a package. (Well, you might want to change the binary names from client and server to something less generic. )
If you want to test the cargo install behavior before publishing, you can use cargo install --path . in a local clone of the project, or cargo install --git https://github.com/mark-i-m/jobserver.
Thanks for the response! That's much simpler than I expected
One followup: currently, the binaries are named client.rs and server.rs. Would I add the [[bin]] sections if I want them to be named something else? Or would it just be easier to just rename the files?
Both approaches are valid. Personally, I like to use the source filenames to control the binary names, just so I don't have to remember what files map to which names.