Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
171 changes: 71 additions & 100 deletions .sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ NO_STD_FLAGS = "--profile ${RUSTC_PROFILE} --timings"
# Note: `--profile test` has been set here in the past. Cargo already defaults to test builds
# with the test profile, so it is removed. cargo-llvm-cov will forward it to `cargo nextest run`
# where `--profile` is used to incorrectly select a nextest config profile (not a Cargo build profile).
COV_FLAGS = { value = "--workspace --ignore-filename-regex .*test.*", condition = { env_not_set = ["COV_FLAGS"] } }
# `--workspace` is intentionally not part of this value. It is supplied separately by the
# `cov-workspace-flag` task, which omits it when the command line provides arguments, because
# `--workspace` overrides `-p`.
COV_FLAGS = { value = "--ignore-filename-regex .*test.*", condition = { env_not_set = ["COV_FLAGS"] } }
RUSTDOCFLAGS = "-D warnings -D missing_docs"
# Selects the nextest `ci` profile (defined in .config/nextest.toml) automatically when the `CI`
# variable is set (e.g. GitHub Actions sets this for every job).
Expand Down Expand Up @@ -111,70 +114,48 @@ for line in ${lines}
end
'''

[tasks.individual-package-targets]
script_runner = "@duckscript"
script = '''
args = get_env CARGO_MAKE_TASK_ARGS

if is_empty ${args}
exit
end

1 = array ""
2 = split ${args} ,
3 = array_concat ${1} ${2}
joined_args = array_join ${3} " -p "
release ${1}
release ${2}
release ${3}

