-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Rust infrastructure files
Adds workspace level files to build Rust in the repo. Signed-off-by: Michael Kubacki <[email protected]>
- Loading branch information
Showing
4 changed files
with
76 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
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,49 @@ | ||
[config] | ||
default_to_workspace = false | ||
|
||
[env] | ||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true | ||
RUSTC_BOOTSTRAP = 1 | ||
ARCH = "X64" | ||
TARGET_TRIPLE = { source = "${ARCH}", mapping = { "X64" = "x86_64-unknown-uefi", "IA32" = "i686-unknown-uefi", "AARCH64" = "aarch64-unknown-uefi", "LOCAL" = "${CARGO_MAKE_RUST_TARGET_TRIPLE}" }, condition = { env_not_set = [ "TARGET_TRIPLE" ] } } | ||
PACKAGE_TARGET = {value = "-p ${CARGO_MAKE_TASK_ARGS}",condition = { env_true = [ "CARGO_MAKE_TASK_ARGS", ] } } | ||
|
||
BUILD_FLAGS = "--profile ${RUSTC_PROFILE} --target ${TARGET_TRIPLE} -Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem -Zunstable-options --timings=html" | ||
TEST_FLAGS = { value = "", condition = { env_not_set = ["TEST_FLAGS"] } } | ||
COV_FLAGS = { value = "--out Html --exclude-files **/tests/*", condition = { env_not_set = ["COV_FLAGS"] } } | ||
|
||
[env.development] | ||
RUSTC_PROFILE = "dev" | ||
RUSTC_TARGET = "debug" | ||
|
||
[env.release] | ||
RUSTC_PROFILE = "release" | ||
RUSTC_TARGET = "release" | ||
|
||
[tasks.build] | ||
description = """Builds a single rust package. | ||
Customizations: | ||
-p [development|release]: Builds in debug or release. Default: development | ||
-e ARCH=[IA32|X64|AARCH64|LOCAL]: Builds with specifed arch. Default: X64 | ||
Example: | ||
`cargo make build RustModule` | ||
`cargo make -p release build RustModule` | ||
`cargo make -e ARCH=IA32 build RustLib` | ||
""" | ||
clear = true | ||
command = "cargo" | ||
args = ["build", "@@split(PACKAGE_TARGET, )", "@@split(BUILD_FLAGS, )"] | ||
|
||
[tasks.test] | ||
description = "Builds all rust tests in the workspace. Example `cargo make test`" | ||
clear = true | ||
command = "cargo" | ||
args = ["test", "@@split(PACKAGE_TARGET, )", "@@split(TEST_FLAGS, )"] | ||
|
||
[tasks.coverage] | ||
description = "Build and run all tests and calculate coverage." | ||
clear = true | ||
command = "cargo" | ||
args = ["tarpaulin", "@@split(PACKAGE_TARGET, )", "@@split(COV_FLAGS, )", "--output-dir", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target"] |
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,2 @@ | ||
[toolchain] | ||
channel = "1.71.1" |
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,21 @@ | ||
# rustfmt (and cargo fmt) will automatically pick up this config when run in the workspace. | ||
|
||
# Note that some items are included here set to their default values. This is to explicitly | ||
# reveal settings for more common options. | ||
|
||
# Keep these options sorted in ascending order to ease lookup with rustfmt documentation. | ||
|
||
edition = "2021" # This would normally be picked up from Cargo.toml if not specified here | ||
force_explicit_abi = true # Always print the ABI for extern items (e.g. extern {... will become extern "C" {...) | ||
hard_tabs = false # Always uses spaces for indentation and alignment | ||
max_width = 120 # The maximum width of each line | ||
merge_derives = false # Do not merge derives into a single line (leave to author discretion). | ||
imports_granularity = "Crate" # Merge imports from a single crate into separate statements. | ||
newline_style = "Windows" # Always use Windows line endings '\r\n' | ||
reorder_impl_items = false # Do not force where type and const before macros and methods in impl blocks. | ||
reorder_imports = true # Do reorder import and extern crate statements alphabetically for readability. | ||
reorder_modules = true # Do reorder mod declarations alphabetically for readability. | ||
tab_spaces = 2 # Use 2 spaces for indentation (Rust default is 4). | ||
unstable_features = false # Do not use unstable rustfmt features. | ||
use_small_heuristics = "Max" # Set all granular width settings to the same as max_width (do not use heuristics) | ||
wrap_comments = false # Leave comment formatting to author's discretion |