summaryrefslogtreecommitdiff
path: root/poky/meta/classes-recipe/cargo_common.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'poky/meta/classes-recipe/cargo_common.bbclass')
-rw-r--r--poky/meta/classes-recipe/cargo_common.bbclass33
1 files changed, 33 insertions, 0 deletions
diff --git a/poky/meta/classes-recipe/cargo_common.bbclass b/poky/meta/classes-recipe/cargo_common.bbclass
index f503a001dd..82ab25b59c 100644
--- a/poky/meta/classes-recipe/cargo_common.bbclass
+++ b/poky/meta/classes-recipe/cargo_common.bbclass
@@ -116,6 +116,39 @@ 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:
+ if ud.user:
+ repo = '%s://%s@%s%s' % (ud.proto, ud.user, ud.host, ud.path)
+ else:
+ 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}"