joined_args = trim ${joined_args}
set_env INDIVIDUAL_PACKAGE_TARGETS ${joined_args}
release ${joined_args}
'''

[tasks.check_code_x64]
description = "Checks rust code for x64 build errors with results."
private = true
command = "cargo"
args = ["check", "--target", "x86_64-unknown-uefi", "--features", "ci_features,x64", "@@split(CARGO_MAKE_TASK_ARGS, )", "@@split(NO_STD_FLAGS, )",]
args = ["check", "--target", "x86_64-unknown-uefi", "--features", "ci_features,x64", "@@split(CARGO_MAKE_TASK_ARGS,;)", "@@split(NO_STD_FLAGS, )",]

[tasks.check_code_aarch64]
description = "Checks rust code for aarch64 build errors with results."
private = true
command = "cargo"
args = ["check", "--target", "aarch64-unknown-uefi", "--features", "ci_features,aarch64", "@@split(CARGO_MAKE_TASK_ARGS, )", "@@split(NO_STD_FLAGS, )",]
args = ["check", "--target", "aarch64-unknown-uefi", "--features", "ci_features,aarch64", "@@split(CARGO_MAKE_TASK_ARGS,;)", "@@split(NO_STD_FLAGS, )",]

[tasks.check_tests]
description = "Checks rust test code for build errors with results."
private = true
command = "cargo"
args = ["nextest", "run", "--no-run", "--all-targets", "--all-features", "@@split(CARGO_MAKE_TASK_ARGS, )",]
args = ["nextest", "run", "--no-run", "--all-targets", "--all-features", "@@split(CARGO_MAKE_TASK_ARGS,;)",]

[tasks.check]
description = "Checks rust code for errors. Example `cargo make check`"
description = "Checks rust code for errors. Arguments are forwarded to `cargo check`/`cargo nextest`. Example `cargo make check` or `cargo make check -p qemu_dxe_core`"
clear = true
run_task = [{ name = ["check_code_x64", "check_code_aarch64", "check_tests"], parallel = true }]

[tasks.check-no-default-features-code]
description = "Checks rust code compiles without default features."
private = true
command = "cargo"
args = ["check", "--no-default-features", "@@split(CARGO_MAKE_TASK_ARGS, )"]
args = ["check", "--no-default-features", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.check-no-default-features-tests]
description = "Checks rust test code compiles without default features."
private = true
command = "cargo"
args = ["nextest", "run", "--no-run", "--no-default-features", "@@split(CARGO_MAKE_TASK_ARGS, )"]
args = ["nextest", "run", "--no-run", "--no-default-features", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.check-no-default-features]
description = "Checks rust code and tests compile without default features to catch feature-gate regressions."
clear = true
run_task = [{ name = ["check-no-default-features-code", "check-no-default-features-tests"], parallel = true }]

[tasks.test]
description = "Runs tests via cargo-nextest. Example `cargo make test` or `cargo make test -p package_name -- --nocapture`. In CI, also runs a second pass with the `ci_features` feature enabled to ensure tests do not depend on it being enabled."
description = "Runs tests via cargo-nextest. Arguments are forwarded to `cargo nextest run`. Example `cargo make test` or `cargo make test --no-capture`. In CI, also runs a second pass with the `ci_features` feature enabled to ensure tests do not depend on it being enabled."
clear = true
dependencies = ["test-default", "test-ci-features"]

Expand All @@ -191,8 +172,23 @@ condition = { env_set = ["CI"] }
command = "cargo"
args = ["nextest", "run", "--features", "ci_features", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.cov-workspace-flag]
description = """Sets `COV_WORKSPACE` to `--workspace` only when no arguments were given on the
command line. `--workspace` overrides `-p`, so it is dropped whenever any argument is given
(for example `cargo make coverage -p qemu_dxe_core`)."""
private = true
script_runner = "@duckscript"
script = '''
args = get_env CARGO_MAKE_TASK_ARGS
if is_empty ${args}
set_env COV_WORKSPACE "--workspace"
else
set_env COV_WORKSPACE ""
end
'''

[tasks.coverage-collect]
description = "Run tests and collect coverage data without generating reports."
description = "Run tests and collect coverage data without generating reports. Arguments are forwarded to `cargo llvm-cov nextest`."
install_crate = false
clear = true
# `coverage_attribute` is deliberately excluded from the default allow-features in
Expand All @@ -201,8 +197,8 @@ clear = true
# Note: RUSTFLAGS replaces build.rustflags.
env = { RUSTFLAGS = "-Z allow-features=c_variadic,allocator_api,coverage_attribute" }
command = "cargo"
args = ["llvm-cov", "@@split(COV_FLAGS, )", "--no-report", "nextest"]
dependencies = ["individual-package-targets"]
args = ["llvm-cov", "@@split(COV_WORKSPACE, )", "@@split(COV_FLAGS, )", "--no-report", "nextest", "@@split(CARGO_MAKE_TASK_ARGS,;)"]
dependencies = ["cov-workspace-flag"]

[tasks.coverage-lcov]
description = "Generate an LCOV coverage report from collected data."
Expand All @@ -219,7 +215,7 @@ command = "cargo"
args = ["llvm-cov", "report", "--html", "--output-dir", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/coverage"]

[tasks.coverage]
description = "Build and run all tests and calculate coverage (runs test once and generates LCOV and HTML reports). In CI, also runs a second pass with the `ci_features` feature enabled (outside of coverage collection) since only `cargo make coverage` is run in CI."
description = "Build and run all tests and calculate coverage (runs test once and generates LCOV and HTML reports). Arguments are forwarded to `cargo llvm-cov nextest`. Example `cargo make coverage -p qemu_dxe_core`. In CI, also runs a second pass with the `ci_features` feature enabled (outside of coverage collection) since only `cargo make coverage` is run in CI."
dependencies = ["coverage-collect", "coverage-lcov", "coverage-html", "test-ci-features"]
clear = true

Expand Down Expand Up @@ -510,127 +506,102 @@ env = { CARGO_BIN_NAME = "qemu_armvirt_dxe_core", "RUSTC_PROFILE" = "release", C
run_task = "patch"

[tasks.doc]
description = "Builds all rust documentation in the workspace. Example `cargo make doc`"
description = "Builds all rust documentation in the workspace. Arguments are forwarded to `cargo doc`. Example `cargo make doc` or `cargo make doc -p qemu_dxe_core`"
clear = true
command = "cargo"
args = ["doc", "@@split(INDIVIDUAL_PACKAGE_TARGETS, )", "--no-deps"]
args = ["doc", "@@split(CARGO_MAKE_TASK_ARGS,;)", "--no-deps"]

[tasks.doc-open]
description = "Builds all rust documentation in the workspace and opens the documentation Example `cargo make doc-open`"
description = "Builds all rust documentation in the workspace and opens the documentation. Arguments are forwarded to `cargo doc`. Example `cargo make doc-open` or `cargo make doc-open -p qemu_dxe_core`"
clear = true
command = "cargo"
args = ["doc", "@@split(INDIVIDUAL_PACKAGE_TARGETS, )", "--open"]
args = ["doc", "@@split(CARGO_MAKE_TASK_ARGS,;)", "--open"]

[tasks.clippy]
description = "Run cargo clippy for the host target and both UEFI cross-compilation targets."
description = "Run cargo clippy for the host target and both UEFI cross-compilation targets. Arguments are forwarded to `cargo clippy`."
clear = true
run_task = [{ name = ["clippy-x64", "clippy-aarch64", "clippy-std"], parallel = true }]

[tasks.clippy-x64]
description = "Run cargo clippy for x86_64-unknown-uefi."
private = true
command = "cargo"
args = ["clippy", "--target", "x86_64-unknown-uefi", "--features", "ci_features,x64", "@@split(NO_STD_FLAGS, )", "--", "-D", "warnings"]
args = ["clippy", "--target", "x86_64-unknown-uefi", "--features", "ci_features,x64", "@@split(CARGO_MAKE_TASK_ARGS,;)", "@@split(NO_STD_FLAGS, )", "--", "-D", "warnings"]

[tasks.clippy-aarch64]
description = "Run cargo clippy for aarch64-unknown-uefi."
private = true
command = "cargo"
args = ["clippy", "--target", "aarch64-unknown-uefi", "--features", "ci_features,aarch64", "@@split(NO_STD_FLAGS, )", "--", "-D", "warnings"]
args = ["clippy", "--target", "aarch64-unknown-uefi", "--features", "ci_features,aarch64", "@@split(CARGO_MAKE_TASK_ARGS,;)", "@@split(NO_STD_FLAGS, )", "--", "-D", "warnings"]

[tasks.clippy-std]
description = "Run cargo clippy for the host target (library and tests only)."
private = true
command = "cargo"
args = ["clippy", "--tests", "--", "-D", "warnings"]
args = ["clippy", "--tests", "@@split(CARGO_MAKE_TASK_ARGS,;)", "--", "-D", "warnings"]

[tasks.fmt-all-flag]
description = """Sets `FMT_ALL` to `--all` only when no arguments were given on the command line.
`--all` overrides `-p`, so it is dropped whenever any argument is given (for example
`cargo make fmt -p qemu_dxe_core`)."""
private = true
script_runner = "@duckscript"
script = '''
args = get_env CARGO_MAKE_TASK_ARGS
if is_empty ${args}
set_env FMT_ALL "--all"
else
set_env FMT_ALL ""
end
'''

[tasks.fmt]
description = "Run cargo format."
description = "Run cargo format. Arguments are forwarded to `cargo fmt`. Example `cargo make fmt` or `cargo make fmt -p qemu_dxe_core`"
clear = true
command = "cargo"
args = ["fmt", "--all"]
args = ["fmt", "@@split(FMT_ALL, )", "@@split(CARGO_MAKE_TASK_ARGS,;)"]
dependencies = ["fmt-all-flag"]

[tasks.fmt-check]
description = "Check cargo format without modifying files."
description = "Check cargo format without modifying files. Arguments are forwarded to `cargo fmt`. Example `cargo make fmt-check` or `cargo make fmt-check -p qemu_dxe_core`"
clear = true
command = "cargo"
args = ["fmt", "--all", "--check"]
args = ["fmt", "@@split(FMT_ALL, )", "--check", "@@split(CARGO_MAKE_TASK_ARGS,;)"]
dependencies = ["fmt-all-flag"]

[tasks.doc-test]
description = "Run documentation tests."
description = "Run documentation tests. Arguments are forwarded to `cargo test`."
clear = true
command = "cargo"
args = ["test", "--doc"]
args = ["test", "--doc", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.cspell]
description = "Run cspell for spell checking." # npm install -g cspell@latest
script = "cspell --quiet --no-progress --no-summary --dot --gitignore -e \"{.git/**,.github/**,.vscode/**}\" ."

[tasks.deny]
description = "Run cargo deny."
description = "Run cargo deny. Arguments are forwarded to `cargo deny check`."
install_crate = false
clear = true
command = "cargo"
args = ["deny", "check"]

[tasks.bloat-q35-exec]
private = true
command = "cargo"
args = ["bloat", "--target", "x86_64-unknown-uefi", "--features", "x64", "--bin", "qemu_q35_dxe_core", "--profile", "${RUSTC_PROFILE}", "-Zbuild-std=core,compiler_builtins,alloc", "-Zbuild-std-features=compiler-builtins-mem", "-Zunstable-options", "@@split(CLEANED_ARGS, )"]
args = ["deny", "check", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.bloat-q35]
description = "Run cargo bloat for q35 (x86_64-unknown-uefi). Examples: `cargo make bloat-q35 -- --crates`, `cargo make bloat-q35 -- --crates -n 40`."
script_runner = "@duckscript"
script = '''
args = get_env CARGO_MAKE_TASK_ARGS

