I'm authoring a set of build tools / yet another cargo subcommand for creating packages.
Prior art includes cargo-apk
, cargo-deb
, cargo-web
, wasm-pack
, etc.
I'd like to generate temporary Cargo.toml packages as well, which has less prior art.
Would generate:
main.rs
specifying#![windows_subsystem=...]
and a stub mainbuild.rs
invokingwinres
,natvis-pdbs
, etc.Cargo.toml
with[dev-dependencies]
Would generate:
Cargo.toml
withcrate-type = ["cdylib"]
lib.rs
with multiple#![no_mangle]
entry points for Java to call into
Cargo.lock
. If these generated Cargo.toml files add dependencies, things get hairy real fast.
This leads to two lockfiles, which is super awkward - will likely lead to building the same crates twice with slightly different dependencies. Also, rustc source paths are workspace relative and thus awkward with the generated workspace.
/Cargo.toml
/Cargo.lock
/.generated/Cargo.toml
/.generated/Cargo.lock
This leads to poor intellisense since it doesn't know anything about my wrapping tool, also poor paths for errors:
/Wrapper.toml
/.generated/Cargo.toml
/.generated/Cargo.lock
/Wrapper.toml
/Cargo.toml
- this could be added to.gitignore
as well?
Could be checked for an autogenerated# DO NOT EDIT THIS FILE
intro comment?/Cargo.lock
What happens on Ctrl+C? Explosions?
/Cargo.toml
/Cargo.lock
Build process would be:
- copy
/Cargo.toml
->/Cargo.toml.orig
- edit
/Cargo.toml
- ...build commands...
- copy
/Cargo.toml.orig
->/Cargo.toml
Would use e.g. cargo::core::WorkspaceRootConfig to add the original workspace packages, and the generated packages, to an in-memory workspace.
cargo update
might still remove stuff fromCargo.lock
cargo
is an expensive dependency
- Makes using build.rs-friendly crates like
winres
andnatvis-pdbs
which output directly to stdout annoying (embed them into the subcommand, fork/self-invoke and capture output, then pase & pipe that into rustc?) - Synthesizing the same flags
cargo
would use is difficult/annoying/brittle