Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkDummySrc: rework to only stub bins if they actually exist #752

Merged
merged 1 commit into from
Dec 1, 2024
Merged

Conversation

ipetkov
Copy link
Owner

@ipetkov ipetkov commented Dec 1, 2024

Motivation

The previous implementation would always unconditionally introduce a crane-dummy-* binary target as a means of ensuring that any workspaces which use the (unstable) bindeps feature will have their binaries built. Unfortunately this meant causing headaches for certain projects (e.g. embedded projects which require additional linking handling which would naturally be missing for the dummy target coming out of nowhere).

Instead, now we emulate cargo's autobin detection logic and only dummify binary targets if they exist (turning this logic off via package.autobin = false in Cargo.toml is fully supported, as is explicitly defining [[bin]] targets there as well) meaning fewer surprises for anyone bitten by this!

It's also worth noting that either removing an existing or defining a new binary (either by defining a [[bin]] entry in Cargo.toml or by adding a new file in src/bin/new.rs or src/bin/new/main.rs) will cause the deps-only derivation to be rebuilt once more. In my experience this is usually pretty rare during the lifecycle of a project that an extra rebuild here or there is not a showstopper, but please open an issue if this becomes a nuisance. For now I've chosen not to allow an opt-out of this behavior for the sake of simplicity of the change, but this can be revisited in the future.

It's also worth noting that this auto-detection is not implemented for bench, example, and test targets since those are definitely more likely to get added and result in unnecessary rebuilds and it's not clear to me (at this time) that this functionality would be needed anywhere.

Fixes #444

Fixes #268

Checklist

  • added tests to verify new behavior
  • added an example template or updated an existing one
  • updated docs/API.md (or general documentation) with changes
  • updated CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant