axodotdev / cargo-dist

📦 shippable application packaging
https://axodotdev.github.io/cargo-dist/
Apache License 2.0
1.47k stars 66 forks source link

do not apply workspace optimisation when a single package is built #1118

Closed arlyon closed 3 months ago

arlyon commented 3 months ago

Closes https://github.com/axodotdev/cargo-dist/issues/1117

This PR adds two commits:

I left the case where there are 0 binaries as-is, since I am not sure whether the list of binaries is guaranteed to be nonempty. If this is the case, I would add a third match: [] => unreachable!()

This change resolves the above issue, where cargo-dist does not work in workspaces with unused libraries that cannot build on a given platform.

arlyon commented 3 months ago

Also (and for #1119) please let me know what I need to do regarding docs.

arlyon commented 3 months ago

I managed to run a build with the two PRs here if you'd like to test them https://github.com/arlyon/cargo-dist/releases/tag/v0.16.7.

Gankra commented 3 months ago

Does https://github.com/axodotdev/cargo-dist/issues/1117#issuecomment-2158442761 make this unnecessary for you? (The linked docs go into detail about why we in fact want to default workspaces even when shipping a single package, although it's definitely not a clear cut decision).

arlyon commented 3 months ago

Ah yeah. Apologies, I pored through the docs for some feature like this but clearly not well enough. Kinda funny that the relevant code was immediately above where I inserted the feature ... sometimes you gotta just go for a walk 😂

I think the behaviour of defaulting to a precise build by default when building a single binary is helpful but that is down to opinion. Thanks!