[env]
RUST_BACKTRACE = "full"

[env.FEATURES_FLAG]
value = ""
condition = { env_not_set = ["FEATURES_FLAG"] }

[env.VERBOSE_FLAG]
value = ""
condition = { env_not_set = ["VERBOSE_FLAG"] }

[env.TARGET_TRIPLE_FLAG]
value = ""
condition = { env_not_set = ["TARGET_TRIPLE_FLAG"] }

[tasks.clean]
description = "Clean target directory"
command = "cargo"
args = [
    "clean",
    "@@remove-empty(VERBOSE_FLAG)",
]

[tasks.build]
description = "Run cargo build"
command = "cargo"
args = [
    "build",
    "--workspace",
    "@@split(FEATURES_FLAG, )",
    "@@remove-empty(VERBOSE_FLAG)",
    "@@split(TARGET_TRIPLE_FLAG, )"
]

[tasks.fmt]
description = "Check whether rust code is properly formatted or not"
command = "cargo"
args = [
    "fmt",
    "@@remove-empty(VERBOSE_FLAG)",
    "--",
    "--check"
]

[tasks.clippy]
description = "Check if clippy return any warnings or error"
command = "cargo"
args = [
    "clippy",
    "--workspace",
    "@@split(FEATURES_FLAG, )",
    "@@remove-empty(VERBOSE_FLAG)",
    "@@split(TARGET_TRIPLE_FLAG, )",
    "--",
    "-D",
    "warnings"
]

[tasks.test]
description = "Run test"
command = "cargo"
args = [
    "test",
    "--workspace",
    "@@split(FEATURES_FLAG, )",
    "@@remove-empty(VERBOSE_FLAG)",
    "@@split(TARGET_TRIPLE_FLAG, )"
]

[tasks.doc]
description = "Run rustdoc"
command = "cargo"
args = [
    "doc",
    "--workspace",
    "--no-deps",
    "@@split(FEATURES_FLAG, )",
    "@@remove-empty(VERBOSE_FLAG)",
    "@@split(TARGET_TRIPLE_FLAG, )"
]

[tasks.rustdoc]
description = "Run rustdoc"
command = "cargo"
args = [
    "rustdoc",
    "@@split(FEATURES_FLAG, )",
    "@@remove-empty(VERBOSE_FLAG)",
    "@@split(TARGET_TRIPLE_FLAG, )",
    "--",
    "--cfg",
    "docsrs"
]

[tasks.ci]
dependencies = [
    "clean",
    "fmt",
    "build",
    "clippy",
    "doc",
    "test"
]
