From: frederic.martinsons@gmail.com
To: openembedded-core@lists.openembedded.org
Cc: alex.kiernan@gmail.com
Subject: [PATCH V5 1/6] cargo_common.bbclass: Support local github repos
Date: Thu, 30 Mar 2023 17:44:48 +0200 [thread overview]
Message-ID: <ea287e57d752f05c32c1bfb3d97c64e23997c5bc.1680190966.git.frederic.martinsons@gmail.com> (raw)
In-Reply-To: <cover.1680190966.git.frederic.martinsons@gmail.com>
From: Alex Kiernan <alex.kiernan@gmail.com>
Since disable network was added cargo configurations which reference git
repos fail as they attempt to fetch across the network as part of
do_compile, even if EXTRA_OECARGO_PATHS to add them as part of `paths`
is used, as this is documented as only working for packages which exist
in crates.io.
Add parsing of the SRC_URIs for git repos and include `[patch]` sections
to redirect to the checked out source repos which the bitbake fetcher
has already populated.
There are still cases which don't work - if you have multiple copies of
the same repo with different revisions, there's currently no way to
represent that and anything using a repo which has a virtual manifest
will fail to build (see https://github.com/rust-lang/cargo/issues/4934).
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---
meta/classes-recipe/cargo_common.bbclass | 30 ++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass
index f503a001dd..63b1382908 100644
--- a/meta/classes-recipe/cargo_common.bbclass
+++ b/meta/classes-recipe/cargo_common.bbclass
@@ -116,6 +116,36 @@ cargo_common_do_configure () {
EOF
}
+python cargo_common_do_patch_paths() {
+ cargo_config = os.path.join(d.getVar("CARGO_HOME"), "config")
+ if not os.path.exists(cargo_config):
+ return
+
+ src_uri = (d.getVar('SRC_URI') or "").split()
+ if len(src_uri) == 0:
+ return
+
+ patches = dict()
+ workdir = d.getVar('WORKDIR')
+ fetcher = bb.fetch2.Fetch(src_uri, d)
+ for url in fetcher.urls:
+ ud = fetcher.ud[url]
+ if ud.type == 'git':
+ name = ud.parm.get('name')
+ destsuffix = ud.parm.get('destsuffix')
+ if name is not None and destsuffix is not None:
+ repo = '%s://%s%s' % (ud.proto, ud.host, ud.path)
+ path = '%s = { path = "%s" }' % (name, os.path.join(workdir, destsuffix))
+ patches.setdefault(repo, []).append(path)
+
+ with open(cargo_config, "a+") as config:
+ for k, v in patches.items():
+ print('\n[patch."%s"]' % k, file=config)
+ for name in v:
+ print(name, file=config)
+}
+do_configure[postfuncs] += "cargo_common_do_patch_paths"
+
oe_cargo_fix_env () {
export CC="${RUST_TARGET_CC}"
export CXX="${RUST_TARGET_CXX}"
--
2.34.1
next prev parent reply other threads:[~2023-03-30 15:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 15:44 [PATCH V5 0/6] Extend cargo based recipe support frederic.martinsons
2023-03-30 15:44 ` frederic.martinsons [this message]
2023-03-30 15:44 ` [PATCH V5 2/6] cargo_common.bbclass: add support of user in url for patch frederic.martinsons
2023-03-30 15:44 ` [PATCH V5 3/6] devtool: add support for multiple git url inside a cargo based recipe frederic.martinsons
2023-03-30 15:44 ` [PATCH V5 4/6] patch: support of git patches when the source uri contained subpath parameter frederic.martinsons
2023-03-30 15:44 ` [PATCH V5 5/6] meta-selftest: provide a recipe for zvariant frederic.martinsons
2023-03-30 15:44 ` [PATCH V5 6/6] cargo-update-recipe-crates: don't walk on the whole dir frederic.martinsons
2023-03-30 16:34 ` Alex Kiernan
2023-03-30 17:09 ` Frédéric Martinsons
[not found] ` <1751418A85B52050.27612@lists.openembedded.org>
2023-03-30 18:53 ` [OE-core] " Frédéric Martinsons
2023-03-30 19:23 ` Martin Jansa
2023-03-30 19:50 ` Frédéric Martinsons
2023-03-30 20:07 ` Frédéric Martinsons
2023-03-30 20:22 ` Martin Jansa
[not found] ` <17514C0A502D4FD8.27612@lists.openembedded.org>
2023-03-30 21:15 ` Martin Jansa
2023-03-31 5:32 ` Frédéric Martinsons
[not found] ` <17516A1097F71BFB.12651@lists.openembedded.org>
2023-04-01 15:21 ` Frédéric Martinsons
2023-04-03 13:35 ` Richard Purdie
2023-04-03 14:25 ` Frédéric Martinsons
2023-03-30 20:08 ` Martin Jansa
2023-03-30 20:20 ` Alex Kiernan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea287e57d752f05c32c1bfb3d97c64e23997c5bc.1680190966.git.frederic.martinsons@gmail.com \
--to=frederic.martinsons@gmail.com \
--cc=alex.kiernan@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox