diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000000..44d54525d8 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,52 @@ +[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", 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] +disabled = true + +[tasks.cov] +description = "Build and run all tests and calculate coverage." +clear = true +command = "cargo" +args = ["tarpaulin", "@@split(PACKAGE_TARGET, )", "@@split(COV_FLAGS, )", "--exclude-files", "**/tests/*", "--output-dir", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target"] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..f15049ea9d --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,6 @@ +[toolchain] +channel = "1.76.0" + +[tool] +cargo-make = "0.37.9" +cargo-tarpaulin = "0.27.3" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000..3d1b2d8554 --- /dev/null +++ b/rustfmt.toml @@ -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 specify settings for +# more common options. + +# Keep these options sorted in ascending order to ease lookup against 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