diff mbox series

ref-manual: document Rust classes

Message ID 20230113180932.1507356-1-michael.opdenacker@bootlin.com
State New
Headers show
Series ref-manual: document Rust classes | expand

Commit Message

Michael Opdenacker Jan. 13, 2023, 6:09 p.m. UTC
From: Michael Opdenacker <michael.opdenacker@bootlin.com>

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
---
 documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

Comments

Alex Kiernan Jan. 15, 2023, 8:03 p.m. UTC | #1
On Fri, Jan 13, 2023 at 6:09 PM Michael Opdenacker via
lists.yoctoproject.org
<michael.opdenacker=bootlin.com@lists.yoctoproject.org> wrote:
>
> From: Michael Opdenacker <michael.opdenacker@bootlin.com>
>
> Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
> ---
>  documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>
> diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
> index 0cb507b500..cc6ba04bff 100644
> --- a/documentation/ref-manual/classes.rst
> +++ b/documentation/ref-manual/classes.rst
> @@ -254,6 +254,42 @@ 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 <https://doc.rust-lang.org/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 an ``src``
> +subdirectory.
> +
> +You will find a simple example in the
> +:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
> +recipe. A more complex example, with package dependencies, is the
> +:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
> +recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/cargo-bitbake>`__
> +tool.
> +

We should reference `cargo-update-recipe-crates` here rather than
`cargo bitbake`. The flow for creating a recipe then goes something
like (using hippotat as an example
https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):

devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
hippotat https://salsa.debian.org/iwj/hippotat.git
# edit resulting recipe delete boiler plate tasks and add `inherit
cargo cargo-update-recipe-crates`
bitbake -c update_crates hippotat
# edit recipe to add `require ${BPN}-crates.inc`
devtool build hippotat
# fix resulting errors (add `DEPENDS += "openssl"`, `inherit
pkgconfig` in this case)
devtool build hippotat


--
Alex Kiernan
Alexander Kanavin Jan. 15, 2023, 8:09 p.m. UTC | #2
Perhaps you could write a patch to the docs that sets them right?

Alex

On Sun, 15 Jan 2023 at 21:03, Alex Kiernan <alex.kiernan@gmail.com> wrote:
>
> On Fri, Jan 13, 2023 at 6:09 PM Michael Opdenacker via
> lists.yoctoproject.org
> <michael.opdenacker=bootlin.com@lists.yoctoproject.org> wrote:
> >
> > From: Michael Opdenacker <michael.opdenacker@bootlin.com>
> >
> > Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
> > ---
> >  documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
> >  1 file changed, 54 insertions(+)
> >
> > diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
> > index 0cb507b500..cc6ba04bff 100644
> > --- a/documentation/ref-manual/classes.rst
> > +++ b/documentation/ref-manual/classes.rst
> > @@ -254,6 +254,42 @@ 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 <https://doc.rust-lang.org/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 an ``src``
> > +subdirectory.
> > +
> > +You will find a simple example in the
> > +:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
> > +recipe. A more complex example, with package dependencies, is the
> > +:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
> > +recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/cargo-bitbake>`__
> > +tool.
> > +
>
> We should reference `cargo-update-recipe-crates` here rather than
> `cargo bitbake`. The flow for creating a recipe then goes something
> like (using hippotat as an example
> https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
>
> devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
> hippotat https://salsa.debian.org/iwj/hippotat.git
> # edit resulting recipe delete boiler plate tasks and add `inherit
> cargo cargo-update-recipe-crates`
> bitbake -c update_crates hippotat
> # edit recipe to add `require ${BPN}-crates.inc`
> devtool build hippotat
> # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
> pkgconfig` in this case)
> devtool build hippotat
>
>
> --
> Alex Kiernan
Ulrich Ölmann Jan. 16, 2023, 7:35 a.m. UTC | #3
Hi Michael,

I am no inhabitant of the rust world, so I can not evaluate the
technical content - nevertheless: thanks for writing this up!
There is only a small typo I came across.

