From: Stefan Herbrechtsmeier <stefan.herbrechtsme...@weidmueller.com>
Add a vendor class for cargo to resolve the dependency SRC_URIs from a Cargo.lock file and populate the crate vendor folder. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsme...@weidmueller.com> --- meta/classes-recipe/vendor_cargo.bbclass | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 meta/classes-recipe/vendor_cargo.bbclass diff --git a/meta/classes-recipe/vendor_cargo.bbclass b/meta/classes-recipe/vendor_cargo.bbclass new file mode 100644 index 0000000000..495f7e01ce --- /dev/null +++ b/meta/classes-recipe/vendor_cargo.bbclass @@ -0,0 +1,46 @@ +# Copyright (C) 2025 Weidmueller Interface GmbH & Co. KG +# Stefan Herbrechtsmeier <stefan.herbrechtsme...@weidmueller.com> +# +# SPDX-License-Identifier: MIT +# + +# The name of the vendor directory +CARGO_VENDOR_SUBDIR = "vendor" + +# The URL of the crate registry +CARGO_REGISTRY ?= "https://crates.io" + +CARGO_SRC_PATH = "${S}/${CARGO_SRC_DIR}" +CARGO_SRC_SUBDIR = "${@os.path.relpath(d.getVar('CARGO_SRC_PATH'), d.getVar('WORKDIR'))}" +CARGO_SRC_URI_FILE = "${VENDOR_DIR}/cargo-source-uris.txt" +SRC_URI_FILES:append = " ${CARGO_SRC_URI_FILE}" + +inherit vendor + +CARGO_VENDORING_DIRECTORY = "${CARGO_SRC_PATH}/${CARGO_VENDOR_SUBDIR}" + +python vendor_cargo_do_vendor_resolve() { + from oe.vendor import cargo + + lock_file_dir = d.getVar("CARGO_LOCK_PATH") + lock_file_dir = get_early_source_dir(d, lock_file_dir) + registry = d.getVar("CARGO_REGISTRY") + src_subdir = d.getVar("CARGO_SRC_SUBDIR") + vendor_subdir = d.getVar("CARGO_VENDOR_SUBDIR") + uris = cargo.resolve_src_uris(lock_file_dir, registry, src_subdir, + vendor_subdir) + with open(d.getVar("CARGO_SRC_URI_FILE"), "w") as f: + oe.vendor.dump(f, uris) +} + +python emulate_crate_vendor() { + from oe.vendor import cargo + + lock_file_dir = d.getVar("CARGO_LOCK_PATH") + lock_file_dir = get_early_source_dir(d, lock_file_dir) + vendor_dir = d.getVar("CARGO_VENDORING_DIRECTORY") + cargo.populate_vendor(lock_file_dir, vendor_dir) +} +do_unpack[postfuncs] += "emulate_crate_vendor" + +EXPORT_FUNCTIONS do_vendor_resolve -- 2.39.5
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#211146): https://lists.openembedded.org/g/openembedded-core/message/211146 Mute This Topic: https://lists.openembedded.org/mt/111123545/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-