Skip to content

Commit

Permalink
add setup.sh to setup rust environment and initialize rust submodule (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fanrong1992 authored Sep 8, 2021
1 parent 03cfbb2 commit 7668004
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
38 changes: 15 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ and install building dependencies (The complete list of prerequisites can be fou
Alternatively, you can use a docker container built with our [Dockerfile](Dockerfile).

``` sh
# clone the project and initialize related submodules
$ git clone [email protected]:apache/incubator-teaclave-trustzone-sdk.git
$ cd incubator-teaclave-trustzone-sdk
$ git submodule update --init
$ (cd rust/compiler-builtins && git submodule update --init libm)
$ (cd rust/rust && git submodule update --init src/stdsimd)

# install dependencies
$ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
automake bc bison build-essential ccache cscope curl device-tree-compiler \
Expand All @@ -32,35 +25,34 @@ $ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
python3-pycryptodome python3-pyelftools python-serial python3-serial \
rsync unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev

# install Rust and select a proper version
$ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2019-07-08
$ source $HOME/.cargo/env
$ rustup component add rust-src && rustup target install aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf

# install Xargo
$ rustup default 1.44.0 && cargo +1.44.0 install xargo
# switch to nightly
$ rustup default nightly-2019-07-08
# clone the project
$ git clone [email protected]:apache/incubator-teaclave-trustzone-sdk.git
$ cd incubator-teaclave-trustzone-sdk
# initialize related submodules and install Rust environment
$ ./setup.sh
```

Before building examples, the environment should be properly setup.

By default, the `OPTEE_DIR` is `incubator-teaclave-trustzone-sdk/optee/`.
``` sh
$ source environment
# initialize OP-TEE submodule
$ git submodule update --init -- optee
```

By default, the `OPTEE_DIR` is `incubator-teaclave-trustzone-sdk/optee/`.
If you already have [OP-TEE repository](https://github.com/OP-TEE)
cloned, you can set OP-TEE root directory before source environment:
cloned, you can set OP-TEE root directory:

``` sh
$ export OPTEE_DIR=path/to/your/optee/root/directory
$ source environment
```

Note that your OPTEE root directory should have `build/`, `optee_os/` and
`optee_client/` as sub-directory.

Before building examples, the environment should be properly setup.

``` sh
$ source environment
```

By default, the target platform is `aarch64`. If you want to build for the `arm`
target, you can setup `ARCH` before source the environment like this:

Expand Down
33 changes: 33 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# install Rust and select a proper version
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2019-07-08
source $HOME/.cargo/env
rustup component add rust-src && rustup target install aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf

# install Xargo
rustup default 1.44.0 && cargo +1.44.0 install xargo
# switch to nightly
rustup default nightly-2019-07-08

# initialize Teaclave TrustZone SDK submodule
git submodule update --init -- rust
cd rust/compiler-builtins && git submodule update --init libm
cd ../rust && git submodule update --init src/stdsimd

0 comments on commit 7668004

Please sign in to comment.