Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rust Environment module #848

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions docs/user/features/rust_environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Rust Environment Helpers

## About Rust Environment Helpers

Firmware developer's machines are often not setup for Rust. As more Rust code is proliferating across the repos, this
code can be used to provide early and direct feedback about the developer's environment so it can successfully build
Rust code using the tools commonly used in the firmware build process.

## Usage

The primary purpose of the functionality in `rust_environment` is to be used in a build plugin wrapper. However, the
public functions may be used in other contexts as well. The following functions are available:

- `run()` - Checks the current environment for Rust build support.
- The checks can be customized with the `custom_tool_checks` and `custom_tool_filters` parameters.
- `get_workspace_toolchain_version()` - Returns the rust toolchain version specified in the workspace toolchain file.
- `verify_workspace_rust_toolchain_is_installed()` - RVerifies the rust toolchain used in the workspace is available.
makubacki marked this conversation as resolved.
Show resolved Hide resolved

### Integration Examples

This section provides examples of how to use the functions available in `edk2toolext/codeql.py`.
makubacki marked this conversation as resolved.
Show resolved Hide resolved

#### `run()`

Call to check the environment for Rust build support:

```python
import edk2toolext.rust_environment as rust_env

def Run(self):
rust_env.run()
makubacki marked this conversation as resolved.
Show resolved Hide resolved
```

#### `get_workspace_toolchain_version()`

Call to get Rust toolchain info:

```python
import edk2toolext.rust_environment as rust_env

def GetWorkspaceToolchainVersion(self):
toolchain = rust_env.get_workspace_toolchain_version()
print(f"Workspace toolchain version: {toolchain_version.toolchain}")
```

#### `verify_workspace_rust_toolchain_is_installed()`

Call to verify the workspace specified toolchain is installed:

```python
import edk2toolext.rust_environment as rust_env

def VerifyWorkspaceRustToolchainIsInstalled(self):
rust_toolchain_info = verify_workspace_rust_toolchain_is_installed()
if rust_toolchain_info.error:
print(f"Error: {rust_toolchain_info.error}")
else:
print(f"Rust toolchain is installed: {rust_toolchain_info.toolchain}")
```
Loading