On Fri, Jan 13 2023 at 19:09 +0100, "Michael Opdenacker via lists.yoctoproject.org" <michael.opdenacker=bootlin.com@lists.yoctoproject.org> wrote:
> From: Michael Opdenacker <michael.opdenacker@bootlin.com>
>
> Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
> ---
>  documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>
> diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
> index 0cb507b500..cc6ba04bff 100644
> --- a/documentation/ref-manual/classes.rst
> +++ b/documentation/ref-manual/classes.rst
> @@ -254,6 +254,42 @@ 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 <https://doc.rust-lang.org/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 an ``src``

s/and an ``src``/and a ``src``/

Best regards
Ulrich


> +subdirectory.
> +
> +You will find a simple example in the
> +:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
> +recipe. A more complex example, with package dependencies, is the
> +:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
> +recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/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:
>  
>  ``ccache``
> @@ -2493,6 +2529,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``
Michael Opdenacker Jan. 16, 2023, 4:05 p.m. UTC | #4
Hi Ulrich,

On 16.01.23 at 08:35, Ulrich Ölmann wrote:
> Hi Michael,
>
> I am no inhabitant of the rust world, so I can not evaluate the
> technical content


That's not very different from my status. I'm just a tourist to the Rust 
world so far ;-)

> s/and an ``src``/and a ``src``/


I'd disagree on this one. If you read "src", what you pronounce ("S. R. 
C.") starts with a vowel, hence the use of "an".

https://editorsmanual.com/articles/indefinite-article-a-an-with-abbreviations/ 
seems to agree with me, but I'd be happy to be corrected!

Thanks for the proofreading!

Cheers
Michael.
Richard Purdie Jan. 16, 2023, 4:15 p.m. UTC | #5
On Mon, 2023-01-16 at 17:05 +0100, Michael Opdenacker via
lists.yoctoproject.org wrote:
> Hi Ulrich,
> 
> On 16.01.23 at 08:35, Ulrich Ölmann wrote:
> > Hi Michael,
> > 
> > I am no inhabitant of the rust world, so I can not evaluate the
> > technical content
> 
> 
> That's not very different from my status. I'm just a tourist to the Rust 
> world so far ;-)
> 
> > s/and an ``src``/and a ``src``/
> 
> 
> I'd disagree on this one. If you read "src", what you pronounce ("S. R. 
> C.") starts with a vowel, hence the use of "an".
> 
> https://editorsmanual.com/articles/indefinite-article-a-an-with-abbreviations/ 
> seems to agree with me, but I'd be happy to be corrected!
> 
> Thanks for the proofreading!

As a native speaker, it is definitely "a source" or "a src", "an src"
just sounds plain wrong to me!

Cheers,

Richard
Richard Purdie Jan. 16, 2023, 4:34 p.m. UTC | #6
On Mon, 2023-01-16 at 16:15 +0000, Richard Purdie via
lists.yoctoproject.org wrote:
> On Mon, 2023-01-16 at 17:05 +0100, Michael Opdenacker via
> lists.yoctoproject.org wrote:
> > Hi Ulrich,
> > 
> > On 16.01.23 at 08:35, Ulrich Ölmann wrote:
> > > Hi Michael,
> > > 
> > > I am no inhabitant of the rust world, so I can not evaluate the
> > > technical content
> > 
> > 
> > That's not very different from my status. I'm just a tourist to the Rust 
> > world so far ;-)
> > 
> > > s/and an ``src``/and a ``src``/
> > 
> > 
> > I'd disagree on this one. If you read "src", what you pronounce ("S. R. 
> > C.") starts with a vowel, hence the use of "an".
> > 
> > https://editorsmanual.com/articles/indefinite-article-a-an-with-abbreviations/ 
> > seems to agree with me, but I'd be happy to be corrected!
> > 
> > Thanks for the proofreading!
> 
> As a native speaker, it is definitely "a source" or "a src", "an src"
> just sounds plain wrong to me!

