Support git subdirectory packages (workspace members & git deps)#91
Open
akiernan wants to merge 5 commits into
Open
Support git subdirectory packages (workspace members & git deps)#91akiernan wants to merge 5 commits into
akiernan wants to merge 5 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.