How can I build multiple binaries with Cargo?

后端 未结 3 712
离开以前
离开以前 2020-12-04 08:36

I\'d like to make a project with a daemon and a client, connecting through a unix socket.

A client and a daemon

3条回答
  •  猫巷女王i
    2020-12-04 09:19

    Another way is to use the workspace feature. This will provide more flexibility due to the fact that we can have more than one library. Example project structure:

    .
    ├── Cargo.toml
    ├── cli
    │   ├── Cargo.toml
    │   └── src
    │       └── main.rs
    ├── core
    │   ├── Cargo.toml
    │   └── src
    │       └── lib.rs
    ├── daemon
    │   ├── Cargo.toml
    │   └── src
    │       └── main.rs
    ├── gui
    │   ├── Cargo.toml
    │   └── src
    │       └── main.rs
    └── rpc
        ├── Cargo.toml
        └── src
            └── lib.rs
    

    Contents of the root Cargo.toml:

    [workspace]
    members = ["cli", "core", "daemon", "gui", "rpc"]
    

提交回复
热议问题