From patchwork Fri Feb 3 10:14:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Opdenacker X-Patchwork-Id: 18976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D343C636CC for ; Fri, 3 Feb 2023 10:14:39 +0000 (UTC) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by mx.groups.io with SMTP id smtpd.web10.7314.1675419277474228257 for ; Fri, 03 Feb 2023 02:14:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mGdToRk0; spf=pass (domain: bootlin.com, ip: 217.70.183.194, mailfrom: michael.opdenacker@bootlin.com) Received: (Authenticated sender: michael.opdenacker@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id D5C4740007; Fri, 3 Feb 2023 10:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675419275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XmBffRRWseisG8hQ8h7puNYTttojZB68jPBgT+BNNJY=; b=mGdToRk0s99c8RzBYdnxUYZVXckvLe0BZJ6SNqg5wkX57wB7FvHXjOk5PJsXpzhUdR+heP BSJYRf6MG4vs4/snz5cF6c8qVFCdiXeDSCW/oiKVMAbUs/Ozq0ew8aJ3fehA3UmYyrPcd5 NKeBkKkOhQ/OQlKVcDZQGoWYYeJ9IrYc8u9zBOTI2qOxos39DMN/D8MVcPGTnJU+308H7w ecGo8KIPX826Z58gUicOscmgEeOwYHvDbr7KS9NhHjwuMg37xli8oNYwpgSsn1//Fcs/8U YGjjrSbWLCIVQaOxk+PfPuMKB+k1p4sXcU6q1Z+pzLdMGOXYFemqpXYWlIvo2A== From: michael.opdenacker@bootlin.com To: docs@lists.yoctoproject.org Cc: alex.kiernan@gmail.com, Michael Opdenacker Subject: [PATCH v2] ref-manual: document Rust classes Date: Fri, 3 Feb 2023 11:14:18 +0100 Message-Id: <20230203101418.54074-1-michael.opdenacker@bootlin.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <17404733E261D6D8.15679@lists.yoctoproject.org> References: <17404733E261D6D8.15679@lists.yoctoproject.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 03 Feb 2023 10:14:39 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/docs/message/3633 From: Michael Opdenacker Signed-off-by: Michael Opdenacker --- Changes in V2: - Grammar fix: replace "an src" by "a src" (Richard Purdie) - Document the cargo-update-recipe-crates class, thanks to information provided by Alex Kiernan --- documentation/ref-manual/classes.rst | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst index 0cb507b500..b5443c0d0a 100644 --- a/documentation/ref-manual/classes.rst +++ b/documentation/ref-manual/classes.rst @@ -254,8 +254,68 @@ When inherited globally, prints statistics at the end of the build on sstate re-use. In order to function, this class requires the :ref:`ref-classes-buildstats` class be enabled. +.. _ref-classes-cargo: + +``cargo`` +========= + +The :ref:`ref-classes-cargo` class allows to compile Rust language programs +using `Cargo `__. Cargo is Rust's package +manager, allowing to fetch package dependencies and build your program. + +Using this class makes it very easy to build Rust programs. All you need +is to use the :term:`SRC_URI` variable to point to a source repository +which can be built by Cargo, typically one that was created by the +``cargo new`` command, containing a ``Cargo.toml`` file and a ``src`` +subdirectory. + +You will find a simple example in the +:oe_git:`rust-hello-world_git.bb ` +recipe. A more complex example, with package dependencies, is the +:oe_git:`uutils-coreutils ` +recipe, which was generated by the `cargo-bitbake `__ +tool. + +This class inherits the :ref:`ref-classes-cargo_common` class. + +.. _ref-classes-cargo_common: + +``cargo_common`` +================ + +The :ref:`ref-classes-cargo_common` class is an internal class +that is not intended to be used directly. + +An exception is the "rust" recipe, to build the Rust compiler and runtime +library, which is built by Cargo but cannot use the :ref:`ref-classes-cargo` +class. This is why this class was introduced. + .. _ref-classes-ccache: +.. _ref-classes-cargo-update-recipe-crates: + +``cargo-update-recipe-crates`` +=============================== + +The :ref:`ref-classes-cargo-update-recipe-crates` class allows +recipe developers to update the list of Cargo crates in :term:`SRC_URI` +by reading the ``Cargo.lock`` file in the source tree. + +To do so, create a recipe for your program, for example using +:doc:`devtool `, +make it inherit the :ref:`ref-classes-cargo` and +:ref:`ref-classes-cargo-update-recipe-crates` and run:: + + bitbake -c update_crates recipe + +This creates a ``recipe-crates.inc`` file that you can include in your +recipe:: + + require ${BPN}-crates.inc + +That's also something you can achieve by using the +`cargo-bitbake `__ tool. + ``ccache`` ========== @@ -2493,6 +2553,24 @@ For information on how root filesystem images are created, see the ":ref:`overview-manual/concepts:image generation`" section in the Yocto Project Overview and Concepts Manual. +.. _ref-classes-rust: + +``rust`` +======== + +The :ref:`ref-classes-rust` class is an internal class which is just used +in the "rust" recipe, to build the Rust compiler and runtime +library. Except for this recipe, it is not intended to be used directly. + +.. _ref-classes-rust-common: + +``rust-common`` +=============== + +The :ref:`ref-classes-rust-common` class is an internal class to the +:ref:`ref-classes-cargo_common` and :ref:`ref-classes-rust` classes and is not +intended to be used directly. + .. _ref-classes-sanity: ``sanity``