I was thinking a bit more about this, I think the reason is that you'd
always pronounce this as "source", I'm not sure how you'd say "src" out
loud! :)

Cheers,

Richard
Michael Opdenacker Jan. 16, 2023, 5:08 p.m. UTC | #7
On 16.01.23 at 17:34, Richard Purdie wrote:
>
>>> I'd disagree on this one. If you read "src", what you pronounce ("S. R.
>>> C.") starts with a vowel, hence the use of "an".
>>>
>>> https://editorsmanual.com/articles/indefinite-article-a-an-with-abbreviations/
>>> seems to agree with me, but I'd be happy to be corrected!
>>>
>>> Thanks for the proofreading!
>> As a native speaker, it is definitely "a source" or "a src", "an src"
>> just sounds plain wrong to me!
> I was thinking a bit more about this, I think the reason is that you'd
> always pronounce this as "source", I'm not sure how you'd say "src" out
> loud! :)


That's what's difficult with English, there are so many different uses 
of it, and I'm saying "S. R. C." while you say "source" for "src".
Anyway, you win as a native speaker :)

Thanks
Michael.
Michael Opdenacker Jan. 16, 2023, 5:18 p.m. UTC | #8
Hi Alex,

On 15.01.23 at 21:03, Alex Kiernan wrote:
> On Fri, Jan 13, 2023 at 6:09 PM Michael Opdenacker via
> lists.yoctoproject.org
> <michael.opdenacker=bootlin.com@lists.yoctoproject.org> wrote:
>> From: Michael Opdenacker <michael.opdenacker@bootlin.com>
>>
>> Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
>> ---
>>   documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
>>   1 file changed, 54 insertions(+)
>>
>> diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
>> index 0cb507b500..cc6ba04bff 100644
>> --- a/documentation/ref-manual/classes.rst
>> +++ b/documentation/ref-manual/classes.rst
>> @@ -254,6 +254,42 @@ 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 <https://doc.rust-lang.org/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 an ``src``
>> +subdirectory.
>> +
>> +You will find a simple example in the
>> +:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
>> +recipe. A more complex example, with package dependencies, is the
>> +:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
>> +recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/cargo-bitbake>`__
>> +tool.
>> +
> We should reference `cargo-update-recipe-crates` here rather than
> `cargo bitbake`. The flow for creating a recipe then goes something
> like (using hippotat as an example
> https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
>
> devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
> hippotat https://salsa.debian.org/iwj/hippotat.git
> # edit resulting recipe delete boiler plate tasks and add `inherit
> cargo cargo-update-recipe-crates`
> bitbake -c update_crates hippotat
> # edit recipe to add `require ${BPN}-crates.inc`
> devtool build hippotat
> # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
> pkgconfig` in this case)
> devtool build hippotat


Thanks for the review and suggestion. I overlooked this class so I will 
mention it in the docs, as well as the example you gave.
Thanks again
Cheers
Michael.
Alex Kiernan Jan. 16, 2023, 7:30 p.m. UTC | #9
On Mon, Jan 16, 2023 at 5:18 PM Michael Opdenacker
<michael.opdenacker@bootlin.com> wrote:
>
> Hi Alex,
>
> On 15.01.23 at 21:03, Alex Kiernan wrote:
> > On Fri, Jan 13, 2023 at 6:09 PM Michael Opdenacker via
> > lists.yoctoproject.org
> > <michael.opdenacker=bootlin.com@lists.yoctoproject.org> wrote:
> >> From: Michael Opdenacker <michael.opdenacker@bootlin.com>
> >>
> >> Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
> >> ---
> >>   documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
> >>   1 file changed, 54 insertions(+)
> >>
> >> diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
> >> index 0cb507b500..cc6ba04bff 100644
> >> --- a/documentation/ref-manual/classes.rst
> >> +++ b/documentation/ref-manual/classes.rst
> >> @@ -254,6 +254,42 @@ 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 <https://doc.rust-lang.org/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 an ``src``
> >> +subdirectory.
> >> +
> >> +You will find a simple example in the
> >> +:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
> >> +recipe. A more complex example, with package dependencies, is the
> >> +:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
> >> +recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/cargo-bitbake>`__
> >> +tool.
> >> +
> > We should reference `cargo-update-recipe-crates` here rather than
> > `cargo bitbake`. The flow for creating a recipe then goes something
> > like (using hippotat as an example
> > https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
> >
> > devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
> > hippotat https://salsa.debian.org/iwj/hippotat.git
> > # edit resulting recipe delete boiler plate tasks and add `inherit
> > cargo cargo-update-recipe-crates`
> > bitbake -c update_crates hippotat
> > # edit recipe to add `require ${BPN}-crates.inc`
> > devtool build hippotat
> > # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
> > pkgconfig` in this case)
> > devtool build hippotat
>
>
> Thanks for the review and suggestion. I overlooked this class so I will
> mention it in the docs, as well as the example you gave.

