Build Script: Ensure Binary A is Built before Binary B

I have a cargo workspace with multiple crates, and binary application in crate app needs to call binary enclave in crate secure at runtime.

Is there a way within a cargo build script (build.rs) to tell cargo to build/rebuild binary enclave as a prerequisite to building binary application?

If not possible, I know there are other ways to go about this, but I was wondering if there is such an option within build scripts.

If the requirement is only "both application and enclave must exist at runtime," then you don't need to build them in any particular order. You aren't running them at build time, and binary-to-binary dependencies generally don't involve the linker or any other machinery where dependency resolution matters.

If you need enclave (from secure) available to app at build time (for example because you also call it from app's build.rs), then use a build dependency to specify that app depends on secure at build time.

2 Likes