content: extend = "./crates/wdk-build/rust-driver-makefile.toml"
  
  [config]
  min_version = "0.37.16"
  additional_profiles = ["all-default-tasks"]
  
  [env]
  CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = false
  CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "${CARGO_MAKE_CARGO_ALL_FEATURES}"
  CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features"
  CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "stable"
  RUSTFLAGS = "-D warnings"
  RUSTDOCFLAGS = "-D warnings"
  
  [tasks.wdk-pre-commit-flow]
  description = "Run pre-commit tasks and checks"
  category = "Development"
  workspace = false
  dependencies = [
    "sort-deps",
    "format-flow",
    "format-toml-conditioned-flow",
    "build",
    "package-driver-workspace-flow",
    "test-flow",
    "clippy-flow",
    "audit-flow",
    "unused-dependencies-flow",
    "docs",
    "nightly-test-flow",
    "nightly-clippy-flow",
    "nightly-docs",
    "beta-test-flow",
    "beta-clippy-flow",
    "beta-docs",
  ]
  
  [tasks.format]
  toolchain = "nightly"
  
  [tasks.package-driver-workspace-flow]
  # by forking, a new cargo make invocation starts and by default detects it is a workspace and runs the package-driver task for each member crate
  run_task = { name = "package-driver-flow", fork = true }
  
  [tasks.pre-test]
  # macrotest and trybuild tests will fail when switching between nightly and stable toolchains due to trybuild/macrotest caching artifacts built with the other toolchain. Deleting the tests directory is enough to purge all test artifacts created by trybuild/macrotest.
  script = '''
  #!@duckscript
  success = rm -r ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/tests
  assert ${success} "Failed to delete tests directory"
  '''
  
  [tasks.test]
  install_crate = { crate_name = "cargo-expand", binary = "cargo", test_arg = [
    "expand",
    "--version",
  ], version = "1.0.85" }
  
  [tasks.audit]
  args = ["audit", "--deny", "warnings"]
  
  [tasks.unused-dependencies]
  workspace = false
  condition = { env_true = ["CARGO_MAKE_CRATE_HAS_DEPENDENCIES"] }
  args = ["machete", "--skip-target-dir"]
  
  [tasks.nightly-test-flow]
  extend = "test-flow"
  dependencies = ["pre-nightly-test", "nightly-test", "post-nightly-test"]
  
  [tasks.pre-nightly-test]
  alias = "pre-test"
  
  [tasks.nightly-test]
  extend = "test"
  toolchain = "nightly"
  
  [tasks.post-nightly-test]
  extend = "post-test"
  
  [tasks.nightly-clippy-flow]
  extend = "clippy-flow"
  dependencies = [
    "pre-nightly-clippy",
    "nightly-clippy-router",
    "post-nightly-clippy",
  ]
  
  [tasks.pre-nightly-clippy]
  extend = "pre-clippy"
  # Proc-macro crates fail to trigger recompilation when switching toolchains due to bug in rustc resulting in "found invalid metadata files for crate" errors.
  run_task = "clean"
  
  [tasks.nightly-clippy-router]
  extend = "clippy-router"
  env = { CARGO_MAKE_CLIPPY_ARGS = "--features nightly ${CARGO_MAKE_CLIPPY_ARGS}", CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "nightly" }
  
  [tasks.post-nightly-clippy]
  extend = "post-clippy"
  env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}" }
  
  [tasks.nightly-docs]
  extend = "docs"
  toolchain = "nightly"
  args = ["doc", "--no-deps", "--features", "nightly"]
  
  [tasks.beta-test-flow]
  extend = "test-flow"
  dependencies = ["pre-beta-test", "beta-test", "post-beta-test"]
  
  [tasks.pre-beta-test]
  alias = "pre-test"
  
  [tasks.beta-test]
  extend = "test"
  toolchain = "beta"
  
  [tasks.post-beta-test]
  alias = "post-test"
  
  [tasks.beta-clippy-flow]
  extend = "clippy-flow"
  dependencies = ["pre-beta-clippy", "beta-clippy-router", "post-beta-clippy"]
  
  [tasks.pre-beta-clippy]
  extend = "pre-clippy"
  # Proc-macro crates fail to trigger recompilation when switching toolchains due to bug in rustc resulting in "found invalid metadata files for crate" errors.
  run_task = "clean"
  
  [tasks.beta-clippy-router]
  extend = "clippy-router"
  env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "beta" }
  
  [tasks.post-beta-clippy]
  extend = "post-clippy"
  env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}" }
  
  [tasks.beta-docs]
  extend = "docs"
  toolchain = "beta"
  
  [tasks.sort-deps]
  workspace = false # Run only at workspace level
  # Installing cargo-sort from main branch since there is an unreleased fix
  # Ref: https://github.com/DevinR528/cargo-sort/issues/67#issuecomment-2486868511
  # Locking down to a specific commit (20th May 2025) until a new stable release is cut out on cargo-sort
  install_script = "cargo install --git=https://github.com/DevinR528/cargo-sort cargo-sort --branch main --rev 4a1ecf093649b87fa610aec32a1bdaa4829d416b --locked --force"
  description = "Sort dependencies in Cargo.toml using cargo-sort"
  command = "cargo"
  args = [
    "sort",
    "-w",
    "-g",
    "-n",
  ] # -w for every crate in workspace, -g for keeping blank lines when sorting groups of deps, -n do not run formatting
  