Happy to pick up on Alex's suggestion and try and get you some words,
just it's likely to take me a few days.
Michael Opdenacker Feb. 2, 2023, 6:06 p.m. UTC | #10
Hi Alex,

I tried the example you gave to use the "cargo-update-recipe-crates" class.

On 15.01.23 at 21:03, Alex Kiernan wrote:
> We should reference `cargo-update-recipe-crates` here rather than
> `cargo bitbake`. The flow for creating a recipe then goes something
> like (using hippotat as an example
> https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
>
> devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
> hippotat https://salsa.debian.org/iwj/hippotat.git
> # edit resulting recipe delete boiler plate tasks and add `inherit
> cargo cargo-update-recipe-crates`
> bitbake -c update_crates hippotat
> # edit recipe to add `require ${BPN}-crates.inc`
> devtool build hippotat
> # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
> pkgconfig` in this case)
> devtool build hippotat


I did just that, but "devtool build hippotat" failed:

<<<

NOTE: hippotat: compiling from external source tree 
/home/mike/work/yocto/poky/build/workspace/sources/hippotat
ERROR: hippotat-1.1.7+git999-r0 do_compile: oe_runmake failed
ERROR: hippotat-1.1.7+git999-r0 do_compile: 
ExecutionError('/home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/run.do_compile.14532', 
1, None, None)
ERROR: Logfile of failure stored in: 
/home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/log.do_compile.14532
Log data follows:
| DEBUG: Executing python function externalsrc_compile_prefunc
| NOTE: hippotat: compiling from external source tree 
/home/mike/work/yocto/poky/build/workspace/sources/hippotat
| DEBUG: Python function externalsrc_compile_prefunc finished
| DEBUG: Executing shell function do_compile
| NOTE: make -j 20
| cargo build --release  --workspace
| rm -rf docs/html
| sphinx-build -M html docs docs
| /bin/bash: line 1: sphinx-build: command not found
| make: *** [Makefile:68: docs/html/index.html] Error 127
| make: *** Waiting for unfinished jobs....
|     Updating crates.io index
| warning: spurious network error (2 tries remaining): failed to resolve 
address for github.com: Name or service not known; class=Net (12)
| warning: spurious network error (1 tries remaining): failed to resolve 
address for github.com: Name or service not known; class=Net (12)
| error: Unable to update registry `crates-io`
|
| Caused by:
|   failed to fetch `https://github.com/rust-lang/crates.io-index`
|
| Caused by:
|   network failure seems to have happened
|   if a proxy or similar is necessary `net.git-fetch-with-cli` may help 
here
| 
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
|
| Caused by:
|   failed to resolve address for github.com: Name or service not known; 
class=Net (12)
| make: *** [Makefile:52: stamp/cargo-build] Error 101
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
ERROR: Task 
(/home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile) 
failed with exit code '1'
NOTE: Tasks Summary: Attempted 739 tasks of which 731 didn't need to be 
rerun and 1 failed.

Summary: 1 task failed:
/home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile
Summary: There was 1 WARNING message.
Summary: There were 2 ERROR messages, returning a non-zero exit code.

 >>>

