diff options
author | Alex Kiernan <alex.kiernan@gmail.com> | 2023-03-31 07:45:22 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-01 11:36:26 +0100 |
commit | 0d099fa404b037d46baf63c9a89a8b83c5bf607f (patch) | |
tree | b3dcd902bb5d1b5912eeb914d772f87112c18e90 | |
parent | 15dc92a4b19baedbb9bfa95fbe2c8b6a7c9987c8 (diff) | |
download | poky-0d099fa404b037d46baf63c9a89a8b83c5bf607f.tar.gz |
cargo_common.bbclass: Support local github repos
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).
(From OE-Core rev: 684a8af41c5bb70db68e75f72bdc4c9b09630810)
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes-recipe/cargo_common.bbclass | 30 |
1 files changed, 30 insertions, 0 deletions
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 () { | |||
116 | EOF | 116 | EOF |
117 | } | 117 | } |
118 | 118 | ||
119 | python cargo_common_do_patch_paths() { | ||
120 | cargo_config = os.path.join(d.getVar("CARGO_HOME"), "config") | ||
121 | if not os.path.exists(cargo_config): | ||
122 | return | ||
123 | |||
124 | src_uri = (d.getVar('SRC_URI') or "").split() | ||
125 | if len(src_uri) == 0: | ||
126 | return | ||
127 | |||
128 | patches = dict() | ||
129 | workdir = d.getVar('WORKDIR') | ||
130 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
131 | for url in fetcher.urls: | ||
132 | ud = fetcher.ud[url] | ||
133 | if ud.type == 'git': | ||
134 | name = ud.parm.get('name') | ||
135 | destsuffix = ud.parm.get('destsuffix') | ||
136 | if name is not None and destsuffix is not None: | ||
137 | repo = '%s://%s%s' % (ud.proto, ud.host, ud.path) | ||
138 | path = '%s = { path = "%s" }' % (name, os.path.join(workdir, destsuffix)) | ||
139 | patches.setdefault(repo, []).append(path) | ||
140 | |||
141 | with open(cargo_config, "a+") as config: | ||
142 | for k, v in patches.items(): | ||
143 | print('\n[patch."%s"]' % k, file=config) | ||
144 | for name in v: | ||
145 | print(name, file=config) | ||
146 | } | ||
147 | do_configure[postfuncs] += "cargo_common_do_patch_paths" | ||
148 | |||
119 | oe_cargo_fix_env () { | 149 | oe_cargo_fix_env () { |
120 | export CC="${RUST_TARGET_CC}" | 150 | export CC="${RUST_TARGET_CC}" |
121 | export CXX="${RUST_TARGET_CXX}" | 151 | export CXX="${RUST_TARGET_CXX}" |