-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds helpers for checking if a firmare environment is ready to build Rust. 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. Signed-off-by: Michael Kubacki <[email protected]>
- Loading branch information
Showing
3 changed files
with
908 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
### Integration Examples | ||
|
||
This section provides examples of how to use the functions available in `edk2toolext/codeql.py`. | ||
|
||
#### `run()` | ||
|
||
Call to check the environment for Rust build support: | ||
|
||
```python | ||
import edk2toolext.rust_environment as rust_env | ||
|
||
def Run(self): | ||
rust_env.run() | ||
``` | ||
|
||
#### `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}") | ||
``` |
Oops, something went wrong.