Search code examples
rust-cargo

Order of workspaces in cargo-make


I am struggling with order of workspace builds with cargo-make tool.

My initial use-case: I have 2 binary workspaces and one logically depends on the other (say, I need to call include_bytes!(member1) in member2).

Reading through docs [1] I see that

The order of the members is defined by the member attribute in the workspace Cargo.toml.

Now let me show MRE:

.
├── Cargo.lock
├── Cargo.toml
├── member1
│   ├── Cargo.toml
│   └── src
│       └── main.rs
└── member2
    ├── Cargo.toml
    └── src
        └── main.rs

Cargo.toml

[workspace]
members = ["member2", "member1"]
resolver = "2"

And then cargo make

$ cargo make | rg member
[cargo-make][1] INFO - Project: member1
[cargo-make][1] INFO - Project: member2

So seems like cargo make internally sorts workspace members list and executes sub-command on work-spaces in alpha order. Since cargo does not support dependencies on binaries, is there any way to force ordering?

I know, that I can write my own Makefile/Justfile/etc, but I thought that cargo-make should replace them.

[1] https://sagiegurari.github.io/cargo-make/#workspace-support


Solution

  • This will be resolved in https://github.com/sagiegurari/cargo-make/pull/897 which removes the sorting and keeps the original order of cargo dependencies.