You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by yu...@apache.org on 2023/04/24 03:03:43 UTC
[incubator-teaclave-trustzone-sdk] 05/06: Rework rustup/toolchain installation
This is an automated email from the ASF dual-hosted git repository.
yuanz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit a2b7bb078e14da856b382bdcbe6dcd8590032331
Author: Thomas Hebb <tc...@meta.com>
AuthorDate: Fri Apr 21 15:32:33 2023 -0400
Rework rustup/toolchain installation
Migrate "rust-toolchain", which sets a rustup toolchain override for the
directory, to the newer "rust-toolchain.toml" format[1] and rewrite the
toolchain-related logic in setup.sh. This has several benefits:
- If the user already has rustup installed, we won't run the
installation script again. That prevents us from messing with
environments that set the rustup $PATH in a non-default way.
- We no longer change rustup's system-wide default toolchain, which
similarly prevents us from messing with the user's environment.
- Thanks to the expanded capabilities of rust-toolchain.toml, users who
build without first running "setup.sh" will get the components and
targets they need in addition to the toolchain itself.
- We now have a single source of truth for our preferred toolchain.
setup.sh now just installs whatever's in rust-toolchain.toml instead
of hardcoding a toolchain name.
[1] https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
---
.licenserc.yaml | 1 -
rust-toolchain | 1 -
.licenserc.yaml => rust-toolchain.toml | 24 +++++-------------------
setup.sh | 22 +++++++++++++++-------
4 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/.licenserc.yaml b/.licenserc.yaml
index ccce5cc..c65f735 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -26,7 +26,6 @@ header:
- '**/*.md'
- 'LICENSE'
- 'NOTICE'
- - 'rust-toolchain'
- '**/Cargo.lock'
- '**/*.lds'
- 'aarch64-unknown-optee-trustzone.json'
diff --git a/rust-toolchain b/rust-toolchain
deleted file mode 100644
index 513fbad..0000000
--- a/rust-toolchain
+++ /dev/null
@@ -1 +0,0 @@
-nightly-2021-09-20
diff --git a/.licenserc.yaml b/rust-toolchain.toml
similarity index 64%
copy from .licenserc.yaml
copy to rust-toolchain.toml
index ccce5cc..d482968 100644
--- a/.licenserc.yaml
+++ b/rust-toolchain.toml
@@ -15,23 +15,9 @@
# specific language governing permissions and limitations
# under the License.
-header:
- license:
- spdx-id: Apache-2.0
- copyright-owner: Apache Software Foundation
+# Toolchain override for rustup
- paths-ignore:
- - 'dist'
- - 'licenses'
- - '**/*.md'
- - 'LICENSE'
- - 'NOTICE'
- - 'rust-toolchain'
- - '**/Cargo.lock'
- - '**/*.lds'
- - 'aarch64-unknown-optee-trustzone.json'
- - 'arm-unknown-optee-trustzone.json'
- - 'KEYS'
- - 'DISCLAIMER-WIP'
- - '.gitmodules'
- - 'examples/tls_server-rs/ta/test-ca/**'
+[toolchain]
+channel = "nightly-2021-09-20"
+components = ["rust-src"]
+targets = ["aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabihf"]
diff --git a/setup.sh b/setup.sh
index 4f8586a..50030b9 100755
--- a/setup.sh
+++ b/setup.sh
@@ -24,15 +24,23 @@ set -xe
cd "$(dirname "$0")"
##########################################
-# install Rust and select a proper version
-curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2021-09-20
-source $HOME/.cargo/env
-rustup component add rust-src && rustup target install aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf
+# install rustup and stable Rust if needed
+if command -v rustup &>/dev/null ; then
+ rustup install stable
+else
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+ source "$HOME/.cargo/env"
+fi
+
+# Ensure the toolchain, components, and targets we've specified in
+# rust-toolchain.toml are ready to go. Since that file sets rustup's default
+# toolchain for the entire directory, all we need to do is run any
+# rustup-wrapped command to trigger installation. We've arbitrarily chosen
+# "cargo --version" since it has no other effect.
+cargo --version >/dev/null
# install Xargo
-rustup default 1.56.0 && cargo +1.56.0 install xargo
-# switch to nightly
-rustup default nightly-2021-09-20
+cargo +stable install xargo
########################################################
# initialize submodules: optee_os / optee_client / build
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org