[tasks.ci-flow]
description = "CI task will run cargo build and cargo test with verbose output"
category = "CI"
dependencies = [
"pre-ci-flow",
"print-env-flow",
"pre-build",
"check-format-ci-flow",
"clippy-ci-flow",
"build",
"post-build",
"test-flow",
"examples-ci-flow",
"bench-ci-flow",
"outdated-ci-flow",
"ci-coverage-flow",
"post-ci-flow",
]
[tasks.workspace-ci-flow]
description = "CI task will run CI flow for each member and merge coverage reports"
category = "CI"
workspace = false
dependencies = [
"pre-workspace-ci-flow",
"workspace-members-ci",
"workspace-coverage-pack",
"post-workspace-ci-flow",
]
[tasks.dev-test-flow]
description = "Development testing flow will first format the code, and than run cargo build and test"
category = "Development"
dependencies = [
"format-flow",
"format-toml-conditioned-flow",
"pre-build",
"build",
"post-build",
"test-flow",
]
[tasks.dev-watch-flow]
description = "Alias for default flow"
category = "Development"
alias = "test-flow"
[tasks.pre-publish-delete-lock]
description = "Deletes lock file before publishing"
category = "Publish"
condition = { env_true = ["CARGO_MAKE_CARGO_PUBLISH_DELETE_LOCK_FILE"] }
run_task = "delete-lock"
[tasks.pre-publish-clean-flow]
description = "Clears old artifactes before publishing"
category = "Publish"
dependencies = ["pre-clean", "clean", "post-clean"]
[tasks.pre-publish-conditioned-clean-flow]
description = "Clears old artifactes before publishing"
category = "Publish"
condition = { env_not_set = ["CARGO_MAKE_SKIP_PREPUBLISH_CLEAN"] }
run_task = "pre-publish-clean-flow"
[tasks.publish-flow]
description = "Publish flow - First clean the target directory of any old leftovers, package and publish"
category = "Publish"
dependencies = [
"wait",
"pre-publish-conditioned-clean-flow",
"pre-publish-delete-lock",
"pre-publish",
"publish",
"post-publish",
]
[tasks.build-flow]
description = "Full sanity testing flow."
category = "Build"
dependencies = [
"init-build-flow",
"pre-clean",
"clean-apidocs",
"clean",
"post-clean",
"format-flow",
"pre-build",
"build",
"post-build",
"test-flow",
"examples-ci-flow",
"bench-ci-flow",
"pre-verify-project",
"verify-project",
"post-verify-project",
"audit-flow",
"outdated-flow",
"docs-flow",
"end-build-flow",
]
[tasks.init-build-flow]
category = "Build"
[tasks.pre-clean]
category = "Cleanup"
[tasks.clean-apidocs]
description = "Delete API docs."
category = "Documentation"
workspace = false
run_task = [
{ name = "workspace-clean-apidocs", condition = { env_set = [
"CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER",
] } },
{ name = "crate-clean-apidocs" },
]
[tasks.crate-clean-apidocs]
category = "Documentation"
private = true
env = { CARGO_MAKE_DOCS_ROOT_FOLDER = "${CARGO_MAKE_WORKING_DIRECTORY}" }
run_task = "do-clean-apidocs"
[tasks.workspace-clean-apidocs]
category = "Documentation"
private = true
env = { CARGO_MAKE_DOCS_ROOT_FOLDER = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}", CARGO_MAKE_DOCS_SUB_FOLDER = "${CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER}" }
run_task = "do-clean-apidocs"
[tasks.do-clean-apidocs]
category = "Documentation"
private = true
condition = { env_set = ["CARGO_MAKE_DOCS_ROOT_FOLDER"] }
script = '''
#!@duckscript
DOCS_DIRECTORY = set ${CARGO_MAKE_DOCS_ROOT_FOLDER}/docs/api/${CARGO_MAKE_DOCS_SUB_FOLDER}
# Removing Documentation Directory: ${DOCS_DIRECTORY}
rm -r ${DOCS_DIRECTORY}
'''
[tasks.clean]
description = "Runs the cargo clean command."
category = "Cleanup"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["clean"]
[tasks.post-clean]
category = "Cleanup"
[tasks.delete-lock]
description = "Deletes the Cargo.lock file."
category = "Cleanup"
run_task = [
{ name = "workspace-delete-lock", condition = { env_set = [
"CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER",
] } },
{ name = "crate-delete-lock" },
]
[tasks.crate-delete-lock]
description = "Deletes the Cargo.lock file."
category = "Cleanup"
private = true
script = '''
#!@duckscript
rm ./Cargo.lock
'''
[tasks.workspace-delete-lock]
description = "Deletes the Cargo.lock file."
category = "Cleanup"
condition = { env_set = ["CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY"] }
private = true
script = '''
#!@duckscript
rm ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/Cargo.lock
'''
[tasks.upgrade-dependencies]
description = "Rebuilds the crate with most updated dependencies."
category = "Development"
dependencies = ["delete-lock", "dev-test-flow"]
[tasks.install-rustfmt]
description = "Installs cargo rustfmt plugin."
category = "Development"
env.CFG_RELEASE = { value = "${CARGO_MAKE_RUST_VERSION}", condition = { env_not_set = [
"CFG_RELEASE",
] } }
env.CFG_RELEASE_CHANNEL = { value = "${CARGO_MAKE_RUST_CHANNEL}", condition = { env_not_set = [
"CFG_RELEASE_CHANNEL",
] } }
install_crate = { crate_name = "rustfmt-nightly", rustup_component_name = "rustfmt", binary = "rustfmt", test_arg = "--help" }
[tasks.pre-format]
category = "Development"
[tasks.format]
description = "Runs the cargo rustfmt plugin."
category = "Development"
dependencies = ["install-rustfmt"]
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["fmt"]
[tasks.post-format]
category = "Development"
[tasks.pre-check-format]
category = "Test"
[tasks.check-format]
description = "Runs cargo fmt to check appropriate code format."
category = "Test"
dependencies = ["install-rustfmt"]
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["fmt", "--", "--check"]
[tasks.post-check-format]
category = "Test"
[tasks.check-format-flow]
description = "Runs cargo fmt check flow."
category = "Test"
dependencies = ["pre-check-format", "check-format", "post-check-format"]
[tasks.check-format-ci-flow]
description = "Runs cargo fmt --check if conditions are met."
category = "Test"
condition = { env_set = [
"CARGO_MAKE_RUN_CHECK_FORMAT",
], channels = [
"nightly",
], platforms = [
"linux",
] }
run_task = "check-format-flow"
[tasks.format-flow]
description = "Runs the cargo rustfmt plugin as part of a flow."
category = "Development"
dependencies = ["pre-format", "format", "post-format"]
[tasks.pre-docs]
category = "Documentation"
[tasks.docs]
description = "Generate rust documentation."
category = "Documentation"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["doc", "--no-deps"]
[tasks.post-docs]
category = "Documentation"
[tasks.docs-flow]
description = "Generate rust documentation."
category = "Documentation"
dependencies = [
"pre-docs",
"docs",
"post-docs",
"readme-set-crate-version-conditioned",
"readme-include-files-conditioned",
"copy-apidocs",
]
[tasks.pre-workspace-docs]
category = "Documentation"
[tasks.workspace-docs]
description = "Generate workspace level rust documentation."
category = "Documentation"
[tasks.post-workspace-docs]
category = "Documentation"
[tasks.workspace-docs-flow]
description = "Generate workspace level rust documentation."
category = "Documentation"
workspace = false
dependencies = ["pre-workspace-docs", "workspace-docs", "post-workspace-docs"]
[tasks.readme-file-set-env]
description = "Sets the CARGO_MAKE_DOCS_README_FILE environment variable."
category = "Documentation"
private = true
condition = { env_not_set = ["CARGO_MAKE_DOCS_README_FILE"] }
env = { CARGO_MAKE_DOCS_README_FILE = "${CARGO_MAKE_WORKING_DIRECTORY}/README.md" }
[tasks.readme-set-crate-version]
description = "Modifies the current README.md file with the current crate version."
category = "Documentation"
env = { "CARGO_MAKE_DOCS_README_SET_CRATE_VERSION" = true }
run_task = "readme-set-crate-version-conditioned"
[tasks.readme-set-crate-version-conditioned]
description = "Modifies the current README.md file with the current crate version."
category = "Documentation"
private = true
dependencies = ["readme-file-set-env"]
condition = { env_true = ["CARGO_MAKE_DOCS_README_SET_CRATE_VERSION"] }
script = '''
#!@duckscript
readme_file_name = set ${CARGO_MAKE_DOCS_README_FILE}
if is_file ${readme_file_name}
readme_text = readfile ${readme_file_name}
prefix = set "dependencies]\n"
index = indexof ${readme_text} ${prefix}
if is_defined index
prefix_length = strlen ${prefix}
end = calc ${index} + ${prefix_length}
readme_start = substring ${readme_text} 0 ${end}
readme_end = substring ${readme_text} ${end}
prefix = set "${CARGO_MAKE_PROJECT_NAME} = \""
found = starts_with ${readme_end} ${prefix}
if ${found}
prefix_length = strlen ${prefix}
readme_start = set "${readme_start}${prefix}"
readme_end = substring ${readme_end} ${prefix_length}
index = indexof ${readme_end} \"
if is_defined index
readme_end = substring ${readme_end} ${index}
readme_text = set "${readme_start}^${CARGO_MAKE_PROJECT_VERSION}${readme_end}"
writefile ${readme_file_name} ${readme_text}
else
echo "Dependency end not found."
end
else
echo "${CARGO_MAKE_PROJECT_NAME} dependency prefix not found."
end
else
echo "Dependencies prefix not found."
end
else
echo "README file: ${readme_file_name} not found."
end
'''
[tasks.readme-include-files]
description = "Modifies the current README.md by including external files."
category = "Documentation"
env = { "CARGO_MAKE_DOCS_README_INCLUDE_FILES" = true }
run_task = "readme-include-files-conditioned"
[tasks.readme-include-files-conditioned]
description = "Modifies the current README.md by including external files."
category = "Documentation"
private = true
condition = { env_true = [
"CARGO_MAKE_DOCS_README_INCLUDE_FILES",
], files_exist = [
"${CARGO_MAKE_DOCS_README_FILE}",
] }
dependencies = ["readme-file-set-env"]
install_crate = { crate_name = "md-inc", binary = "md-inc", test_arg = "--help" }
env = { CARGO_MAKE_DOCS_INCLUDE_FILES_MARKDOWN_FILE = "${CARGO_MAKE_DOCS_README_FILE}" }
run_task = "markdown-include-files"
[tasks.markdown-include-files]
description = "Modifies the markdown file defined by the CARGO_MAKE_DOCS_INCLUDE_FILES_MARKDOWN_FILE environment variable, by including external files."
category = "Documentation"
condition = { files_exist = ["${CARGO_MAKE_DOCS_INCLUDE_FILES_MARKDOWN_FILE}"] }
install_crate = { crate_name = "md-inc", binary = "md-inc", test_arg = "--help" }
command = "md-inc"
args = ["${CARGO_MAKE_DOCS_INCLUDE_FILES_MARKDOWN_FILE}"]
[tasks.pre-build]
category = "Build"
[tasks.build]
description = "Runs the rust compiler."
category = "Build"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = [
"build",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
]
[tasks.build-release]
description = "Runs release build."
category = "Build"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["build", "--release", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.post-build]
category = "Build"
[tasks.pre-test]
category = "Test"
[tasks.test]
description = "Runs all available tests."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = [
"test",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
]
[tasks.test-thread-safe]
description = "Runs all available tests without limiting test threads."
category = "Test"
env = { RUST_TEST_THREADS = { unset = true } }
run_task = "test"
[tasks.test-single-threaded]
description = "Runs all ignored tests with a single test thread."
category = "Test"
install_crate = false
env = { RUST_TEST_THREADS = 1 }
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = [
"test",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
"--",
"--ignored",
]
[tasks.test-custom]
description = "Runs custom test command."
category = "Test"
[tasks.test-multi-phases-cleanup]
description = "Cleanup after multi phase tests flow."
category = "Test"
private = true
env = { RUST_TEST_THREADS = { unset = true } }
[tasks.test-multi-phases-flow]
description = "Runs single/multi and custom test tasks."
category = "Test"
run_task = [
{ name = [
"test-thread-safe",
"test-single-threaded",
"test-custom",
"test-multi-phases-cleanup",
], condition = { env_true = [
"CARGO_MAKE_TEST_USE_MULTI_TEST_PHASES",
] } },
{ name = "test" },
]
[tasks.test-flow]
description = "Runs pre/post hooks and cargo test."
category = "Test"
dependencies = ["pre-test", "test-multi-phases-flow", "post-test"]
[tasks.test-with-args]
description = "Runs cargo test with command line arguments."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["test", "${@}"]
[tasks.post-test]
category = "Test"
[tasks.pre-bench]
category = "Test"
[tasks.bench]
description = "Runs all available bench files."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["bench", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.post-bench]
category = "Test"
[tasks.bench-flow]
description = "Runs a bench flow."
category = "Test"
dependencies = ["pre-bench", "bench", "post-bench"]
[tasks.bench-conditioned-flow]
description = "Runs the bench flow if conditions are met."
category = "Test"
condition = { env_set = ["CARGO_MAKE_RUN_BENCH"], channels = ["nightly"] }
run_task = "bench-flow"
[tasks.bench-compile]
description = "Compiles all available bench files."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["build", "--benches", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.bench-conditioned-compile]
description = "Compiles all available bench files if conditions are met."
category = "Test"
condition = { env_set = ["CARGO_MAKE_BUILD_BENCH"], channels = ["nightly"] }
run_task = "bench-compile"
[tasks.bench-ci-flow]
description = "Runs/Compiles the benches if conditions are met."
category = "CI"
dependencies = ["bench-conditioned-compile", "bench-conditioned-flow"]
[tasks.pre-check]
category = "Test"
[tasks.check]
description = "Runs cargo check."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["check"]
[tasks.post-check]
category = "Test"
[tasks.check-flow]
description = "Runs cargo check flow."
category = "Test"
dependencies = ["pre-check", "check", "post-check"]
[tasks.check-tests]
description = "Runs cargo check for project tests."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["check", "--tests"]
[tasks.check-examples]
description = "Runs cargo check for project examples."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["check", "--examples"]
[tasks.examples-compile]
description = "Runs cargo build for project examples."
category = "Test"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["build", "--examples"]
[tasks.examples-conditioned-compile]
description = "Runs cargo build for project examples if conditions are met."
category = "Test"
condition = { env_set = ["CARGO_MAKE_BUILD_EXAMPLES"] }
run_task = "examples-compile"
[tasks.examples-ci-flow]
description = "Compiles the examples if conditions are met."
category = "CI"
dependencies = ["examples-conditioned-compile"]
[tasks.pre-verify-project]
category = "CI"
[tasks.verify-project]
description = "Runs verify-project cargo plugin."
category = "CI"
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["verify-project"]
[tasks.post-verify-project]
category = "CI"
[tasks.pre-audit]
category = "CI"
[tasks.audit]
description = "Runs audit cargo plugin."
category = "CI"
condition = { env_true = [
"CARGO_MAKE_CRATE_HAS_DEPENDENCIES",
"CARGO_MAKE_CRATE_LOCK_FILE_EXISTS",
] }
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["audit"]
[tasks.post-audit]
category = "CI"
[tasks.audit-flow-no-condition]
description = "Runs audit flow."
category = "CI"
private = true
dependencies = ["pre-audit", "audit", "post-audit"]
[tasks.audit-flow]
description = "Runs audit flow."
category = "CI"
condition = { env_not_set = ["CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS"] }
run_task = "audit-flow-no-condition"
[tasks.pre-outdated]
category = "CI"
[tasks.outdated]
description = "Runs cargo-outdated cargo plugin."
category = "CI"
condition = { env_true = ["CARGO_MAKE_CRATE_HAS_DEPENDENCIES"] }
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["outdated", "--root-deps-only", "--exit-code", "1"]
[tasks.post-outdated]
category = "CI"
[tasks.outdated-flow-no-condition]
description = "Runs outdated cargo flow."
category = "CI"
private = true
dependencies = ["pre-outdated", "outdated", "post-outdated"]
[tasks.outdated-flow]
description = "Runs outdated cargo flow."
category = "CI"
condition = { env_not_set = ["CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS"] }
run_task = "outdated-flow-no-condition"
[tasks.outdated-ci-flow]
description = "Runs outdated cargo conditioned CI flow."
category = "CI"
condition = { env_set = [
"CARGO_MAKE_CHECK_OUTDATED",
], env_true = [
"CARGO_MAKE_CRATE_HAS_DEPENDENCIES",
], env_false = [
"CARGO_MAKE_PR",
], env = { "CARGO_MAKE_CI_BRANCH_NAME" = "master" }, channels = [
"nightly",
], platforms = [
"linux",
] }
run_task = "outdated-flow"
[tasks.unused-dependencies-flow]
description = "Checks for unused dependencies."
category = "CI"
condition = { env_true = ["CARGO_MAKE_CRATE_HAS_DEPENDENCIES"] }
dependencies = [
"pre-unused-dependencies",
"unused-dependencies",
"post-unused-dependencies",
]
[tasks.pre-unused-dependencies]
category = "CI"
[tasks.unused-dependencies]
description = "Checks for unused dependencies."
category = "CI"
condition = { channels = [
"nightly",
], env_true = [
"CARGO_MAKE_CRATE_HAS_DEPENDENCIES",
] }
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["udeps"]
[tasks.post-unused-dependencies]
category = "CI"
[tasks.install-clippy-any]
description = "Installs the latest clippy code linter via cargo install via rustup or directly from github."
category = "Test"
condition = { channels = ["nightly"] }
ignore_errors = true
install_crate = { crate_name = "clippy", rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }
install_crate_args = [
"--git",
"https://github.com/rust-lang/rust-clippy/",
"clippy",
]
args = ["clippy", "--help"]
[tasks.install-clippy-rustup]
description = "Installs the clippy code linter via rustup."
category = "Test"
ignore_errors = true
install_crate = { rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }
[tasks.install-clippy]
description = "Installs the clippy code linter."
category = "Test"
run_task = [{ name = ["install-clippy-any", "install-clippy-rustup"] }]
[tasks.pre-clippy]
category = "Test"
[tasks.clippy]
description = "Runs clippy code linter."
category = "Test"
dependencies = ["install-clippy"]
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["clippy", "@@split(CARGO_MAKE_CLIPPY_ARGS, )"]
[tasks.post-clippy]
category = "Test"
[tasks.clippy-allow-fail]
extend = "clippy"
ignore_errors = true
[tasks.clippy-router]
description = "Selects clippy task based on current environment."
category = "Test"
run_task = [
{ name = "clippy-allow-fail", condition = { env_true = [
"CARGO_MAKE_CLIPPY_ALLOW_FAIL",
] } },
{ name = "clippy" },
]
[tasks.clippy-flow]
description = "Runs clippy flow."
category = "Test"
dependencies = ["pre-clippy", "clippy-router", "post-clippy"]
[tasks.clippy-ci-flow]
description = "Runs clippy code linter if conditions are met."
category = "CI"
condition = { env_set = [
"CARGO_MAKE_RUN_CLIPPY",
], channels = [
"nightly",
], platforms = [
"linux",
] }
run_task = "clippy-flow"
[tasks.copy-apidocs]
description = "Copies the generated documentation to the docs/api directory."
category = "Documentation"
workspace = false
run_task = [
{ name = "workspace-copy-apidocs", condition = { env_set = [
"CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER",
] } },
{ name = "crate-copy-apidocs" },
]
[tasks.crate-copy-apidocs]
description = "Copies the generated documentation to the docs/api directory."
category = "Documentation"
private = true
env = { CARGO_MAKE_DOCS_ROOT_FOLDER = "${CARGO_MAKE_WORKING_DIRECTORY}" }
run_task = "do-copy-apidocs"
[tasks.workspace-copy-apidocs]
description = "Copies the generated documentation to the docs/api directory."
category = "Documentation"
private = true
env = { CARGO_MAKE_DOCS_ROOT_FOLDER = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}", CARGO_MAKE_DOCS_SUB_FOLDER = "${CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER}" }
run_task = "do-copy-apidocs"
[tasks.do-copy-apidocs]
description = "Copies the generated documentation to the docs/api directory."
category = "Documentation"
private = true
script_runner = "@duckscript"
script = '''
if is_empty "${CARGO_MAKE_DOCS_SUB_FOLDER}"
src_dir= set ${CARGO_MAKE_DOCS_ROOT_FOLDER}
else
src_dir= set ${CARGO_MAKE_DOCS_ROOT_FOLDER}/${CARGO_MAKE_DOCS_SUB_FOLDER}
end
if is_dir ${src_dir}/target/${CARGO_MAKE_CRATE_TARGET_TRIPLE}/doc
src_dir= set ${src_dir}/target/${CARGO_MAKE_CRATE_TARGET_TRIPLE}/doc
else
src_dir= set ${src_dir}/target/doc
end
if is_empty "${CARGO_MAKE_DOCS_SUB_FOLDER}"
dest_dir= set ${CARGO_MAKE_DOCS_ROOT_FOLDER}/docs/api
else
dest_dir= set ${CARGO_MAKE_DOCS_ROOT_FOLDER}/docs/api/${CARGO_MAKE_DOCS_SUB_FOLDER}/
end
echo Source Directory: ${src_dir}
echo Target Directory: ${dest_dir}
rm -r ${dest_dir}
mkdir ${dest_dir}
handle = glob_array ${src_dir}/*
for path in ${handle}
echo Moving documentation path: ${path}
if is_directory ${path}
mv ${path}/ ${dest_dir}
else
mv ${path} ${dest_dir}
end
end
echo All docs copied
'''
[tasks.end-build-flow]
category = "Build"
[tasks.pre-package]
category = "Publish"
[tasks.package]
description = "Runs the cargo package command."
category = "Publish"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["package"]
[tasks.post-package]
category = "Publish"
[tasks.pre-publish]
category = "Publish"
[tasks.publish]
description = "Runs the cargo publish command."
category = "Publish"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
args = ["publish", "@@split(CARGO_MAKE_CARGO_PUBLISH_FLAGS, )"]
[tasks.post-publish]
category = "Publish"
[tasks.pre-ci-flow]
category = "CI"
[tasks.post-ci-flow]
category = "CI"
[tasks.do-on-members]
description = "Runs the requested task for every workspace member."
category = "Tools"
env = { CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY = "${CARGO_MAKE_WORKING_DIRECTORY}/target" }
condition = { env_set = ["CARGO_MAKE_MEMBER_TASK"] }
script = '''
#prevent codecov publish in member builds
export CARGO_MAKE_SKIP_CODECOV="true"
#output coverage data goes into workspace level
export CARGO_MAKE_COVERAGE_REPORT_DIRECTORY="${CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY}/coverage"
cargo make --loglevel=${CARGO_MAKE_LOG_LEVEL} --profile="${CARGO_MAKE_PROFILE}" "${CARGO_MAKE_MEMBER_TASK}"
unset CARGO_MAKE_COVERAGE_REPORT_DIRECTORY
unset CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY
unset CARGO_MAKE_SKIP_CODECOV
'''
[tasks.do-on-members.windows]
clear = true
script = '''
cargo make --loglevel=%CARGO_MAKE_LOG_LEVEL% --profile="%CARGO_MAKE_PROFILE%" %CARGO_MAKE_MEMBER_TASK%
if %errorlevel% neq 0 exit /b %errorlevel%
'''
[tasks.pre-workspace-ci-flow]
category = "CI"
[tasks.post-workspace-ci-flow]
category = "CI"
[tasks.workspace-members-ci]
description = "Runs the ci-flow for every workspace member."
category = "CI"
env = { "CARGO_MAKE_MEMBER_TASK" = "${CARGO_MAKE_CORE_TASK_NAMESPACE_PREFIX}ci-flow" }
run_task = "do-on-members"
[tasks.upload-artifacts]
description = "Uploads the binary artifact from the cargo package/publish output (hook only)."
category = "Publish"
[tasks.build-publish-flow]
description = "Runs full sanity, generates github release and publishes the crate."
category = "Publish"
workspace = false
condition = { env_set = [
"COMMIT_MSG",
"GITHUB_API_TOKEN",
"GITHUB_REPO_NAME",
], env = { "CARGO_MAKE_GIT_BRANCH" = "master" } }
env = { "CARGO_MAKE_SKIP_PREPUBLISH_CLEAN" = true, "CARGO_MAKE_GIT_PUSH_ARGS" = "--no-verify" }
run_task = [
{ name = "workspace-build-publish-flow", condition = { env_true = [
"CARGO_MAKE_CRATE_IS_WORKSPACE",
] } },
{ name = "crate-build-publish-flow" },
]
[tasks.crate-build-publish-flow]
private = true
dependencies = [
"delete-lock",
"build-flow",
"build-file-increment-flow",
"git-add",
"git-status",
"git-commit-message",
"git-push",
"git-delete-merged-branches",
"github-publish-custom-name",
"publish-flow",
"upload-artifacts",
"git-pull",
]
[tasks.workspace-build-publish-flow]
private = true
dependencies = [
"delete-lock",
"workspace-build-flow",
"build-file-increment-flow",
"git-add",
"git-status",
"git-commit-message",
"git-push",
"git-delete-merged-branches",
"github-publish-custom-name",
"workspace-publish-flow",
"git-pull",
]
[tasks.workspace-build-flow]
description = "Full sanity testing flow."
category = "Build"
workspace = false
dependencies = ["workspace-member-build-flow", "workspace-docs-flow"]
[tasks.workspace-member-build-flow]
category = "Build"
private = true
env = { "CARGO_MAKE_MEMBER_TASK" = "${CARGO_MAKE_CORE_TASK_NAMESPACE_PREFIX}build-flow" }
run_task = "do-on-members"
[tasks.workspace-publish-flow]
description = "Publish flow - First clean the target directory of any old leftovers, package and publish"
category = "Publish"
workspace = false
env = { "CARGO_MAKE_MEMBER_TASK" = "${CARGO_MAKE_CORE_TASK_NAMESPACE_PREFIX}publish-flow", "CARGO_MAKE_WAIT_MILLISECONDS" = 20000 }
run_task = "do-on-members"
[tasks.install-rust-src]
description = "Installs rust-src rustup component."
category = "Tools"
install_crate = { rustup_component_name = "rust-src" }
[tasks.install-rls]
description = "Installs rust Language server rustup component."
category = "Tools"
install_crate = { rustup_component_name = "rls-preview", binary = "rls", test_arg = "--help" }
[tasks.zip-release-ci-flow]
description = "Compiles the binary in release mode and zips it up"
category = "CI"
condition = { env_set = [
"CARGO_MAKE_RELEASE_FLOW_TARGET",
], env_true = [
"CARGO_MAKE_CI",
] }
dependencies = [
"print-env-flow",
"clean",
"setup-release-build-env",
"build-release-for-binary-upload",
"zip-release-binary-for-target",
]
[tasks.setup-release-build-env]
description = "Sets up any non-rust dependencies in the build environment"
category = "CI"
private = true
dependencies = [
"setup-release-build-env-vars",
"setup-release-build-env-print",
"install-zip",
"setup-musl",
]
[tasks.setup-release-build-env-print]
category = "CI"
private = true
script = '''
#!@duckscript
echo "*************************************"
echo "Release Binary Build Environment:"
echo " Target: ${CARGO_MAKE_RELEASE_FLOW_TARGET}"
echo " Use Cross: ${CARGO_MAKE_BINARY_RELEASE_ENV_USE_CROSS}"
echo " Setup MUSL: ${CARGO_MAKE_BINARY_RELEASE_ENV_INSTALL_MUSL}"
echo " ARM Linux: ${CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX}"
echo "*************************************"
'''
[tasks.setup-release-build-env-vars]
description = "Sets up environment variables based on target."
category = "CI"
private = true
env.CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX = { source = "${CARGO_MAKE_RELEASE_FLOW_TARGET}", default_value = "false", mapping = { "arm-unknown-linux-gnueabihf" = "true" } }
env.CARGO_MAKE_BINARY_RELEASE_ENV_USE_CROSS = "${CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX}"
env.CARGO_MAKE_BINARY_RELEASE_ENV_INSTALL_MUSL = true
[tasks.install-zip]
description = "Installs zip executable"
category = "Tools"
condition = { platforms = ["linux"] }
dependencies = ["setup-sudo-env"]
install_script = '''
which zip || (${CARGO_MAKE_SUDO_COMMAND} apt-get update && ${CARGO_MAKE_SUDO_COMMAND} apt-get install -y zip)
'''
[tasks.setup-musl]
description = "Sets up a musl build environment"
category = "CI"
private = true
condition = { env_set = [
"CARGO_MAKE_RELEASE_FLOW_TARGET",
"CARGO_MAKE_OPENSSL_VERSION",
"CARGO_MAKE_OPENSSL_DOWNLOAD_URL",
], env_true = [
"CARGO_MAKE_CI",
"CARGO_MAKE_BINARY_RELEASE_ENV_INSTALL_MUSL",
], platforms = [
"linux",
] }
env.OPENSSL_DIR = "${HOME}/openssl-musl"
env.OPENSSL_PLATFORM = { source = "${CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX}", default_value = "x86_64", mapping = { "true" = "armv4" } }
script = '''
rustup target add "${CARGO_MAKE_RELEASE_FLOW_TARGET}"
curl --location ${CARGO_MAKE_OPENSSL_DOWNLOAD_URL} | tar xzf -
cd openssl-${CARGO_MAKE_OPENSSL_VERSION}
CC=musl-gcc ./Configure --prefix="${OPENSSL_DIR}" no-dso no-ssl2 no-ssl3 linux-${OPENSSL_PLATFORM} -fPIC
make -j"$(nproc)"
make install
'''
[tasks.build-release-for-binary-upload]
run_task = [
{ name = "cross-build-release-for-target", condition = { env_true = [
"CARGO_MAKE_BINARY_RELEASE_ENV_USE_CROSS",
] } },
{ name = "build-release-for-target" },
]
[tasks.build-release-for-target-base]
description = "Makes a release build for a given target"
category = "Build"
private = true
condition = { env_set = [
"CARGO_MAKE_RELEASE_FLOW_TARGET",
], env_true = [
"CARGO_MAKE_CI",
] }
args = [
"build",
"--release",
"--all-features",
"--target",
"${CARGO_MAKE_RELEASE_FLOW_TARGET}",
]
[tasks.cross-build-release-for-target]
extend = "build-release-for-target-base"
install_crate = { crate_name = "cross", binary = "cross", test_arg = [
"--help",
] }
command = "cross"
[tasks.build-release-for-target]
extend = "build-release-for-target-base"
install_crate = false
toolchain = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}"
command = "cargo"
[tasks.zip-release-binary-for-target]
description = "Zips up the release binary, README, and license(s)"
category = "Publish"
condition = { env_set = [
"CARGO_MAKE_RELEASE_FLOW_TARGET",
"CARGO_MAKE_PROJECT_NAME",
"CARGO_MAKE_PROJECT_VERSION",
"CARGO_MAKE_BINARY_EXECUTABLE_NAME",
], env_true = [
"CARGO_MAKE_CI",
] }
env.OUTPUT_NAME = "${CARGO_MAKE_PROJECT_NAME}-v${CARGO_MAKE_PROJECT_VERSION}-${CARGO_MAKE_RELEASE_FLOW_TARGET}"
env.TARGET_RELEASE_DIRECTORY = "target/${CARGO_MAKE_RELEASE_FLOW_TARGET}/release"
script = '''
#!@duckscript
executable_file = set ${CARGO_MAKE_BINARY_EXECUTABLE_NAME}
additional_executable_file = set "${CARGO_MAKE_ADDITIONAL_BINARY_EXECUTABLE_NAME}"
additional_executable_file_len = length ${additional_executable_file}
additional_executable_file_defined = set true
if eq ${additional_executable_file_len} 0
additional_executable_file_defined = set false
end
if is_windows
executable_file = set "${executable_file}.exe"
additional_executable_file = set "${additional_executable_file}.exe"
end
mkdir ${OUTPUT_NAME}
cp ${TARGET_RELEASE_DIRECTORY}/${executable_file} ${OUTPUT_NAME}/${executable_file}
if ${additional_executable_file_defined}
if is_path_exists ${TARGET_RELEASE_DIRECTORY}/${additional_executable_file}
cp ${TARGET_RELEASE_DIRECTORY}/${additional_executable_file} ${OUTPUT_NAME}/${additional_executable_file}
end
end
cp ./README.md ${OUTPUT_NAME}/README.md
glob_cp ./LICENSE* ${OUTPUT_NAME}/
ls -l ${OUTPUT_NAME}/
if is_windows
exec --fail-on-error powershell Compress-Archive -Path ${OUTPUT_NAME}/* -DestinationPath ${OUTPUT_NAME}.zip
else
exec --fail-on-error zip -r ${OUTPUT_NAME}.zip ${OUTPUT_NAME}
end
'''