meta-rust / cargo-bitbake

cargo extension that can generate BitBake recipes utilizing the classes from meta-rust
Apache License 2.0
85 stars 59 forks source link

Generated recipe includes dependencies of all projects in a workspace, not just the current project #17

Open pbrkr opened 4 years ago

pbrkr commented 4 years ago

I have a workspace with two simple projects in it: a hello project with no dependencies and a print-rand project that depends on the rand crate. This workspace can be seen here: https://gitlab.com/pbarker.dev/learn-rust/-/tree/711141cb58ccb241b1c6b13454746bd28b106de7

If I run cargo bitbake in the directory of the hello project, the dependencies of the print-rand project are also included in SRC_URI.

[pbarker@ar2 hello]$ cargo bitbake --version
cargo-bitbake 0.3.14
[pbarker@ar2 hello]$ cargo bitbake
Wrote: hello_0.1.0.bb
[pbarker@ar2 hello]$ cat hello_0.1.0.bb 
# Auto-Generated by cargo-bitbake 0.3.14
#
inherit cargo

# If this is git based prefer versioned ones if they exist
# DEFAULT_PREFERENCE = "-1"

# how to get hello could be as easy as but default to a git checkout:
# SRC_URI += "crate://crates.io/hello/0.1.0"
SRC_URI += "git://git@gitlab.com/pbarker.dev/learn-rust.git;protocol=ssh;nobranch=1;branch=dev"
SRCREV = "711141cb58ccb241b1c6b13454746bd28b106de7"
S = "${WORKDIR}/git"
CARGO_SRC_DIR = "hello"
PV_append = ".AUTOINC+711141cb58"

# please note if you have entries that do not begin with crate://
# you must change them to how that package can be fetched
SRC_URI += " \
    crate://crates.io/cfg-if/0.1.10 \
    crate://crates.io/getrandom/0.1.15 \
    crate://crates.io/libc/0.2.77 \
    crate://crates.io/ppv-lite86/0.2.9 \
    crate://crates.io/rand/0.7.3 \
    crate://crates.io/rand_chacha/0.2.2 \
    crate://crates.io/rand_core/0.5.1 \
    crate://crates.io/rand_hc/0.2.0 \
    crate://crates.io/wasi/0.9.0+wasi-snapshot-preview1 \
"

# FIXME: update generateme with the real MD5 of the license file
LIC_FILES_CHKSUM = " \
    file://hello/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327 \
"

SUMMARY = "Hello World application"
HOMEPAGE = "https://gitlab.com/pbarker.dev/learn-rust/-/tree/dev/hello"
LICENSE = "Apache-2.0"

# includes this file if it exists but does not fail
# this is useful for anything you may want to override from
# what cargo-bitbake generates.
include hello-${PV}.inc
include hello.inc

I suspect that the dependencies are being resolved at the workspace level instead of at the project level but I'm not familiar enough with the cargo API to be sure on this or to suggest how to fix it.

MaartenvMegen commented 3 years ago

I can confirm this behavior is still present on cargo-bitbake 0.3.15 and is interfering with our workflow. It does seem to match with the way meta-rust pulls in sources during bitbake compilation. Because manually removing the unneeded dependencies from the recipe causes the bitbake build to fail.