Skip to content

Commit

Permalink
Merge pull request #136 from Exein-io/classes_rename
Browse files Browse the repository at this point in the history
Classes rename
  • Loading branch information
posborne authored Oct 7, 2023
2 parents 829ea2d + f1037f3 commit 7ac87ec
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,25 @@ SUMMARY = "GPIO Utilities"
HOMEPAGE = "git://github.com/rust-embedded/gpio-utils"
LICENSE = "MIT"
inherit cargo
inherit cargo_bin
# Enable network for the compile task allowing cargo to download dependencies
do_compile[network] = "1"
SRC_URI = "git://github.com/rust-embedded/gpio-utils.git;protocol=https;branch=master"
SRCREV="02b0658cd7e13e46f6b1a5de3fd9655711749759"
S = "${WORKDIR}/git"
LIC_FILES_CHKSUM = "file://LICENSE-MIT;md5=935a9b2a57ae70704d8125b9c0e39059"
```

As you can see, there is almost no overhead introduced from the `cargo` class
beyond simply inheriting it. The `cargo` class adds the appropriate Rust
As you can see, there is almost no overhead introduced from the `cargo_bin` class
beyond simply inheriting it. The `cargo_bin` class adds the appropriate Rust
dependencies as well as default compile and install steps.

> **Warning**
> In previous versions of `meta-rust-bin` the class `cargo` was used instead
> of `cargo_bin`. Follow this [guide](#updating-from-an-old-meta-rust-bin) if you
> are updating your `meta-rust-bin` layer from an old version.
## Features

Expand Down Expand Up @@ -79,12 +86,15 @@ downloads dependencies, so add the following line to the recipe:
do_compile[network] = "1"
```

### Use with Yocto Release 3.4 (honister) and Above
### Updating from an old `meta-rust-bin`

To avoid conflicts with the offical Rust layer of Yocto, the class `cargo` of
`meta-rust-bin` was renamed to `cargo_bin`.

If you are updating `meta-rust-bin` from an old version please make sure to
update the inherited class of your recipe to `cargo_bin`.

Rust is included directly in `openmbedded-core` as of Yocto version 3.4. The
included recipe builds Rust components from the sources. To use binaries from
the `meta-rust-bin` layer instead, set `BBMASK` to exclude the package in your
configuration:
After the update it's safe to remove the previously used `BBMASK`:

```bitbake
BBMASK = "poky/meta/recipes-devtools/rust"
Expand Down
8 changes: 4 additions & 4 deletions classes/cargo.bbclass → classes/cargo_bin.bbclass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
inherit rust-common
inherit rust_bin-common

# Many crates rely on pkg-config to find native versions of their libraries for
# linking - do the simple thing and make it generally available.
Expand Down Expand Up @@ -75,7 +75,7 @@ create_cargo_config() {
echo "debug = true" >> ${CARGO_HOME}/config
}

cargo_do_configure() {
cargo_bin_do_configure() {
mkdir -p "${B}"
mkdir -p "${CARGO_HOME}"
mkdir -p "${WRAPPER_DIR}"
Expand Down Expand Up @@ -111,7 +111,7 @@ cargo_do_configure() {
create_cargo_config
}

cargo_do_compile() {
cargo_bin_do_compile() {
export TARGET_CC="${WRAPPER_DIR}/cc-wrapper.sh"
export TARGET_CXX="${WRAPPER_DIR}/cxx-wrapper.sh"
export CC="${WRAPPER_DIR}/cc-native-wrapper.sh"
Expand All @@ -130,7 +130,7 @@ cargo_do_compile() {
cargo build ${CARGO_BUILD_FLAGS}
}

cargo_do_install() {
cargo_bin_do_install() {
if [ "${CARGO_BUILD_TYPE}" = "--release" ]; then
local cargo_bindir="${CARGO_RELEASE_DIR}"
else
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ LAYERSERIES_COMPAT_rust-bin-layer = " \
hardknott \
honister \
kirkstone \
langdale \
"
2 changes: 1 addition & 1 deletion recipes-devtools/rust/cargo-bin-cross.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LICENSE = "Apache-2.0 | MIT"
SECTION = "devel"

inherit cross
inherit rust-common
inherit rust_bin-common

PN = "cargo-bin-cross-${TARGET_ARCH}"

Expand Down
2 changes: 1 addition & 1 deletion recipes-devtools/rust/rust-bin-cross.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LICENSE = "Apache-2.0 | MIT"
SECTION = "devel"

inherit cross
inherit rust-common
inherit rust_bin-common

# Required to link binaries
DEPENDS += "gcc-cross-${TARGET_ARCH}"
Expand Down

0 comments on commit 7ac87ec

Please sign in to comment.