Skip to contentSkip to conversation

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

PATCH In review Peter Bergin 2 participants 5 messages Aug 23, 2022 – Aug 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust-cross-canadian: rename shell variables for easier appends

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.

---
 meta/recipes-devtools/rust/rust-cross-canadian.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-devtools/rust/rust-cross-canadian.inc +4 -4
index 77d45a37a31..7bf75a4712e 100644
@@ -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.
Signature · 1 line
2.34.1
#1 lore raw

Em ter., 23 de ago. de 2022 às 08:02, Peter Bergin <[email protected]> escreveu:

Quoted 8 lines

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.

Why do you want to append them?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
#2 lore raw

Hi Otavio,

Quoted 10 lines · Otavio Salvador

Em ter., 23 de ago. de 2022 às 08:02, Peter Bergin <[email protected]> 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.

Quoted 4 lines

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

#3 lore raw

Em ter., 23 de ago. de 2022 às 17:38, Peter Bergin <[email protected]> escreveu:

Quoted 12 lines

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.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
#4 lore raw
Quoted 18 lines · Otavio Salvador

Em ter., 23 de ago. de 2022 às 17:38, Peter Bergin <[email protected]> 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.

Quoted 2 lines

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