Skip to content

Commit

Permalink
Add development tips to use IDEs (RLS/rust-analyzer) (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Jun 16, 2020
1 parent e232e51 commit d9f91f1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ cov_report
# ignore the build dir which usually for cmake
/build
/release
/Cargo.toml
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ platform, making computation on privacy-sensitive data safe and simple.
- [Access Control](docs/access-control.md)
- [Build System](docs/build-system.md)

### Contribute to Teaclave

- [Rust Development Guideline](docs/rust-guideline.md)
- [Development Tips](docs/development-tips.md)

### Codebase

- [Attestation](attestation)
Expand Down
2 changes: 2 additions & 0 deletions cmake/tomls/Cargo.sgx_trusted_lib.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk", rev =
# sgx_tunittest = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_types = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_unwind = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_urts = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }

# SGX crates
# adler32 = { git = "https://github.com/mesalock-linux/adler32-rs-sgx" }
Expand All @@ -46,6 +47,7 @@ chrono = { git = "https://github.com/mesalock-linux/chrono-sgx" }
# deflate = { git = "https://github.com/mesalock-linux/deflate-rs-sgx", branch = "dev" }
gbdt = { git = "https://github.com/mesalock-linux/gbdt-rs", branch = "mesatee-sgx" }
getrandom = { git = "https://github.com/mesalock-linux/getrandom-sgx" }
crc = { git = "https://github.com/mesalock-linux/crc-rs-sgx" }
# gif = { git = "https://github.com/mesalock-linux/image-gif-sgx" }
# image = { git = "https://github.com/mesalock-linux/image-sgx" }
# inflate = { git = "https://github.com/mesalock-linux/inflate-sgx" }
Expand Down
2 changes: 2 additions & 0 deletions cmake/tomls/Cargo.sgx_untrusted_app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ exclude = [
# We cannot remove these crates, because proto crates depend on them
sgx_urts = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_types = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
sgx_trts = { git = "https://github.com/apache/teaclave-sgx-sdk", rev = "v1.1.2" }
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ permalink: /docs/
- [Mutual Attestation: Why and How](mutual-attestation.md)
- [My First Function](my-first-function.md)
- [Rust Development Guideline](rust-guideline.md)
- [Development Tips](development-tips.md)
- [Threat Model](threat-model.md)
29 changes: 29 additions & 0 deletions docs/development-tips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
permalink: /docs/development-tips
---

# Development Tips

## RLS/rust-analyzer and IDEs

The most common question on developing Teaclave is how to use Rust IDEs to
improve help the development, e.g., code completions, type hints and cross
references. Internally, these features are supported by either
[RLS](https://github.com/rust-lang/rls) or
[rust-analyzer](https://github.com/rust-analyzer/rust-analyzer). Unfortunately,
these features are not supported in Teaclave's codebase out-of-box.
The reason is that Teaclave has components targeting different environments (SGX
enclave and Linux app) which need different set of dependencies (SGX crates and
vanilla crates). To support this flexible building and linking process, we are
using cmake for our [build system](build-system.md). However, there are still
ways to workaround and let the analyzer understand the project structures.

When developing SGX enclaves and corresponding dependent crates, you need to
prepare a `Cargo.toml` in the root directory to help the analyzer. This
`Cargo.toml` file can be copied from our build system:
`cmake/tomls/Cargo.sgx_trusted_lib.toml`. Similarly, when developing the app
parts, you can copy the `cmake/tomls/Cargo.sgx_untrusted_lib.toml` file to the
root directory as `Cargo.toml`. For standalone Rust applications such as CLI, no
`Cargo.toml` is needed. After the preparation of `Cargo.toml` in root,
RLS/rust-analyzer can understand the projects finally. You will see type hints
and cross references using IDEs with extensions.

0 comments on commit d9f91f1

Please sign in to comment.