# Clean up the args by replacing semicolons with spaces
if not is_empty ${args}
clean_args = replace ${args} ";;--" " --"
clean_args = replace ${clean_args} ";;" " "
clean_args = replace ${clean_args} ";" " "
# Remove leading/trailing whitespace and -- prefix
clean_args = trim ${clean_args}
clean_args = replace ${clean_args} "-- " ""
set_env CLEANED_ARGS ${clean_args}
else
set_env CLEANED_ARGS ""
end

cm_run_task bloat-q35-exec
'''

[tasks.bloat-armvirt-exec]
private = true
description = "Run cargo bloat for q35 (x86_64-unknown-uefi). Arguments are forwarded to `cargo bloat`. Examples: `cargo make bloat-q35 --crates`, `cargo make bloat-q35 --crates -n 40`."
command = "cargo"
args = ["bloat", "--target", "aarch64-unknown-uefi", "--features", "aarch64", "--bin", "qemu_armvirt_dxe_core", "--profile", "${RUSTC_PROFILE}", "-Zbuild-std=core,compiler_builtins,alloc", "-Zbuild-std-features=compiler-builtins-mem", "-Zunstable-options", "@@split(CLEANED_ARGS, )"]
args = ["bloat", "--target", "x86_64-unknown-uefi", "--features", "x64", "--bin", "qemu_q35_dxe_core", "--profile", "${RUSTC_PROFILE}", "-Zbuild-std=core,compiler_builtins,alloc", "-Zbuild-std-features=compiler-builtins-mem", "-Zunstable-options", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.bloat-armvirt]
description = "Run cargo bloat for armvirt (aarch64-unknown-uefi). Examples: `cargo make bloat-armvirt -- --crates`, `cargo make bloat-armvirt -- --crates -n 40`."
script_runner = "@duckscript"
script = '''
args = get_env CARGO_MAKE_TASK_ARGS