I did try to add BB_NO_NETWORK = "0" to conf/local.conf but it didn't help.
Any clues?

Maybe we could use an example that's simpler to build and with fewer 
dependencies...
Cheers
Michael.
Michael Opdenacker Feb. 3, 2023, 9:42 a.m. UTC | #11
Hi again Alex (Kiernan),

On 02.02.23 at 19:06, Michael Opdenacker wrote:
> Hi Alex,
>
> I tried the example you gave to use the "cargo-update-recipe-crates" 
> class.
>
> On 15.01.23 at 21:03, Alex Kiernan wrote:
>> We should reference `cargo-update-recipe-crates` here rather than
>> `cargo bitbake`. The flow for creating a recipe then goes something
>> like (using hippotat as an example
>> https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
>>
>> devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
>> hippotat https://salsa.debian.org/iwj/hippotat.git
>> # edit resulting recipe delete boiler plate tasks and add `inherit
>> cargo cargo-update-recipe-crates`
>> bitbake -c update_crates hippotat
>> # edit recipe to add `require ${BPN}-crates.inc`
>> devtool build hippotat
>> # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
>> pkgconfig` in this case)
>> devtool build hippotat
>
>
> I did just that, but "devtool build hippotat" failed:
>
> <<<
>
> NOTE: hippotat: compiling from external source tree 
> /home/mike/work/yocto/poky/build/workspace/sources/hippotat
> ERROR: hippotat-1.1.7+git999-r0 do_compile: oe_runmake failed
> ERROR: hippotat-1.1.7+git999-r0 do_compile: 
> ExecutionError('/home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/run.do_compile.14532', 
> 1, None, None)
> ERROR: Logfile of failure stored in: 
> /home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/log.do_compile.14532
> Log data follows:
> | DEBUG: Executing python function externalsrc_compile_prefunc
> | NOTE: hippotat: compiling from external source tree 
> /home/mike/work/yocto/poky/build/workspace/sources/hippotat
> | DEBUG: Python function externalsrc_compile_prefunc finished
> | DEBUG: Executing shell function do_compile
> | NOTE: make -j 20
> | cargo build --release  --workspace
> | rm -rf docs/html
> | sphinx-build -M html docs docs
> | /bin/bash: line 1: sphinx-build: command not found
> | make: *** [Makefile:68: docs/html/index.html] Error 127
> | make: *** Waiting for unfinished jobs....
> |     Updating crates.io index
> | warning: spurious network error (2 tries remaining): failed to 
> resolve address for github.com: Name or service not known; class=Net (12)
> | warning: spurious network error (1 tries remaining): failed to 
> resolve address for github.com: Name or service not known; class=Net (12)
> | error: Unable to update registry `crates-io`
> |
> | Caused by:
> |   failed to fetch `https://github.com/rust-lang/crates.io-index`
> |
> | Caused by:
> |   network failure seems to have happened
> |   if a proxy or similar is necessary `net.git-fetch-with-cli` may 
> help here
> | 
> https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
> |
> | Caused by:
> |   failed to resolve address for github.com: Name or service not 
> known; class=Net (12)
> | make: *** [Makefile:52: stamp/cargo-build] Error 101
> | ERROR: oe_runmake failed
> | WARNING: exit code 1 from a shell command.
> ERROR: Task 
> (/home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile) 
> failed with exit code '1'
> NOTE: Tasks Summary: Attempted 739 tasks of which 731 didn't need to 
> be rerun and 1 failed.
>
> Summary: 1 task failed:
> /home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile 
>
> Summary: There was 1 WARNING message.
> Summary: There were 2 ERROR messages, returning a non-zero exit code.
>
> >>>
>
> I did try to add BB_NO_NETWORK = "0" to conf/local.conf but it didn't 
> help.
> Any clues?
>
> Maybe we could use an example that's simpler to build and with fewer 
> dependencies...
> Cheers
> Michael.


I tried with uutils too (we have it in meta-oe), and I also get 
networking errors. It seems that Cargo is trying to connect to the 
network at build time.

Trying "cargo bitbake" on uutils was so much easier (just checkout the 
tag / commit you want in the git repository, run "cargo bitbake" and you 
get a recipe that builds just fine).

 From the example instructions you gave, devtool didn't even realize 
that the recipe was meant to be built with Cargo. How could it?

So, I'd rather document a workflow that's by far the easiest, even if 
that's not something officially supported by the Yocto Project.

Cheers
Michael.
Alex Kiernan Feb. 3, 2023, 12:06 p.m. UTC | #12
On Fri, Feb 3, 2023 at 9:42 AM Michael Opdenacker
<michael.opdenacker@bootlin.com> wrote:
>
> Hi again Alex (Kiernan),
>
> On 02.02.23 at 19:06, Michael Opdenacker wrote:
> > Hi Alex,
> >
> > I tried the example you gave to use the "cargo-update-recipe-crates"
> > class.
> >
> > On 15.01.23 at 21:03, Alex Kiernan wrote:
> >> We should reference `cargo-update-recipe-crates` here rather than
> >> `cargo bitbake`. The flow for creating a recipe then goes something
> >> like (using hippotat as an example
> >> https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/):
> >>
> >> devtool add -S a6ac94b4922602af64f22b86ba5347ad95fcda44 -V 1.1.7
> >> hippotat https://salsa.debian.org/iwj/hippotat.git
> >> # edit resulting recipe delete boiler plate tasks and add `inherit
> >> cargo cargo-update-recipe-crates`
> >> bitbake -c update_crates hippotat
> >> # edit recipe to add `require ${BPN}-crates.inc`
> >> devtool build hippotat
> >> # fix resulting errors (add `DEPENDS += "openssl"`, `inherit
> >> pkgconfig` in this case)
> >> devtool build hippotat
> >
> >
> > I did just that, but "devtool build hippotat" failed:
> >
> > <<<
> >
> > NOTE: hippotat: compiling from external source tree
> > /home/mike/work/yocto/poky/build/workspace/sources/hippotat
> > ERROR: hippotat-1.1.7+git999-r0 do_compile: oe_runmake failed
> > ERROR: hippotat-1.1.7+git999-r0 do_compile:
> > ExecutionError('/home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/run.do_compile.14532',
> > 1, None, None)
> > ERROR: Logfile of failure stored in:
> > /home/mike/work/yocto/poky/build/tmp/work/core2-64-poky-linux/hippotat/1.1.7+git999-r0/temp/log.do_compile.14532
> > Log data follows:
> > | DEBUG: Executing python function externalsrc_compile_prefunc
> > | NOTE: hippotat: compiling from external source tree
> > /home/mike/work/yocto/poky/build/workspace/sources/hippotat
> > | DEBUG: Python function externalsrc_compile_prefunc finished
> > | DEBUG: Executing shell function do_compile
> > | NOTE: make -j 20
> > | cargo build --release  --workspace
> > | rm -rf docs/html
> > | sphinx-build -M html docs docs
> > | /bin/bash: line 1: sphinx-build: command not found
> > | make: *** [Makefile:68: docs/html/index.html] Error 127
> > | make: *** Waiting for unfinished jobs....
> > |     Updating crates.io index
> > | warning: spurious network error (2 tries remaining): failed to
> > resolve address for github.com: Name or service not known; class=Net (12)
> > | warning: spurious network error (1 tries remaining): failed to
> > resolve address for github.com: Name or service not known; class=Net (12)
> > | error: Unable to update registry `crates-io`
> > |
> > | Caused by:
> > |   failed to fetch `https://github.com/rust-lang/crates.io-index`
> > |
> > | Caused by:
> > |   network failure seems to have happened
> > |   if a proxy or similar is necessary `net.git-fetch-with-cli` may
> > help here
> > |
> > https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
> > |
> > | Caused by:
> > |   failed to resolve address for github.com: Name or service not
> > known; class=Net (12)
> > | make: *** [Makefile:52: stamp/cargo-build] Error 101
> > | ERROR: oe_runmake failed
> > | WARNING: exit code 1 from a shell command.
> > ERROR: Task
> > (/home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile)
> > failed with exit code '1'
> > NOTE: Tasks Summary: Attempted 739 tasks of which 731 didn't need to
> > be rerun and 1 failed.
> >
> > Summary: 1 task failed:
> > /home/mike/work/yocto/poky/build/workspace/recipes/hippotat/hippotat_git.bb:do_compile
> >
> > Summary: There was 1 WARNING message.
> > Summary: There were 2 ERROR messages, returning a non-zero exit code.
> >
> > >>>
> >
> > I did try to add BB_NO_NETWORK = "0" to conf/local.conf but it didn't
> > help.
> > Any clues?
> >
> > Maybe we could use an example that's simpler to build and with fewer
> > dependencies...
> > Cheers
> > Michael.
>
>
> I tried with uutils too (we have it in meta-oe), and I also get
> networking errors. It seems that Cargo is trying to connect to the
> network at build time.
>
> Trying "cargo bitbake" on uutils was so much easier (just checkout the
> tag / commit you want in the git repository, run "cargo bitbake" and you
> get a recipe that builds just fine).
>
>  From the example instructions you gave, devtool didn't even realize
> that the recipe was meant to be built with Cargo. How could it?
>

