cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.64k stars 370 forks source link

Cross config for multiple targets? #1244

Open VorpalBlade opened 1 year ago

VorpalBlade commented 1 year ago

Checklist

Describe your request

I need to install OpenSSL when cross compiling to other Linux architectures (e.g. ARM, Aarch64, i686). However the documented command in https://github.com/cross-rs/cross/wiki/Recipes#openssl would as far as I understand lead to code duplication.

I can't find anywhere to specify a glob pattern, e.g.:

[target.*-unknown-linux-*]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH"
]

(and that specific syntax does not work). Do I really need to duplicate this for every single architecture I want to compile to? Or is there a way to stick to the DRY principle (Don't Repeat Yourself)?

Describe why this would be a good inclusion for cross

If this is not supported, it seems like an obvious feature to avoid repetition (and risk of these lines getting out of sync). All matching sections should be applied (e.g. apply both a *windows* and a *x86_64-pc-windows* section when building for 64-bit windows)

Adding a custom docker image for each architecture, maintaining that, and dealing with CI for it is way outside of my personal project scope as well as outside my expertise. Especially since I plan to use a ready-made GitHub CI action to do this (once I confirm everything works locally).

Emilgardis commented 1 year ago

Yes!

See https://github.com/cross-rs/cross/wiki/Configuration#build

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH"
]
Emilgardis commented 1 year ago

hmm, I'll actually reopen this, it could maybe be useful to have cfg() and wildcards

so

[target."*linux*"] and target."cfg(feature = "feat").<target>"

orhun commented 1 year ago

[target."*linux*"] and target."cfg(feature = "feat").<target>"

Having this feature would be really nice.