axodotdev / axodotdev/cargo-dist
including cdylib deps in bundles
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 149
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 32
Description
This is a separate issue for https://github.com/axodotdev/cargo-dist/issues/193#issuecomment-1537732091
Might get some details wrong here, but my rough recollection is that libraries [can define cdylib outputs](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#library) (shared objects / DLLs). Historically these outputs were treated as final outputs of a build that nothing could depend on (just like binaries). However [bindeps was introduced](https://rust-lang.github.io/rfcs/3028-cargo-binary-dependencies.html) and lets crates depend on those kinds of outputs (it's still unstable [but cargo-dist can theoretically handle that](https://github.com/axodotdev/cargo-dist/issues/347)... but only at build-time. This results in this wonderfully horrifying section of the RFC (hey at least it's honest about its limitations):
> Cargo also allows depending on cdylib or staticlib artifacts. For example, you can embed a dynamic library in your binary:
>
> ```
> [dependencies]
> mypreload = { version = "1.2.3", artifact = "cdylib" }
> ```
>
> ```
> // main.rs
> const MY_PRELOAD_LIB: &[u8] = include_bytes!(env!("CARGO_CDYLIB_FILE_MYPRELOAD"));
> ```
>
> Note that cargo only supplies these dependencies when building your crate. If your program or library requires artifacts at runtime, you will still need to handle that yourself by some other means. Runtime requirements for installed crates are out of scope for this change.
cargo-dist should have a way to say "hey this bindep is a runtime one" so we can copy it into you executable-zips. I'm not 100% sure what that should look like, as someone who doesn't use cdylibs (much more common for gui apps / games). Examples would be useful.
Contributor guide
Research direction
Start by reviewing the linked cargo-dist issues 193 and 347, the Cargo bindeps RFC, and the cdylib target documentation. Define how a runtime bindep should be declared and how cargo-dist should include it in executable ZIPs; useful cdylib examples are still needed before implementation can be considered complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, release
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100