Skip to content

Support git subdirectory packages (workspace members & git deps)#91

Open
akiernan wants to merge 5 commits into
meta-rust:masterfrom
A-Squared-Projects:master
Open

Support git subdirectory packages (workspace members & git deps)#91
akiernan wants to merge 5 commits into
meta-rust:masterfrom
A-Squared-Projects:master

Conversation

@akiernan
Copy link
Copy Markdown

@akiernan akiernan commented Jun 1, 2026

Packages that live in a subdirectory of their git repository (workspace
members, monorepo crates, git deps whose crate is not at the repo root)
were handled incorrectly: CARGO_SRC_DIR, LIC_FILES_CHKSUM paths, and
the SRC_URI for git deps were anchored at the Cargo workspace root
instead of the git checkout root (S = "${WORKDIR}/git").

  • Emit subdir= for git dependencies whose crate lives in a
    subdirectory of its git repository. git_to_yocto_git_url gains a
    subdir parameter; the new git_repo_subdir helper detects the
    relative path from a package root to its git checkout root.
    This change is dependent on the corresponding support in
    meta-rust (meta-rust/meta-rust@314851b)

  • Fix CARGO_SRC_DIR and LIC_FILES_CHKSUM paths to be relative to the
    git checkout root. ProjectRepo::new now accepts a package_dir
    parameter and computes cargo_src_dir. crate_root is now
    package.root() (the selected member directory) instead of the
    workspace root manifest's parent.

  • Fall back to the git repo root when searching for license files.
    When no license file is found under the crate directory,
    license::file also checks the repository root, covering the common
    monorepo pattern where a shared LICENSE lives at the top level.

  • Downgrade missing homepage/repository from an error to a warning.
    HOMEPAGE is optional in BitBake; an absent value now prints a
    diagnostic and leaves the field empty rather than aborting.

Whilst these changes were largely AI created, they have all been reviewed and checked against repos which exhibit all of these issues as well as existing ones which do not.

akiernan and others added 5 commits May 31, 2026 15:35
HOMEPAGE is optional in BitBake. Workspace members often have neither
field set, causing cargo-bitbake to abort. Demote to a warning and emit
an empty HOMEPAGE instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
The git checkout used by the recipe (S = "${WORKDIR}/git") contains the
whole repository, so paths interpreted relative to it must account for a
project whose Cargo.toml lives in a sub directory of the repo:

  - CARGO_SRC_DIR must point at that sub directory rather than "".
  - LIC_FILES_CHKSUM entries must be prefixed with it too, otherwise the
    license paths point at the repo root rather than the actual files.

Compute the package directory relative to the git repository working
directory in ProjectRepo and use it for both, dropping the previous
workspace-root-relative rel_dir helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
A git dependency whose crate is in a sub directory of its repository is
fetched to its own destsuffix, but EXTRA_OECARGO_PATHS then points cargo
at the repo root rather than the crate. Add a ";subdir=<subdir>"
modifier to the SRC_URI so bitbake unpacks just that sub directory at
the destsuffix where cargo expects it.

The sub directory is derived from the dependency's checked-out location
relative to its git working directory.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
License-file discovery only searched the crate directory, so a shared
license at the top of a monorepo (with the crate in a sub directory) was
never found and emitted the generateme fallback.

Search the crate directory first, then the git repository root, emitting
paths relative to S = "${WORKDIR}/git" in both cases (the crate sub
directory prefix for the former, no prefix for the latter). Track the
repo root in ProjectRepo to support this.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
crate_root was the workspace root, so a workspace member's own license
file (in the member directory) was never found and fell back to
generateme. Use the selected package's directory as crate_root and its
git-root-relative path as the license prefix, so member-local licenses
are discovered and pathed correctly. The repo-root fallback still
handles a shared license at the top of the workspace.

CARGO_SRC_DIR is unchanged (the workspace root, built with -p).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant