Skip to content

Project Layout Advice #8633

@npmccallum

Description

@npmccallum

We currently have a situation we don't know how to solve using cargo and we could use some advice. I'm posting here because I suspect there isn't a good answer and we'd like to patch cargo to make things work once we have an agreed upon solution.

We have two binaries: foo and bar. They are built for specific hardware and are not portable. The foo binary is built for the platform default (i.e. x86_64-unknown-linux-gnu) but the bar binary is built for x86_64-unknown-linux-musl and is no_std. Then the bar binary is embedded into the foo binary via include_bytes!().

The interface between these two binaries is private. So we don't want to package them as separate published crates. They should always live in the same repo and be published together.

Currently, bar is a subdirectory in the foo crate and we build it by manually shelling out to cargo during build.rs. With a little hackery, this seems to work fine. Our major problem is that we can't seem to publish this configuration. If we attempt to include = ["bar"] in the foo crate, it is ignored because it contains a Cargo.toml.

So we're basically looking for a solution:

  • foo depends on the bar binary, which is compiled for a different target.
  • foo and bar have their own, separate dependency trees.
  • foo and bar should always be distributed in the same package.
  • How can we publish this to crates.io?

cc @haraldh

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindA-cross-compilingArea: using --target flag for other platformsS-triageStatus: This issue is waiting on initial triage.Z-bindepsNightly: binary artifact dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions