Skip to contentSkip to conversation

ref-manual: document Rust classes

PATCH Superseded [email protected] 5 participants 14 messages Jan 13, 2023 – Feb 3, 2023 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ref-manual: document Rust classes

From: Michael Opdenacker <[email protected]>

---
 documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +54 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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``
Signature · 1 line
2.37.2
#1 lore raw
Quoted 28 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

---
 documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +12 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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

documentation/ref-manual/classes.rst When inherited globally, prints statistics at the end of the build on · line 278

Quoted 10 lines
documentation/ref-manual/classes.rst +10 -0
+``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

#2 lore raw

Perhaps you could write a patch to the docs that sets them right?

Alex

Quoted 62 lines · Alex Kiernan
Quoted 28 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

---
 documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +12 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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

documentation/ref-manual/classes.rst When inherited globally, prints statistics at the end of the build on · line 278

Quoted 10 lines
documentation/ref-manual/classes.rst +10 -0
+``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

#3 lore raw
In reply to Alex Kiernan

Hi Alex,

Quoted 47 lines · Alex Kiernan
Quoted 27 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

---
  documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
  1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +12 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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

documentation/ref-manual/classes.rst When inherited globally, prints statistics at the end of the build on · line 278

Quoted 10 lines
documentation/ref-manual/classes.rst +10 -0
+``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

Quoted 8 lines
# 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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw
Quoted 61 lines · Michael Opdenacker

Hi Alex,

Quoted 47 lines · Alex Kiernan
Quoted 27 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

---
  documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
  1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +12 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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

documentation/ref-manual/classes.rst When inherited globally, prints statistics at the end of the build on · line 278

Quoted 10 lines
documentation/ref-manual/classes.rst +10 -0
+``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

Quoted 8 lines
# 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
Quoted 2 lines

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.

Signature · 1 line
Alex Kiernan
#5 lore raw
In reply to Alex Kiernan

Hi Alex,

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

Quoted 7 lines · Alex Kiernan

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

Quoted 8 lines
# 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.

Quoted 1 line
Quoted 1 line
Quoted 1 line

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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

Hi again Alex (Kiernan),

Quoted 71 lines · Michael Opdenacker

Hi Alex,

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

Quoted 7 lines · Alex Kiernan

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

Quoted 8 lines
# 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.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 6 lines

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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw
Quoted 103 lines · Michael Opdenacker

Hi again Alex (Kiernan),

Quoted 85 lines · Michael Opdenacker

Hi Alex,

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

Quoted 7 lines · Alex Kiernan

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

Quoted 8 lines
# 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.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines

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.

Quoted 7 lines

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.

Quoted 3 lines

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!

Signature · 1 line
Alex Kiernan
#8 lore raw

Hi Alex,

Thanks for the feedback!

Quoted 6 lines · Alex Kiernan

I suspect you missed this part:

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

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 :)

Quoted 6 lines
Quoted 4 lines

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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#9 lore raw
In reply to [email protected]

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.

Quoted 18 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

---
 documentation/ref-manual/classes.rst | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
documentation/ref-manual/classes.rst +3 -0
index 0cb507b500..cc6ba04bff 100644
@@ -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``

documentation/ref-manual/classes.rst When inherited globally, prints statistics at the end of the build on · line 269

Quoted 10 lines
documentation/ref-manual/classes.rst +10 -0
+=========
+
+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

Quoted 51 lines
documentation/ref-manual/classes.rst +41 -0
+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``
Signature · 4 lines
Pengutronix e.K.                           | Ulrich Ölmann               |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#10 lore raw

Hi Ulrich,

Quoted 4 lines · Ulrich Ölmann

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 ;-)

Quoted 1 line

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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#11 lore raw
Quoted 15 lines · Michael Opdenacker via lists.yoctoproject.org

Hi Ulrich,

Quoted 4 lines · Ulrich Ölmann

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 ;-)

Quoted 1 line

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

Quoted 7 lines

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw
Quoted 20 lines · Richard Purdie via lists.yoctoproject.org
Quoted 18 lines · Michael Opdenacker via lists.yoctoproject.org

Hi Ulrich,

Quoted 4 lines · Ulrich Ölmann

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 ;-)

Quoted 1 line

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".

Quoted 7 lines
Quoted 4 lines

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

#14 lore raw
Quoted 7 lines · Richard Purdie
Quoted 7 lines
Quoted 7 lines

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!

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com