rust-embedded / meta-rust-bin

Yocto layer for installing Rust toolchain from pre-built binaries
104 stars 63 forks source link

Support for `Cross.toml` configs #186

Open redeexpressos opened 1 month ago

redeexpressos commented 1 month ago

Trying to build a crate that depends on protoc. When cross-compiling, I have to add Cross.toml:

[build]
default-target = "armv7-unknown-linux-gnueabihf"
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get --assume-yes install protobuf-compiler:$CROSS_DEB_ARCH",
]

How can I add that configuration when compiling with this layer?

tronical commented 1 month ago

I don't think calling apt-get install, etc. would make sense in the Yocto context. I suggest to try to modify your bit bake recipe to include protoc in the native sysroot, that's hopefully in the path. Something like DEPENDS += " protobuf-native"

redeexpressos commented 1 month ago

@tronical Thanks for answering. However, doesn't this layer use cross to build? When I use Cross, I also have to install protoc via a Cross.toml like this:

[build]
default-target = "armv7-unknown-linux-gnueabihf"
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get --assume-yes install protobuf-compiler:$CROSS_DEB_ARCH",
]
tronical commented 1 month ago

However, doesn't this layer use cross to build?

No, meta-rust-bin does not use cross to build. In fact, it doesn't build rust, it fetches the right binaries and makes them available (via bit bake classes) to recipes for invocation. The actual build of crates compiled with meta-rust-bin happen inside the yocto/bitbake environment, not inside a docker container (like cross). In short, cross-compilation with meta-rust-bin is like calling cargo build --target=aarch64-unknown-linux-gnu (or similar), along with a cargo config set up to invoke the correct linker, set the right sysroot, etc - behind the scenes.