diff mbox series

rust-cross-canadian: rename shell variables for easier appends

Message ID 20220823110227.68348-1-peter@berginkonsult.se
State Accepted, archived
Commit 74307f57ad0b3c538be0add11028e4e6199a7662
Headers show
Series rust-cross-canadian: rename shell variables for easier appends | expand

Commit Message

Peter Bergin Aug. 23, 2022, 11:02 a.m. UTC
Make unique shell variable names for cargo and rust
setup scripts. This change will make it easier to append to the
scripts in a bbappend file by using the variable for the script.
Before this change it was only possible for the last script as
they shared the same variable name.

Signed-off-by: Peter Bergin <peter@berginkonsult.se>
---
 meta/recipes-devtools/rust/rust-cross-canadian.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Otavio Salvador Aug. 23, 2022, 2:03 p.m. UTC | #1
Em ter., 23 de ago. de 2022 às 08:02, Peter Bergin <peter@berginkonsult.se>
escreveu:

> Make unique shell variable names for cargo and rust
> setup scripts. This change will make it easier to append to the
> scripts in a bbappend file by using the variable for the script.
> Before this change it was only possible for the last script as
> they shared the same variable name.
>
> Signed-off-by: Peter Bergin <peter@berginkonsult.se>
>

Why do you want to append them?
Peter Bergin Aug. 23, 2022, 8:38 p.m. UTC | #2
Hi Otavio,

On 2022-08-23 16:03, Otavio Salvador wrote:
>
>
> Em ter., 23 de ago. de 2022 às 08:02, Peter Bergin 
> <peter@berginkonsult.se> escreveu:
>
>     Make unique shell variable names for cargo and rust
>     setup scripts. This change will make it easier to append to the
>     scripts in a bbappend file by using the variable for the script.
>     Before this change it was only possible for the last script as
>     they shared the same variable name.
>
>     Signed-off-by: Peter Bergin <peter@berginkonsult.se>
>
>
> Why do you want to append them?

In my particular case the rust application I'm building against the SDK 
is using the crate prost-build (https://crates.io/crates/prost-build) 
that is used to generate code from .proto files. It is using the tool 
protoc from protobuf and in order to get it working the variable PROTOC 
needs to be set. Then my solution was to add that variable to 
environment-setup.d/rust.sh in the SDK as I thought that was an easy 
solution and rust.sh is in some way connected to the variable setting. 
Then looking in to do_install of rust-cross-canadian I saw that the 
variable ENV_SETUP_SH is first used for rust.sh then for cargo.sh so I 
could not use it to point out rust.sh. Then I had the idea that it would 
be better to have one variable for rust.sh and one for cargo.sh.

No strong opinion if this is a good solution or not. I can find other 
solutions of course. If this break things for other people I hope it 
will not be accepted. Just wanted to share if it can also help others.

Best regards,
/Peter
Otavio Salvador Aug. 23, 2022, 9:32 p.m. UTC | #3
Em ter., 23 de ago. de 2022 às 17:38, Peter Bergin <peter@berginkonsult.se>
escreveu:

> In my particular case the rust application I'm building against the SDK is
> using the crate prost-build (https://crates.io/crates/prost-build) that
> is used to generate code from .proto files. It is using the tool protoc
> from protobuf and in order to get it working the variable PROTOC needs to
> be set. Then my solution was to add that variable to
> environment-setup.d/rust.sh in the SDK as I thought that was an easy
> solution and rust.sh is in some way connected to the variable setting. Then
> looking in to do_install of rust-cross-canadian I saw that the variable
> ENV_SETUP_SH is first used for rust.sh then for cargo.sh so I could not use
> it to point out rust.sh. Then I had the idea that it would be better to
> have one variable for rust.sh and one for cargo.sh.
>
The protoc could have this set in environment-setup.d so it doesn't need
change in rust and avoids rebuilds.
Peter Bergin Aug. 24, 2022, 6:16 a.m. UTC | #4
On 2022-08-23 23:32, Otavio Salvador wrote:
>
>
> Em ter., 23 de ago. de 2022 às 17:38, Peter Bergin 
> <peter@berginkonsult.se> escreveu:
>
>     In my particular case the rust application I'm building against
>     the SDK is using the crate prost-build
>     (https://crates.io/crates/prost-build) that is used to generate
>     code from .proto files. It is using the tool protoc from protobuf
>     and in order to get it working the variable PROTOC needs to be
>     set. Then my solution was to add that variable to
>     environment-setup.d/rust.sh in the SDK as I thought that was an
>     easy solution and rust.sh is in some way connected to the variable
>     setting. Then looking in to do_install of rust-cross-canadian I
>     saw that the variable ENV_SETUP_SH is first used for rust.sh then
>     for cargo.sh so I could not use it to point out rust.sh. Then I
>     had the idea that it would be better to have one variable for
>     rust.sh and one for cargo.sh.
>
> The protoc could have this set in environment-setup.d so it doesn't 
> need change in rust and avoids rebuilds.
>
Yes. As I wrote there are many different solutions to my problem. In 
this patch I just wanted to share in what I think an improvement for a 
recipe.

/Peter
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
index 77d45a37a31..7bf75a4712e 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
@@ -37,17 +37,17 @@  do_install () {
 
     ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d
     mkdir "${ENV_SETUP_DIR}"
-    ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
+    RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
 
-    cat <<- EOF > "${ENV_SETUP_SH}"
+    cat <<- EOF > "${RUST_ENV_SETUP_SH}"
 	export RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT"
 	export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib"
 	EOF
 
     chown -R root.root ${D}
 
-    ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh"
-    cat <<- EOF > "${ENV_SETUP_SH}"
+    CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh"
+    cat <<- EOF > "${CARGO_ENV_SETUP_SH}"
 	export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo"
 	mkdir -p "\$CARGO_HOME"
         # Init the default target once, it might be otherwise user modified.