# Clean up the args by replacing semicolons with spaces
if not is_empty ${args}
clean_args = replace ${args} ";;--" " --"
clean_args = replace ${clean_args} ";;" " "
clean_args = replace ${clean_args} ";" " "
# Remove leading/trailing whitespace and -- prefix
clean_args = trim ${clean_args}
clean_args = replace ${clean_args} "-- " ""
set_env CLEANED_ARGS ${clean_args}
else
set_env CLEANED_ARGS ""
end

cm_run_task bloat-armvirt-exec
'''
description = "Run cargo bloat for armvirt (aarch64-unknown-uefi). Arguments are forwarded to `cargo bloat`. Examples: `cargo make bloat-armvirt --crates`, `cargo make bloat-armvirt --crates -n 40`."
command = "cargo"
args = ["bloat", "--target", "aarch64-unknown-uefi", "--features", "aarch64", "--bin", "qemu_armvirt_dxe_core", "--profile", "${RUSTC_PROFILE}", "-Zbuild-std=core,compiler_builtins,alloc", "-Zbuild-std-features=compiler-builtins-mem", "-Zunstable-options", "@@split(CARGO_MAKE_TASK_ARGS,;)"]

[tasks.all-preflight]
private = true
run_task = [{ name = ["fmt-check", "deny", "cspell"], parallel = true }]

[tasks.all]
description = "Run all tasks for PR readiness."
description = "Run all tasks for PR readiness. This task takes no arguments; any arguments given are forwarded to every sub-task."
env = { CARGO_INCREMENTAL = "0" }
run_task = { name = [
"all-preflight",
Expand Down
Loading
Loading