I suspect you missed this part:

# edit resulting recipe delete boiler plate tasks and add `inherit
cargo cargo-update-recipe-crates`

I've just pushed up this repo which I did step by step:

https://github.com/akiernan/hippotat-recipe

Though I can't argue its less straightforward than the `cargo bitbake`
approach - holding up my hands, so far we've only migrated one of our
rust recipes to update_crates.

> So, I'd rather document a workflow that's by far the easiest, even if
> that's not something officially supported by the Yocto Project.
>

Sorry, I did say I'd write something and I've not - the last couple of
weeks have disappeared into a load of other things.

Getting something in there, would clearly be an improvement!
Michael Opdenacker Feb. 3, 2023, 5:32 p.m. UTC | #13
Hi Alex,

Thanks for the feedback!

On 03.02.23 at 13:06, Alex Kiernan wrote:
>
> I suspect you missed this part:
>
> # edit resulting recipe delete boiler plate tasks and add `inherit
> cargo cargo-update-recipe-crates`
>
> I've just pushed up this repo which I did step by step:
>
> https://github.com/akiernan/hippotat-recipe
>
> Though I can't argue its less straightforward than the `cargo bitbake`
> approach - holding up my hands, so far we've only migrated one of our
> rust recipes to update_crates.


I believe I did that, but now I have your recipe to compare with mine. 
Maybe a basic mistake somewhere :)

>
>> So, I'd rather document a workflow that's by far the easiest, even if
>> that's not something officially supported by the Yocto Project.
>>
> Sorry, I did say I'd write something and I've not - the last couple of
> weeks have disappeared into a load of other things.

No problem, I'm also here to take the raw input from people and turn it 
into docs.

Thanks again
Cheers
Michael.
diff mbox series

Patch

diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
index 0cb507b500..cc6ba04bff 100644
--- a/documentation/ref-manual/classes.rst
+++ b/documentation/ref-manual/classes.rst
@@ -254,6 +254,42 @@  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 <https://doc.rust-lang.org/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 an ``src``
+subdirectory.
+
+You will find a simple example in the
+:oe_git:`rust-hello-world_git.bb </openembedded-core/tree/meta/recipes-extended/rust-example/rust-hello-world_git.bb>`
+recipe. A more complex example, with package dependencies, is the
+:oe_git:`uutils-coreutils </meta-openembedded/tree/meta-oe/recipes-core/uutils-coreutils>`
+recipe, which was generated by the `cargo-bitbake <https://crates.io/crates/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:
 
 ``ccache``
@@ -2493,6 +2529,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``