1*4882a593Smuzhiyun## Introduction 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunThis provides the Rust compiler, tools for building packages (cargo), and 4*4882a593Smuzhiyuna few example projects. 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun## What works: 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun - Building `rust-native` and `cargo-native` 9*4882a593Smuzhiyun - Building Rust based projects with Cargo for the TARGET 10*4882a593Smuzhiyun - e.g. `rustfmt` which is used by the CI system 11*4882a593Smuzhiyun - `-buildsdk` and `-crosssdk` packages 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun## What doesn't: 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun - Using anything but x86_64 or arm64 as the build environment 16*4882a593Smuzhiyun - rust (built for target) [issue #81](https://github.com/meta-rust/meta-rust/issues/81) 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun## What's untested: 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun - cargo (built for target) 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun## Building a rust package 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunWhen building a rust package in bitbake, it's usually easiest to build with 25*4882a593Smuzhiyuncargo using cargo.bbclass. If the package already has a Cargo.toml file (most 26*4882a593Smuzhiyunrust packages do), then it's especially easy. Otherwise you should probably 27*4882a593Smuzhiyunget the code building in cargo first. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunOnce your package builds in cargo, you can use 30*4882a593Smuzhiyun[cargo-bitbake](https://github.com/cardoe/cargo-bitbake) to generate a bitbake 31*4882a593Smuzhiyunrecipe for it. This allows bitbake to fetch all the necessary dependent 32*4882a593Smuzhiyuncrates, as well as a pegged version of the crates.io index, to ensure maximum 33*4882a593Smuzhiyunreproducibility. Once the Rust SDK support is added to oe-core, cargo-bitbake 34*4882a593Smuzhiyunmay also be added to the SDK. 35*4882a593Smuzhiyun 36*4882a593SmuzhiyunNOTE: You will have to edit the generated recipe based on the comments 37*4882a593Smuzhiyuncontained within it 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun## TODO 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun## Pitfalls 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun - TARGET_SYS _must_ be different from BUILD_SYS. This is due to the way Rust configuration options are tracked for different targets. This is the reason we use the Yocto triples instead of the native Rust triples. See rust-lang/cargo#3349. 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun## Dependencies 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunOn the host: 48*4882a593Smuzhiyun - Any `-sys` packages your project might need must have RDEPENDs for 49*4882a593Smuzhiyun the native library. 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunOn the target: 52*4882a593Smuzhiyun - Any `-sys` packages your project might need must have RDEPENDs for 53*4882a593Smuzhiyun the native library. 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun## Copyright 56*4882a593Smuzhiyun 57*4882a593SmuzhiyunMIT OR Apache-2.0 - Same as rust 58*4882a593Smuzhiyun 59