shiplift icon indicating copy to clipboard operation
shiplift copied to clipboard

Compile crate based on target platform instead of exposing features?

Open thomaseizinger opened this issue 6 years ago • 0 comments

We are using shiplift in a crate that we ship on three major platforms: windows, macos and linux.

Unfortunately, it is not possible to use different features of the same crate depending on the platform with cargo: https://github.com/rust-lang/cargo/issues/2524

Because of that and the way the crate is currently laid out makes it a bit painful to compile because we have to define two non-default features windows and unix and pass the desired feature upon compilation.

I saw that there has already been an attempt to make using this crate on Windows easier: https://github.com/softprops/shiplift/pull/197

Looking at the dependencies and with https://github.com/rust-lang/cargo/issues/2524 in mind, I think there is a solution we could go for that makes consuming this crate among several platforms easier:

  • We only really need openssl on Windows.
  • On Windows, we probably always want to vendor openssl to make compilation easier.
  • We only need hyperlocal on unix systems.

Given that, I feel like we could define these dependencies based on the target platform instead of defining features.

The downside of the above approach would be that one could not use the crate on Unix with SSL but I am not sure what that would be useful for anyway. If we still wanted to support that, I believe we could always define an optional feature that adds the openssl crate.

Opinions?

thomaseizinger avatar Dec 10 '19 12:12 thomaseizinger