-
Notifications
You must be signed in to change notification settings - Fork 6
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
imageproc support: include feature/dependency for a the sic_image_crate package #395
Comments
status: works for https://github.com/foresterre/workspace-features-experiment, but not sic ... (?) |
It works, but only for a crate one level deep from the crate where the action is invoked (i.e. the crate where the feature is set must directly depend on the crate where a cargo command is invoked). It seems that See 2360a22 |
Additional workspace support is being discussed in a new RFC (rust-lang/rfcs#2906), currently in its final comment period, which may also (partially?) solve the above. I'm not sure whether it will actually solve the full problem as we need a dependency on See also rust-lang/rfcs#2906 (comment) |
✅ Cargo supports transitive conditional features just one level deep (See workspace-features-experiment, #395 (comment) and #410)
I would like to add
imageproc
operations to sic. For this to happen we need to letsic_image_engine
be dependent onimageproc
.imageproc
however pulls in a lot of code, so for now I would like to be able to build with and without imageproc support. Thus, I wanted to add a feature tosic_image_engine
:imageproc-ops = ["imageproc"] and under dependencies
imageproc = { version = "...", optional = true }`.Now, if I can't build sic from the root workspace;
Attempts
Branch: https://github.com/foresterre/sic/tree/experiment/gated-imageproc-feature - (perm link)
(A) Attempt: define feature from workspace root directly
cargo run --features imageproc-ops -- -i .\resources\1x1_a.png -o target/o.jpg
error: Package
sic v0.11.0 (\ws\sic)
does not have these features:imageproc-ops
if the root crate also defines the above feature in its manifest, it will only be enabled for the root crate (which sounds logical to me), not the
sic_image_engine
package.cargo build --workspace --features 'imageproc-ops'
; without imageproc-ops feature in the root results in the same "missing feature" error (A,1); with the empty feature it results in (A,2)cargo +nightly build --features 'sic_image_ops/imageproc-ops' -Z package-features
error: none of the selected packages contains these features: sic_image_ops/imageproc-ops
(B) Attempt: build with multiple packages
cargo +nightly run --bin sic -p sic -p sic_cli -p sic_cli_ops -p sic_core -p sic_io -p sic_parser -p sic_testing -p sic_image_engine --features imageproc-ops -Z package-features -- -i .\resources\1x1_a.png -o target/o.jpg
error: The argument '--package ' was provided more than once, but cannot be used multiple times
happens both with this nightly flag and without (it was a trial and error attempt)
(C) Attempt: add feature to every depending package in package manifest
i.e.
src: https://github.com/foresterre/sic/blob/experiment/gated-imageproc-feature/components/sic_cli/Cargo.imageproc-ops.toml
This works, but is very inconvenient, as we'll need to change the manifests of several packages for every custom build where we would like to include the imageproc features ...
Workarounds
Second custom manifest
sic_cli
calledCargo.imageproc-ops.toml
, and replace the Cargo.toml with this version temporarily when building with the imageproc feature:create script or cargo-ws(e) [cargo workspace-enhancer <opts...>] if we need to do this a lot
Open Questions?
Related
Similarly,
sic_parser
andsic_cli_ops
should add the feature like so:imageproc-ops = []
The text was updated successfully, but these errors were encountered: