//! # types//!//! Defines the various types and aliases used by cargo-make.//!#[cfg(test)]#[path ="types_test.rs"]modtypes_test;usecrate::legacy;usecrate::plugin::types::Plugins;useci_info::types::CiInfo;usegit_info::types::GitInfo;useindexmap::{IndexMap, IndexSet};useregex::Regex;userust_info::types::RustInfo;usestd::collections::HashMap;/// Returns the platform namepub fnget_platform_name() -> String {ifcfg!(windows) {"windows".to_string() }else ifcfg!(target_os ="macos") ||cfg!(target_os ="ios") {"mac".to_string() }else{"linux".to_string() }}fnget_namespaced_task_name(namespace:&str, task:&str) -> String {letmutnamespaced_task = String::new();ifnamespace.len() >0{ namespaced_task.push_str(namespace); namespaced_task.push_str("::"); } namespaced_task.push_str(task); namespaced_task}fnextend_script_value( current_script_value:Option<ScriptValue>, new_script_value:Option<ScriptValue>,) ->Option<ScriptValue> {matchcurrent_script_value {Some(refcurrent_value) =>matchnew_script_value {Some(refnew_value) =>matchcurrent_value { ScriptValue::Sections(current_sections) =>matchnew_value { ScriptValue::Sections(new_sections) => {letpre =ifnew_sections.pre.is_some() { new_sections.pre.clone() }else{ current_sections.pre.clone() };letmain =ifnew_sections.main.is_some() { new_sections.main.clone() }else{ current_sections.main.clone() };letpost =ifnew_sections.post.is_some() { new_sections.post.clone() }else{ current_sections.post.clone() };Some(ScriptValue::Sections(ScriptSections { pre, main, post })) }_=> current_script_value, },_=> new_script_value, },None=> current_script_value, },None=> new_script_value, }}#[derive(Debug, Clone)]/// Holds CLI argspub structCliArgs {/// The command namepubcommand: String,/// The external Makefile.toml pathpubbuild_file:Option<String>,/// The task to invokepubtask: String,/// The profile namepubprofile:Option<String>,/// Log level namepublog_level: String,/// Disables colorful outputpubdisable_color: bool,/// Task completion for given shellpubcompletion:Option<String>,/// Current working directorypubcwd:Option<String>,/// Environment variablespubenv:Option<Vec<String>>,/// Environment variables filepubenv_file:Option<String>,/// Prevent workspace supportpubdisable_workspace: bool,/// Prevent on error flow even if defined in config sectionpubdisable_on_error: bool,/// Allow invocation of private taskspuballow_private: bool,/// If true, the init and end tasks are skippedpubskip_init_end_tasks: bool,/// Skip tasks that match the provided patternpubskip_tasks_pattern:Option<String>,/// Only print the execution planpubprint_only: bool,/// List all known stepspublist_all_steps: bool,/// List steps for a given categorypublist_category_steps:Option<String>,/// Diff flowspubdiff_execution_plan: bool,/// Disables the update check during startuppubdisable_check_for_updates: bool,/// Allows access unsupported experimental predefined taskspubexperimental: bool,/// additional command line argumentspubarguments:Option<Vec<String>>,/// Output formatpuboutput_format: String,/// Output file namepuboutput_file:Option<String>,/// Print time summary at end of the flowpubprint_time_summary: bool,/// Hide any minor tasks such as pre/post hookspubhide_uninteresting: bool,}implCliArgs {/// Creates and returns a new instance.pub fnnew() -> CliArgs { CliArgs { command:"".to_string(), build_file:None, task:"default".to_string(), profile:None, log_level:"info".to_string(), disable_color:false, completion:None, cwd:None, env:None, env_file:None, disable_workspace:false, disable_on_error:false, allow_private:false, skip_init_end_tasks:false, skip_tasks_pattern:None, print_only:false, list_all_steps:false, list_category_steps:None, diff_execution_plan:false, disable_check_for_updates:false, experimental:false, arguments:None, output_format:"default".to_string(), output_file:None, print_time_summary:false, hide_uninteresting:false, } }}#[derive(Debug)]pub(crate)structRunTaskOptions {pub(crate) plugins_enabled: bool,}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds persisted data used by cargo-makepub structCache {/// File from which the cache file was loaded from#[serde(skip)]pubfile_name:Option<String>,/// Holds last update check with returned no updates resultpublast_update_check:Option<u64>,}implCache {/// Returns new instancepub fnnew() -> Cache { Default::default() }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds configuration info for cargo-makepub structGlobalConfig {/// File from which the global config was loaded from#[serde(skip)]pubfile_name:Option<String>,/// Default log levelpublog_level:Option<String>,/// Default output coloringpubdisable_color:Option<bool>,/// Default task namepubdefault_task_name:Option<String>,/// Update check minimum time from the previous check (always, daily, weekly, monthly)pubupdate_check_minimum_interval:Option<String>,/// True to search for project root in parent directories if current cwd is not a project rootpubsearch_project_root:Option<bool>,}implGlobalConfig {/// Returns new instancepub fnnew() -> GlobalConfig { GlobalConfig { search_project_root:Some(false), ..Default::default() } }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds crate workspace info, see <http://doc.crates.io/manifest.html#the-workspace-section>pub structWorkspace {/// members pathspubmembers:Option<Vec<String>>,/// exclude pathspubexclude:Option<Vec<String>>,/// workspace level dependenciespubdependencies:Option<IndexMap<String, CrateDependency>>,/// root packagepubpackage:Option<PackageInfo>,}implWorkspace {/// Creates and returns a new instance.pub fnnew() -> Workspace { Default::default() }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds crate package information loaded from the Cargo.toml file package section.pub structPackageInfo {/// namepubname:Option<String>,/// versionpubversion:Option<String>,/// descriptionpubdescription:Option<String>,/// licensepublicense:Option<String>,/// documentation linkpubdocumentation:Option<String>,/// homepage linkpubhomepage:Option<String>,/// repository linkpubrepository:Option<String>,}implPackageInfo {/// Creates and returns a new instance.pub fnnew() -> PackageInfo { Default::default() }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds crate dependency info.pub structCrateDependencyInfo {/// Holds the dependency pathpubpath:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds crate dependency info.pub enumCrateDependency {/// Holds the dependency versionVersion(String),/// Hold dependency infoInfo(CrateDependencyInfo),}#[derive(Deserialize, Debug, Clone, Default)]/// Holds crate information loaded from the Cargo.toml file.pub structCrateInfo {/// package infopubpackage:Option<PackageInfo>,/// workspace infopubworkspace:Option<Workspace>,/// crate dependenciespubdependencies:Option<IndexMap<String, CrateDependency>>,}implCrateInfo {/// Creates and returns a new instance.pub fnnew() -> CrateInfo { Default::default() }}#[derive(Debug, Clone)]/// Holds env informationpub structEnvInfo {/// Rust infopubrust_info: RustInfo,/// Crate infopubcrate_info: CrateInfo,/// Git infopubgit_info: GitInfo,/// CI infopubci_info: CiInfo,}#[derive(Debug, Clone)]/// Holds flow informationpub structFlowInfo {/// The flow config objectpubconfig: Config,/// The main task of the flowpubtask: String,/// The env infopubenv_info: EnvInfo,/// Prevent workspace supportpubdisable_workspace: bool,/// Prevent on error flow even if defined in config sectionpubdisable_on_error: bool,/// Allow invocation of private taskspuballow_private: bool,/// If true, the init and end tasks are skippedpubskip_init_end_tasks: bool,/// Skip tasks that match the provided patternpubskip_tasks_pattern:Option<Regex>,/// additional command line argumentspubcli_arguments:Option<Vec<String>>,}#[derive(Debug, Clone, Default)]/// Holds mutable flow statepub structFlowState {/// timing info for summarypubtime_summary: Vec<(String, u128)>,/// forced plugin namepubforced_plugin:Option<String>,}implFlowState {/// Creates and returns a new instance.pub fnnew() -> FlowState { Default::default() }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Rust version condition structurepub structRustVersionCondition {/// min version numberpubmin:Option<String>,/// max version numberpubmax:Option<String>,/// specific version numberpubequal:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Files modified (input/output) condition structurepub structFilesFilesModifiedCondition {/// input filespubinput: Vec<String>,/// output filespuboutput: Vec<String>,}#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]/// Control how condition checks are evaluatedpub enumConditionType {/// All conditions must passAnd,/// Any condition must passOr,/// Any condition group must pass, but each group will be validated as an ANDGroupOr,}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds condition attributespub structTaskCondition {/// condition type (AND/OR) by default ANDpubcondition_type:Option<ConditionType>,/// Failure messagepubfail_message:Option<String>,/// Profile names (development, ...)pubprofiles:Option<Vec<String>>,/// As defined in the cfg target_ospubos:Option<Vec<String>>,/// Platform names (linux, windows, mac)pubplatforms:Option<Vec<String>>,/// Channel names (stable, beta, nightly)pubchannels:Option<Vec<String>>,/// Environment variables which must be definedpubenv_set:Option<Vec<String>>,/// Environment variables which must not be definedpubenv_not_set:Option<Vec<String>>,/// Environment variables and their valuespubenv:Option<IndexMap<String, String>>,/// Environment variables and the values which they must not be defined aspubenv_not:Option<IndexMap<String, String>>,/// Environment variables which are defined as truepubenv_true:Option<Vec<String>>,/// Environment variables which are defined as falsepubenv_false:Option<Vec<String>>,/// Environment variables and the values which they are required to containpubenv_contains:Option<IndexMap<String, String>>,/// Rust version conditionpubrust_version:Option<RustVersionCondition>,/// Files existpubfiles_exist:Option<Vec<String>>,/// Files which do not existpubfiles_not_exist:Option<Vec<String>>,/// Files modified since last executionpubfiles_modified:Option<FilesFilesModifiedCondition>,}implTaskCondition {pub fnget_condition_type(&self) -> ConditionType {matchself.condition_type {Some(refvalue) => value.clone(),None=> ConditionType::And, } }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Env file path and attributespub structEnvFileInfo {/// The file path as stringpubpath: String,/// The path base directory (relative paths are from this base path)pubbase_path:Option<String>,/// The profile name this file is relevant topubprofile:Option<String>,/// If true, only set the env vars if not already definedpubdefaults_only:Option<bool>,}implEnvFileInfo {/// Creates and returns a new instance.pub fnnew(path: String) -> EnvFileInfo { EnvFileInfo { path, base_path:None, profile:None, defaults_only:None, } }}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds the env file path and attributespub enumEnvFile {/// The file path as stringPath(String),/// Extended info object for env fileInfo(EnvFileInfo),}#[derive(Serialize, Deserialize, Debug, Clone)]/// Env value provided by a scriptpub structEnvValueScript {/// The script to execute to get the env valuepubscript: Vec<String>,/// True/False to enable multi line env valuespubmulti_line:Option<bool>,/// The condition to validatepubcondition:Option<TaskCondition>,/// The explicit environment variables this script depends onpubdepends_on:Option<Vec<String>>,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Env value provided by decoding other valuespub structEnvValueDecode {/// The source value (can be an env expression)pubsource: String,/// The default value in case no decode mapping was found, if not provided it will default to the source valuepubdefault_value:Option<String>,/// The decoding mappingpubmapping: HashMap<String, String>,/// The condition to validatepubcondition:Option<TaskCondition>,}#[derive(Serialize, Deserialize, Debug, Clone, Copy)]/// Enables to unset env variablespub structEnvValueUnset {/// If true, the env variable will be unset, else ignoredpubunset: bool,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Env value set if condition is metpub structEnvValueConditioned {/// The value to set (can be an env expression)pubvalue: String,/// The condition to validatepubcondition:Option<TaskCondition>,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Env value holding a list of paths based on given glob definitionspub structEnvValuePathGlob {/// The glob used to fetch all pathspubglob: String,/// True to include files (default is true if undefined)pubinclude_files:Option<bool>,/// True to include directories (default is true if undefined)pubinclude_dirs:Option<bool>,/// Enables to respect ignore filespubignore_type:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds the env value or scriptpub enumEnvValue {/// The value as stringValue(String),/// The value as booleanBoolean(bool),/// The value as numberNumber(isize),/// The value as a list of stringsList(Vec<String>),/// Unset envUnset(EnvValueUnset),/// Script which will return the valueScript(EnvValueScript),/// Env decoding infoDecode(EnvValueDecode),/// Conditional env valueConditional(EnvValueConditioned),/// Path globPathGlob(EnvValuePathGlob),/// Profile envProfile(IndexMap<String, EnvValue>),}/// Arguments used to check whether a crate or rustup component is installed.////// Deserialize into an array of strings. Allows both a single string (which will/// become a single-element array) or a sequence of strings.#[derive(Debug, Serialize, Clone, PartialEq, Eq)]#[serde(transparent)]pub structTestArg {/// Content of the argumentspubinner: Vec<String>,}implstd::ops::DerefforTestArg {typeTarget = Vec<String>;fnderef(&self) ->&Self::Target {&self.inner }}implstd::ops::DerefMutforTestArg {fnderef_mut(&mutself) ->&mutSelf::Target {&mutself.inner }}impl<'de> serde::de::Deserialize<'de>forTestArg {fndeserialize<D>(deserializer: D) ->Result<Self, D::Error>whereD: serde::de::Deserializer<'de>, {structStringVecVisitor;impl<'de> serde::de::Visitor<'de>forStringVecVisitor {typeValue = TestArg;fnexpecting(&self, formatter:&mutstd::fmt::Formatter) -> std::fmt::Result { formatter.write_str("A string or an array of strings") }fnvisit_str<E>(self, s:&str) ->Result<Self::Value, E>whereE: serde::de::Error, {Ok(TestArg { inner:vec![s.to_string()], }) }fnvisit_seq<A>(self,mutseq: A) ->Result<Self::Value, A::Error>whereA: serde::de::SeqAccess<'de>, {letmutv = Vec::with_capacity(seq.size_hint().unwrap_or(0));while letSome(s) = seq.next_element()?{ v.push(s); }Ok(TestArg { inner: v }) } } deserializer.deserialize_any(StringVecVisitor) }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds instructions how to install the cargo pluginpub structInstallCargoPluginInfo {/// The provided crate to installpubcrate_name:Option<String>,/// Minimal versionpubmin_version:Option<String>,/// Optional alternate 'install' commandpubinstall_command:Option<String>,/// Optional add force flag (if needed), default is truepubforce:Option<bool>,}implPartialEqforInstallCargoPluginInfo {fneq(&self, other:&InstallCargoPluginInfo) -> bool {letmutsame =matchself.crate_name {Some(refcrate_name) =>matchother.crate_name {Some(refother_crate_name) => crate_name == other_crate_name,None=>false, },None=>matchother.crate_name {None=>true,_=>false, }, };if!same {returnfalse; } same =matchself.min_version {Some(refmin_version) =>matchother.min_version {Some(refother_min_version) => min_version == other_min_version,None=>false, },None=>matchother.min_version {None=>true,_=>false, }, };if!same {returnfalse; } same =matchself.install_command {Some(refinstall_command) =>matchother.install_command {Some(refother_install_command) => install_command == other_install_command,None=>false, },None=>matchother.install_command {None=>true,_=>false, }, };if!same {returnfalse; }matchself.force {Some(refforce) =>matchother.force {Some(refother_force) => force == other_force,None=>false, },None=>matchother.force {None=>true,_=>false, }, } }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds instructions how to install the cratepub structInstallCrateInfo {/// The provided crate to installpubcrate_name: String,/// If defined, the component to install via rustuppubrustup_component_name:Option<String>,/// The binary file name to be used to test if the crate is already installedpubbinary: String,/// Test arguments that will be used to check that the crate is installed.pubtest_arg: TestArg,/// Minimal versionpubmin_version:Option<String>,/// Exact versionpubversion:Option<String>,/// Optional alternate 'install' commandpubinstall_command:Option<String>,/// Optional add force flag (if needed), default is truepubforce:Option<bool>,}implPartialEqforInstallCrateInfo {fneq(&self, other:&InstallCrateInfo) -> bool {ifself.crate_name != other.crate_name ||self.binary != other.binary ||self.test_arg != other.test_arg {returnfalse; }letmutsame =matchself.rustup_component_name {Some(refrustup_component_name) =>matchother.rustup_component_name {Some(refother_rustup_component_name) => {ifrustup_component_name == other_rustup_component_name {true}else{false} }None=>false, },None=>matchother.rustup_component_name {None=>true,_=>false, }, };if!same {returnfalse; } same =matchself.min_version {Some(refmin_version) =>matchother.min_version {Some(refother_min_version) => min_version == other_min_version,None=>false, },None=>matchother.min_version {None=>true,_=>false, }, };if!same {returnfalse; } same =matchself.version {Some(refversion) =>matchother.version {Some(refother_version) => version == other_version,None=>false, },None=>matchother.version {None=>true,_=>false, }, };if!same {returnfalse; } same =matchself.install_command {Some(refinstall_command) =>matchother.install_command {Some(refother_install_command) => install_command == other_install_command,None=>false, },None=>matchother.install_command {None=>true,_=>false, }, };if!same {returnfalse; }matchself.force {Some(refforce) =>matchother.force {Some(refother_force) => force == other_force,None=>false, },None=>matchother.force {None=>true,_=>false, }, } }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds instructions how to install a rustup componentpub structInstallRustupComponentInfo {/// The component to install via rustuppubrustup_component_name: String,/// The binary file name to be used to test if the crate is already installedpubbinary:Option<String>,/// Test argument that will be used to check that the crate is installedpubtest_arg:Option<TestArg>,}implPartialEqforInstallRustupComponentInfo {fneq(&self, other:&InstallRustupComponentInfo) -> bool {ifself.rustup_component_name != other.rustup_component_name {false}else{letsame =matchself.binary {Some(refvalue) =>matchother.binary {Some(refother_value) => value == other_value,None=>false, },None=>matchother.binary {None=>true,_=>false, }, };ifsame {self.test_arg == other.test_arg }else{false} } }}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Install crate name or paramspub enumInstallCrate {/// Enables to prevent installation flowEnabled(bool),/// The value as stringValue(String),/// Install crate paramsCrateInfo(InstallCrateInfo),/// Install rustup component paramsRustupComponentInfo(InstallRustupComponentInfo),/// Install cargo plugin infoCargoPluginInfo(InstallCargoPluginInfo),}implPartialEqforInstallCrate {fneq(&self, other:&InstallCrate) -> bool {matchself{ InstallCrate::Enabled(value) =>matchother { InstallCrate::Enabled(other_value) => value == other_value,_=>false, }, InstallCrate::Value(value) =>matchother { InstallCrate::Value(other_value) => value == other_value,_=>false, }, InstallCrate::CargoPluginInfo(info) =>matchother { InstallCrate::CargoPluginInfo(other_info) => info == other_info,_=>false, }, InstallCrate::CrateInfo(info) =>matchother { InstallCrate::CrateInfo(other_info) => info == other_info,_=>false, }, InstallCrate::RustupComponentInfo(info) =>matchother { InstallCrate::RustupComponentInfo(other_info) => info == other_info,_=>false, }, } }}#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]#[serde(untagged)]/// Holds the run task name/spub enumRunTaskName {/// Single task nameSingle(String),/// Multiple task namesMultiple(Vec<String>),}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds the run task informationpub structRunTaskDetails {/// The task namepubname: RunTaskName,/// True to fork the task to a new sub processpubfork:Option<bool>,/// True to run all tasks in parallel (default false)pubparallel:Option<bool>,/// Cleanup task namepubcleanup_task:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds the run task routing informationpub structRunTaskRoutingInfo {/// The task namepubname: RunTaskName,/// True to fork the task to a new sub processpubfork:Option<bool>,/// True to run all tasks in parallel (default false)pubparallel:Option<bool>,/// Cleanup task namepubcleanup_task:Option<String>,/// if provided all condition values must be met in order for the task to be invokedpubcondition:Option<TaskCondition>,/// if script exit code is not 0, the task will not be invokedpubcondition_script:Option<ConditionScriptValue>,/// The script runner arguments before the script file pathpubcondition_script_runner_args:Option<Vec<String>>,}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Run task infopub enumRunTaskInfo {/// Task nameName(String),/// Run Task InfoDetails(RunTaskDetails),/// Task conditional selectorRouting(Vec<RunTaskRoutingInfo>),}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds watch optionspub structWatchOptions {/// Watch version to install if not already installedpubversion:Option<String>,/// Postpone first run until a file changespubpostpone:Option<bool>,/// Ignore a glob/gitignore-style patternpubignore_pattern:Option<MaybeArray<String>>,/// Do not use .gitignore filespubno_git_ignore:Option<bool>,/// Show paths that changedpubwhy:Option<bool>,/// Select which files/folders to watchpubwatch:Option<Vec<String>>,}#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]#[serde(untagged)]/// Could be an array or single valuepub enumMaybeArray<T> {/// Single valueSingle(T),/// Multiple valuesMultiple(Vec<T>),}implPartialEqforWatchOptions {fneq(&self, other:&WatchOptions) -> bool {letmutsame =matchself.version {Some(refvalue) =>matchother.version {Some(refother_value) => value == other_value,None=>false, },None=>matchother.version {None=>true,_=>false, }, }; same =ifsame {matchself.postpone {Some(refvalue) =>matchother.postpone {Some(refother_value) => value == other_value,None=>false, },None=>matchother.postpone {None=>true,_=>false, }, } }else{false}; same =ifsame {matchself.ignore_pattern {Some(refvalue) =>matchother.ignore_pattern {Some(refother_value) => value == other_value,None=>false, },None=>matchother.ignore_pattern {None=>true,_=>false, }, } }else{false}; same =ifsame {matchself.no_git_ignore {Some(refvalue) =>matchother.no_git_ignore {Some(refother_value) => value == other_value,None=>false, },None=>matchother.no_git_ignore {None=>true,_=>false, }, } }else{false};ifsame {matchself.watch {Some(refvalue) =>matchother.watch {Some(refother_value) => value == other_value,None=>false, },None=>matchother.watch {None=>true,_=>false, }, } }else{false} }}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds watch options or simple true/false valuepub enumTaskWatchOptions {/// True/False to enable/disable watchBoolean(bool),/// Extended configuration for watchOptions(WatchOptions),}implPartialEqforTaskWatchOptions {fneq(&self, other:&TaskWatchOptions) -> bool {matchself{ TaskWatchOptions::Boolean(value) =>matchother { TaskWatchOptions::Boolean(other_value) => value == other_value,_=>false, }, TaskWatchOptions::Options(info) =>matchother { TaskWatchOptions::Options(other_info) => info == other_info,_=>false, }, } }}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds deprecation info such as true/false/messagepub enumDeprecationInfo {/// True/False flag (true is deprecated)Boolean(bool),/// Deprecation messageMessage(String),}implPartialEqforDeprecationInfo {fneq(&self, other:&DeprecationInfo) -> bool {matchself{ DeprecationInfo::Boolean(value) =>matchother { DeprecationInfo::Boolean(other_value) => value == other_value,_=>false, }, DeprecationInfo::Message(message) =>matchother { DeprecationInfo::Message(other_message) => message == other_message,_=>false, }, } }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Script file namepub structFileScriptValue {/// Script file namepubfile: String,/// True for absolute path (default false)pubabsolute_path:Option<bool>,}#[derive(Serialize, Deserialize, Debug, Clone)]/// Script content split to parts to enable a more fine tuned extension capabilitypub structScriptSections {/// Script sectionpubpre:Option<String>,/// Script sectionpubmain:Option<String>,/// Script sectionpubpost:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Script value (text, file name, ...)pub enumScriptValue {/// The script text as single lineSingleLine(String),/// The script text linesText(Vec<String>),/// Script file nameFile(FileScriptValue),/// Script content split to multiple parts to enable fine tuned extensionSections(ScriptSections),}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Condition script value (not as advanced as normal script value)pub enumConditionScriptValue {/// The script text as single lineSingleLine(String),/// The script text linesText(Vec<String>),}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds a single task configuration such as command and dependencies listpub structTask {/// if true, it should ignore all data in base taskpubclear:Option<bool>,/// Task descriptionpubdescription:Option<String>,/// Category name used to document the taskpubcategory:Option<String>,/// if true, the command/script of this task will not be invoked, dependencies however will bepubdisabled:Option<bool>,/// if true, the task is hidden from the list of available tasks and also cannot be invoked directly from clipubprivate:Option<bool>,/// if not false, this task is defined as deprecatedpubdeprecated:Option<DeprecationInfo>,/// Extend any task based on the defined namepubextend:Option<String>,/// set to false to notify cargo-make that this is not a workspace and should not call task for every member (same as --no-workspace CLI flag)pubworkspace:Option<bool>,/// Optional plugin used to execute the taskpubplugin:Option<String>,/// set to true to watch for file changes and invoke the task operationpubwatch:Option<TaskWatchOptions>,/// if provided all condition values must be met in order for the task to be invoked (will not stop dependencies)pubcondition:Option<TaskCondition>,/// if script exit code is not 0, the command/script of this task will not be invoked, dependencies however will bepubcondition_script:Option<ConditionScriptValue>,/// The script runner arguments before the script file pathpubcondition_script_runner_args:Option<Vec<String>>,/// if true, any error while executing the task will be printed but will not break the buildpubignore_errors:Option<bool>,/// DEPRECATED, replaced with ignore_errorspubforce:Option<bool>,/// The env files to setup before running the task commandspubenv_files:Option<Vec<EnvFile>>,/// The env vars to setup before running the task commandspubenv:Option<IndexMap<String, EnvValue>>,/// The working directory for the task to execute its command/scriptpubcwd:Option<String>,/// if defined, task points to another task and all other properties are ignoredpubalias:Option<String>,/// acts like alias if runtime OS is Linux (takes precedence over alias)publinux_alias:Option<String>,/// acts like alias if runtime OS is Windows (takes precedence over alias)pubwindows_alias:Option<String>,/// acts like alias if runtime OS is Mac (takes precedence over alias)pubmac_alias:Option<String>,/// if defined, the provided crate will be installed (if needed) before running the taskpubinstall_crate:Option<InstallCrate>,/// additional cargo install argumentspubinstall_crate_args:Option<Vec<String>>,/// if defined, the provided script will be executed before running the taskpubinstall_script:Option<ScriptValue>,/// The command to executepubcommand:Option<String>,/// The command argspubargs:Option<Vec<String>>,/// If command is not defined, and script is defined, the provided script will be executedpubscript:Option<ScriptValue>,/// The script runner (defaults to cmd in windows and sh for other platforms)pubscript_runner:Option<String>,/// The script runner arguments before the script file pathpubscript_runner_args:Option<Vec<String>>,/// The script file extensionpubscript_extension:Option<String>,/// The task name to executepubrun_task:Option<RunTaskInfo>,/// A list of tasks to execute before this taskpubdependencies:Option<Vec<DependencyIdentifier>>,/// The rust toolchain used to invoke the command or install the needed crates/componentspubtoolchain:Option<ToolchainSpecifier>,/// override task if runtime OS is Linux (takes precedence over alias)publinux:Option<PlatformOverrideTask>,/// override task if runtime OS is Windows (takes precedence over alias)pubwindows:Option<PlatformOverrideTask>,/// override task if runtime OS is Mac (takes precedence over alias)pubmac:Option<PlatformOverrideTask>,}/// A toolchain, defined either as a string (following the rustup syntax)/// or a ToolchainBoundedSpecifier.#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]#[serde(untagged)]pub enumToolchainSpecifier {/// A string specifying the channel name of the toolchainSimple(String),/// A toolchain with a minimum version boundBounded(ToolchainBoundedSpecifier),}implFrom<String>forToolchainSpecifier {fnfrom(channel: String) ->Self{Self::Simple(channel) }}implFrom<&str>forToolchainSpecifier {fnfrom(channel:&str) ->Self{ channel.to_string().into() }}implstd::fmt::DisplayforToolchainSpecifier {fnfmt(&self, formatter:&mutstd::fmt::Formatter<'_>) -> std::fmt::Result {matchself{Self::Simple(refchannel) =>write!(formatter,"{}", channel),Self::Bounded(refspec) =>write!(formatter,"{}", spec), } }}implToolchainSpecifier {/// Return the channel of the toolchain to look forpub fnchannel(&self) ->&str {matchself{Self::Simple(refchannel) =>&channel,Self::Bounded(ToolchainBoundedSpecifier {refchannel, .. }) => channel, } }/// Return the minimal version, if any, to look forpub fnmin_version(&self) ->Option<&str> {matchself{Self::Simple(_) =>None,Self::Bounded(ToolchainBoundedSpecifier {refmin_version, .. }) =>Some(min_version), } }}/// A toolchain with a minimum version bound#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]pub structToolchainBoundedSpecifier {/// The channel of the toolchain to usepubchannel: String,/// The minimum version to matchpubmin_version: String,}implstd::fmt::DisplayforToolchainBoundedSpecifier {fnfmt(&self, formatter:&mutstd::fmt::Formatter<'_>) -> std::fmt::Result {write!(formatter,"{} >= {}",self.channel,self.min_version) }}/// A dependency, defined either as a string or as a Dependency object#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]#[serde(untagged)]pub enumDependencyIdentifier {/// A full dependency definition (potentially in a different file)Definition(TaskIdentifier),/// A string dependency definition (its name in the current file)Name(String),}implFrom<&str>forDependencyIdentifier {fnfrom(name:&str) ->Self{ DependencyIdentifier::Name(name.to_string()) }}implDependencyIdentifier {/// Get the name of a dependencypub fnname(&self) ->&str {matchself{ DependencyIdentifier::Definition(identifier) =>&identifier.name, DependencyIdentifier::Name(name) => name, } }/// Adorn the TaskIdentifier with a namespacepub fnwith_namespace(self, namespace:&str) ->Self{matchself{ DependencyIdentifier::Definition(mutidentifier) => { identifier.name = get_namespaced_task_name(namespace,&identifier.name); DependencyIdentifier::Definition(identifier) } DependencyIdentifier::Name(name) => { DependencyIdentifier::Name(get_namespaced_task_name(namespace,&name)) } } }}/// An identifier for a task#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]pub structTaskIdentifier {/// The task name to executepubname: String,/// The path to the makefile the task resides inpubpath:Option<String>,}implstd::fmt::DisplayforTaskIdentifier {fnfmt(&self, formatter:&mutstd::fmt::Formatter<'_>) -> std::fmt::Result {match&self.path {Some(path) =>write!(formatter,"{}:{}", path,self.name),None=>write!(formatter,"{}",self.name), } }}implTaskIdentifier {/// Create a new TaskIdentifier referencing a task in the current filepub fnfrom_name(name:&str) ->Self{Self{ name: name.to_string(), path:None, } }}implInto<TaskIdentifier>forDependencyIdentifier {fninto(self) -> TaskIdentifier {matchself{ DependencyIdentifier::Definition(identifier) => identifier, DependencyIdentifier::Name(name) => TaskIdentifier { name, path:None}, } }}implTask {/// Creates and returns a new instance.pub fnnew() -> Task { Default::default() }/// Apply modificationspub fnapply(self:&mutTask, modify_config:&ModifyConfig) {matchmodify_config.private {Some(value) => {ifvalue {self.private =Some(true); } }None=> (), };matchmodify_config.namespace {Some(refnamespace) => {ifnamespace.len() >0{ifself.extend.is_some() {self.extend =Some(get_namespaced_task_name( namespace,&self.extend.clone().unwrap(), )); }ifself.alias.is_some() {self.alias =Some(get_namespaced_task_name( namespace,&self.alias.clone().unwrap(), )); }ifself.linux_alias.is_some() {self.linux_alias =Some(get_namespaced_task_name( namespace,&self.linux_alias.clone().unwrap(), )); }ifself.windows_alias.is_some() {self.windows_alias =Some(get_namespaced_task_name( namespace,&self.windows_alias.clone().unwrap(), )); }ifself.mac_alias.is_some() {self.mac_alias =Some(get_namespaced_task_name( namespace,&self.mac_alias.clone().unwrap(), )); }ifself.run_task.is_some() {letmutrun_task =self.run_task.clone().unwrap(); run_task =matchrun_task { RunTaskInfo::Name(value) => { RunTaskInfo::Name(get_namespaced_task_name(namespace,&value)) } RunTaskInfo::Details(mutrun_task_details) => {matchrun_task_details.name { RunTaskName::Single(refname) => { run_task_details.name = RunTaskName::Single( get_namespaced_task_name(namespace, name), ) } RunTaskName::Multiple(refnames) => {letmutupdated_names =vec![];fornameinnames { updated_names .push(get_namespaced_task_name(namespace, name)); } run_task_details.name = RunTaskName::Multiple(updated_names); } }; RunTaskInfo::Details(run_task_details) } RunTaskInfo::Routing(mutrouting_info_vector) => {forrouting_infoin&mutrouting_info_vector {matchrouting_info.name { RunTaskName::Single(refname) => { routing_info.name = RunTaskName::Single( get_namespaced_task_name(namespace, name), ) } RunTaskName::Multiple(refnames) => {letmutupdated_names =vec![];fornameinnames { updated_names.push(get_namespaced_task_name( namespace, name, )); } routing_info.name = RunTaskName::Multiple(updated_names); } }; } RunTaskInfo::Routing(routing_info_vector) } };self.run_task =Some(run_task); }if letSome(dependencies) =&self.dependencies {self.dependencies =Some( dependencies .iter() .map(|identifier| identifier.to_owned().with_namespace(namespace)) .collect(), ); } } }None=> (), }; }/// Copies values from the task into self. /// /// # Arguments /// /// * `task` - The task to copy frompub fnextend(self:&mutTask, task:&Task) {letoverride_values =matchtask.clear {Some(value) => value,None=>false, };iftask.clear.is_some() {self.clear = task.clear.clone(); }iftask.description.is_some() {self.description = task.description.clone(); }else ifoverride_values {self.description =None; }iftask.category.is_some() {self.category = task.category.clone(); }else ifoverride_values {self.category =None; }iftask.disabled.is_some() {self.disabled = task.disabled.clone(); }else ifoverride_values {self.disabled =None; }iftask.private.is_some() {self.private = task.private.clone(); }else ifoverride_values {self.private =None; }iftask.deprecated.is_some() {self.deprecated = task.deprecated.clone(); }else ifoverride_values {self.deprecated =None; }iftask.extend.is_some() {self.extend = task.extend.clone(); }else ifoverride_values {self.extend =None; }iftask.workspace.is_some() {self.workspace = task.workspace.clone(); }else ifoverride_values {self.workspace =None; }iftask.plugin.is_some() {self.plugin = task.plugin.clone(); }else ifoverride_values {self.plugin =None; }iftask.watch.is_some() {self.watch = task.watch.clone(); }else ifoverride_values {self.watch =None; }iftask.condition.is_some() {self.condition = task.condition.clone(); }else ifoverride_values {self.condition =None; }iftask.condition_script.is_some() {self.condition_script = task.condition_script.clone(); }else ifoverride_values {self.condition_script =None; }iftask.condition_script_runner_args.is_some() {self.condition_script_runner_args = task.condition_script_runner_args.clone(); }else ifoverride_values {self.condition_script_runner_args =None; }iftask.ignore_errors.is_some() {self.ignore_errors = task.ignore_errors.clone(); }else ifoverride_values {self.ignore_errors =None; }iftask.force.is_some() {self.force = task.force.clone(); }else ifoverride_values {self.force =None; }iftask.env_files.is_some() {self.env_files = task.env_files.clone(); }else ifoverride_values {self.env_files =None; }iftask.env.is_some() {self.env = task.env.clone(); }else ifoverride_values {self.env =None; }iftask.cwd.is_some() {self.cwd = task.cwd.clone(); }else ifoverride_values {self.cwd =None; }iftask.alias.is_some() {self.alias = task.alias.clone(); }else ifoverride_values {self.alias =None; }iftask.linux_alias.is_some() {self.linux_alias = task.linux_alias.clone(); }else ifoverride_values {self.linux_alias =None; }iftask.windows_alias.is_some() {self.windows_alias = task.windows_alias.clone(); }else ifoverride_values {self.windows_alias =None; }iftask.mac_alias.is_some() {self.mac_alias = task.mac_alias.clone(); }else ifoverride_values {self.mac_alias =None; }iftask.install_crate.is_some() {self.install_crate = task.install_crate.clone(); }else ifoverride_values {self.install_crate =None; }iftask.install_crate_args.is_some() {self.install_crate_args = task.install_crate_args.clone(); }else ifoverride_values {self.install_crate_args =None; }iftask.install_script.is_some() {self.install_script = extend_script_value(self.install_script.clone(), task.install_script.clone()); }else ifoverride_values {self.install_script =None; }iftask.command.is_some() {self.command = task.command.clone(); }else ifoverride_values {self.command =None; }iftask.args.is_some() {self.args = task.args.clone(); }else ifoverride_values {self.args =None; }iftask.script.is_some() {self.script = extend_script_value(self.script.clone(), task.script.clone()); }else ifoverride_values {self.script =None; }iftask.script_runner.is_some() {self.script_runner = task.script_runner.clone(); }else ifoverride_values {self.script_runner =None; }iftask.script_runner_args.is_some() {self.script_runner_args = task.script_runner_args.clone(); }else ifoverride_values {self.script_runner_args =None; }iftask.script_extension.is_some() {self.script_extension = task.script_extension.clone(); }else ifoverride_values {self.script_extension =None; }iftask.run_task.is_some() {self.run_task = task.run_task.clone(); }else ifoverride_values {self.run_task =None; }iftask.dependencies.is_some() {self.dependencies = task.dependencies.clone(); }else ifoverride_values {self.dependencies =None; }iftask.toolchain.is_some() {self.toolchain = task.toolchain.clone(); }else ifoverride_values {self.toolchain =None; }iftask.linux.is_some() {self.linux = task.linux.clone(); }else ifoverride_values {self.linux =None; }iftask.windows.is_some() {self.windows = task.windows.clone(); }else ifoverride_values {self.windows =None; }iftask.mac.is_some() {self.mac = task.mac.clone(); }else ifoverride_values {self.mac =None; } }/// Returns true if the task ignore_errors attribute is defined and truepub fnshould_ignore_errors(self:&Task) -> bool {matchself.ignore_errors {Some(value) => value,None=>matchself.force {Some(value) => { legacy::show_deprecated_attriute_warning("force","ignore_errors"); value }None=>false, }, } }/// Returns the override task definition based on the current platform.fnget_override(self:&Task) ->Option<PlatformOverrideTask> {letplatform_name = get_platform_name();ifplatform_name =="windows"{matchself.windows {Some(refvalue) =>Some(value.clone()),_=>None, } }else ifplatform_name =="mac"{matchself.mac {Some(refvalue) =>Some(value.clone()),_=>None, } }else{matchself.linux {Some(refvalue) =>Some(value.clone()),_=>None, } } }/// Returns a new task based on the override information and current platform.pub fnget_normalized_task(self:&mutTask) -> Task {matchself.get_override() {Some(ref mutoverride_task) => { override_task.extend(self); Task { clear:self.clear.clone(), description:self.description.clone(), category:self.category.clone(), disabled: override_task.disabled.clone(), private: override_task.private.clone(), deprecated: override_task.deprecated.clone(), extend: override_task.extend.clone(), workspace:self.workspace.clone(), plugin: override_task.plugin.clone(), watch: override_task.watch.clone(), condition: override_task.condition.clone(), condition_script: override_task.condition_script.clone(), condition_script_runner_args: override_task .condition_script_runner_args .clone(), ignore_errors: override_task.ignore_errors.clone(), force: override_task.force.clone(), env_files: override_task.env_files.clone(), env: override_task.env.clone(), cwd: override_task.cwd.clone(), alias:None, linux_alias:None, windows_alias:None, mac_alias:None, install_crate: override_task.install_crate.clone(), install_crate_args: override_task.install_crate_args.clone(), install_script: override_task.install_script.clone(), command: override_task.command.clone(), args: override_task.args.clone(), script: override_task.script.clone(), script_runner: override_task.script_runner.clone(), script_runner_args: override_task.script_runner_args.clone(), script_extension: override_task.script_extension.clone(), run_task: override_task.run_task.clone(), dependencies: override_task.dependencies.clone(), toolchain: override_task.toolchain.clone(), linux:None, windows:None, mac:None, } }None=>self.clone(), } }/// Returns the alias value based on the current platform and task definition.pub fnget_alias(self:&Task) ->Option<String> {letalias =ifcfg!(windows) {matchself.windows_alias {Some(refvalue) =>Some(value),_=>None, } }else ifcfg!(target_os ="macos") ||cfg!(target_os ="ios") {matchself.mac_alias {Some(refvalue) =>Some(value),_=>None, } }else{matchself.linux_alias {Some(refvalue) =>Some(value),_=>None, } };matchalias {Some(os_alias) =>Some(os_alias.clone()),_=>matchself.alias {Some(refalias) =>Some(alias.clone()),_=>None, }, } }/// Returns the amount of actions defined on the taskpub fnget_actions_count(self:&Task) -> u8 {letmutactions_count =0;ifself.run_task.is_some() { actions_count = actions_count +1; }ifself.command.is_some() { actions_count = actions_count +1; }ifself.script.is_some() { actions_count = actions_count +1; } actions_count }/// Returns true if the task has any actions on its own /// or if it modifies the environment in any way.pub fnis_actionable(self:&Task) -> bool {ifself.disabled.unwrap_or(false) {returnfalse; }letactions_count =self.get_actions_count();ifactions_count >0{returntrue; }ifself.install_crate.is_some() ||self.install_script.is_some() {returntrue; }letmutactionable =matchself.env {Some(refvalue) => value.len() >0,None=>false, };ifactionable {returntrue; } actionable =matchself.env_files {Some(refvalue) => value.len() >0,None=>false, };ifactionable {returntrue; } actionable =matchself.dependencies {Some(refvalue) => value.len() >0,None=>false, };ifactionable {returntrue; } actionable =matchself.watch {Some(refoptions) =>matchoptions { TaskWatchOptions::Boolean(value) =>*value,_=>true, },None=>false, }; actionable }/// Returns true if the task is validpub fnis_valid(self:&Task) -> bool {letactions_count =self.get_actions_count();ifactions_count <=1{true}else{false} }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds a single task configuration for a specific platform as an override of another taskpub structPlatformOverrideTask {/// if true, it should ignore all data in base taskpubclear:Option<bool>,/// if true, the command/script of this task will not be invoked, dependencies however will bepubdisabled:Option<bool>,/// if true, the task is hidden from the list of available tasks and also cannot be invoked directly from clipubprivate:Option<bool>,/// if not false, this task is defined as deprecatedpubdeprecated:Option<DeprecationInfo>,/// Extend any task based on the defined namepubextend:Option<String>,/// Optional plugin used to execute the taskpubplugin:Option<String>,/// set to true to watch for file changes and invoke the task operationpubwatch:Option<TaskWatchOptions>,/// if provided all condition values must be met in order for the task to be invoked (will not stop dependencies)pubcondition:Option<TaskCondition>,/// if script exit code is not 0, the command/script of this task will not be invoked, dependencies however will bepubcondition_script:Option<ConditionScriptValue>,/// The script runner arguments before the script file pathpubcondition_script_runner_args:Option<Vec<String>>,/// if true, any error while executing the task will be printed but will not break the buildpubignore_errors:Option<bool>,/// DEPRECATED, replaced with ignore_errorspubforce:Option<bool>,/// The env files to setup before running the task commandspubenv_files:Option<Vec<EnvFile>>,/// The env vars to setup before running the task commandspubenv:Option<IndexMap<String, EnvValue>>,/// The working directory for the task to execute its command/scriptpubcwd:Option<String>,/// if defined, the provided crate will be installed (if needed) before running the taskpubinstall_crate:Option<InstallCrate>,/// additional cargo install argumentspubinstall_crate_args:Option<Vec<String>>,/// if defined, the provided script will be executed before running the taskpubinstall_script:Option<ScriptValue>,/// The command to executepubcommand:Option<String>,/// The command argspubargs:Option<Vec<String>>,/// If command is not defined, and script is defined, the provided script will be executedpubscript:Option<ScriptValue>,/// The script runner (defaults to cmd in windows and sh for other platforms)pubscript_runner:Option<String>,/// The script runner arguments before the script file pathpubscript_runner_args:Option<Vec<String>>,/// The script file extensionpubscript_extension:Option<String>,/// The task name to executepubrun_task:Option<RunTaskInfo>,/// A list of tasks to execute before this taskpubdependencies:Option<Vec<DependencyIdentifier>>,/// The rust toolchain used to invoke the command or install the needed crates/componentspubtoolchain:Option<ToolchainSpecifier>,}implPlatformOverrideTask {/// Copies values from the task into self. /// /// # Arguments /// /// * `task` - The task to copy frompub fnextend(self:&mutPlatformOverrideTask, task:&mutTask) {letcopy_values =matchself.clear {Some(value) => !value,None=>true, };ifcopy_values {ifself.disabled.is_none() && task.disabled.is_some() {self.disabled = task.disabled.clone(); }ifself.private.is_none() && task.private.is_some() {self.private = task.private.clone(); }ifself.deprecated.is_none() && task.deprecated.is_some() {self.deprecated = task.deprecated.clone(); }ifself.extend.is_none() && task.extend.is_some() {self.extend = task.extend.clone(); }ifself.plugin.is_none() && task.plugin.is_some() {self.plugin = task.plugin.clone(); }ifself.watch.is_none() && task.watch.is_some() {self.watch = task.watch.clone(); }ifself.condition.is_none() && task.condition.is_some() {self.condition = task.condition.clone(); }ifself.condition_script.is_none() && task.condition_script.is_some() {self.condition_script = task.condition_script.clone(); }ifself.condition_script_runner_args.is_none() && task.condition_script_runner_args.is_some() {self.condition_script_runner_args = task.condition_script_runner_args.clone(); }ifself.ignore_errors.is_none() && task.ignore_errors.is_some() {self.ignore_errors = task.ignore_errors.clone(); }ifself.force.is_none() && task.force.is_some() {self.force = task.force.clone(); }ifself.env_files.is_none() && task.env_files.is_some() {self.env_files = task.env_files.clone(); }ifself.env.is_none() && task.env.is_some() {self.env = task.env.clone(); }ifself.cwd.is_none() && task.cwd.is_some() {self.cwd = task.cwd.clone(); }ifself.install_crate.is_none() && task.install_crate.is_some() {self.install_crate = task.install_crate.clone(); }ifself.install_crate_args.is_none() && task.install_crate_args.is_some() {self.install_crate_args = task.install_crate_args.clone(); }ifself.install_script.is_none() && task.install_script.is_some() {self.install_script = extend_script_value(self.install_script.clone(), task.install_script.clone()); }ifself.command.is_none() && task.command.is_some() {self.command = task.command.clone(); }ifself.args.is_none() && task.args.is_some() {self.args = task.args.clone(); }ifself.script.is_none() && task.script.is_some() {self.script = extend_script_value(None, task.script.clone()); }ifself.script_runner.is_none() && task.script_runner.is_some() {self.script_runner = task.script_runner.clone(); }ifself.script_runner_args.is_none() && task.script_runner_args.is_some() {self.script_runner_args = task.script_runner_args.clone(); }ifself.script_extension.is_none() && task.script_extension.is_some() {self.script_extension = task.script_extension.clone(); }ifself.run_task.is_none() && task.run_task.is_some() {self.run_task = task.run_task.clone(); }ifself.dependencies.is_none() && task.dependencies.is_some() {self.dependencies = task.dependencies.clone(); }ifself.toolchain.is_none() && task.toolchain.is_some() {self.toolchain = task.toolchain.clone(); } } }}#[derive(Serialize, Deserialize, Debug, Clone)]/// Extend with more fine tuning optionspub structExtendOptions {/// Path to another makefilepubpath: String,/// Enable optional extend (default to false)puboptional:Option<bool>,/// Relative to option, sub as current makefile, git root, crate root, workspace root, etc... /// Possible values: (makefile, git, crate, workspace)pubrelative:Option<String>,}#[derive(Serialize, Deserialize, Debug, Clone)]#[serde(untagged)]/// Holds makefile extend valuepub enumExtend {/// Path to another makefilePath(String),/// Extend options for more fine tune controlOptions(ExtendOptions),/// Multiple extends listList(Vec<ExtendOptions>),}#[derive(Serialize, Deserialize, Debug, Clone)]/// Holds properties to modify the core taskspub structModifyConfig {/// If true, all core tasks will be set to private (default false)pubprivate:Option<bool>,/// If set to some value, all core tasks are modified to: namespace::name for example default::buildpubnamespace:Option<String>,}implModifyConfig {/// Returns true if config modifications is needed based on the current statepub fnis_modifications_defined(self:&ModifyConfig) -> bool {ifself.private.unwrap_or(false) {true}else{matchself.namespace {Some(refvalue) => value.len() >0,None=>false, } } }/// Returns the namespace prefix for task namespub fnget_namespace_prefix(self:&ModifyConfig) -> String {matchself.namespace {Some(refvalue) => get_namespaced_task_name(value,""),None=>"".to_string(), } }}#[derive(Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq)]#[serde(rename_all ="SCREAMING_SNAKE_CASE")]/// Unstable cargo-make featurepub enumUnstableFeature {/// Gracefully shutdown and then kill the running command on Ctrl+C signalCtrlCHandling,}implUnstableFeature {/// Creates the env. variable name associated to the featurepub fnto_env_name(&self) -> String {letmutfeature = serde_json::to_string(&self).unwrap(); feature = feature.replace("\"","");format!("CARGO_MAKE_UNSTABLE_FEATURE_{feature}", feature = feature) }/// Is the corresponding env. variable set?pub fnis_env_set(&self) -> bool { envmnt::is(self.to_env_name()) }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds the configuration found in the makefile toml config section.pub structConfigSection {/// If true, the default core tasks will not be loadedpubskip_core_tasks:Option<bool>,/// Modify core tasks configpubmodify_core_tasks:Option<ModifyConfig>,/// Init task name which will be invoked at the start of every runpubinit_task:Option<String>,/// End task name which will be invoked at the end of every runpubend_task:Option<String>,/// The name of the task to run in case of any error during the invocation of the flowpubon_error_task:Option<String>,/// The name of the task which runs legacy migration flowspublegacy_migration_task:Option<String>,/// Additional profile names to loadpubadditional_profiles:Option<Vec<String>>,/// Minimum cargo-make/makers versionpubmin_version:Option<String>,/// The task.workspace default valuepubdefault_to_workspace:Option<bool>,/// do not load git env info (save on perf)pubskip_git_env_info:Option<bool>,/// do not load rust env info (save on perf)pubskip_rust_env_info:Option<bool>,/// do not load current crate env info (save on perf)pubskip_crate_env_info:Option<bool>,/// True to reduce console output for non CI executionpubreduce_output:Option<bool>,/// True to print time summary at the end of the flowpubtime_summary:Option<bool>,/// Automatically load cargo aliases as cargo-make taskspubload_cargo_aliases:Option<bool>,/// If true (default false) disable all automatic/defined installation instructionspubdisable_install:Option<bool>,/// The project information member (used by workspaces)pubmain_project_member:Option<String>,/// Invoked while loading the descriptor file but before loading any extended descriptorpubload_script:Option<ScriptValue>,/// acts like load_script if runtime OS is Linux (takes precedence over load_script)publinux_load_script:Option<ScriptValue>,/// acts like load_script if runtime OS is Windows (takes precedence over load_script)pubwindows_load_script:Option<ScriptValue>,/// acts like load_script if runtime OS is Mac (takes precedence over load_script)pubmac_load_script:Option<ScriptValue>,/// Enables unstable cargo-make featurespubunstable_features:Option<IndexSet<UnstableFeature>>,}implConfigSection {/// Creates and returns a new instance.pub fnnew() -> ConfigSection { Default::default() }/// Apply modificationspub fnapply(self:&mutConfigSection, modify_config:&ModifyConfig) {matchmodify_config.namespace {Some(refnamespace) => {ifself.init_task.is_some() {self.init_task =Some(get_namespaced_task_name( namespace,&self.init_task.clone().unwrap(), )); }ifself.end_task.is_some() {self.end_task =Some(get_namespaced_task_name( namespace,&self.end_task.clone().unwrap(), )); }ifself.on_error_task.is_some() {self.on_error_task =Some(get_namespaced_task_name( namespace,&self.on_error_task.clone().unwrap(), )); }ifself.legacy_migration_task.is_some() {self.legacy_migration_task =Some(get_namespaced_task_name( namespace,&self.legacy_migration_task.clone().unwrap(), )); } }None=> (), } }/// Copies values from the config section into self. /// /// # Arguments /// /// * `task` - The task to copy frompub fnextend(self:&mutConfigSection, extended:&mutConfigSection) {ifextended.skip_core_tasks.is_some() {self.skip_core_tasks = extended.skip_core_tasks.clone(); }ifextended.modify_core_tasks.is_some() {self.modify_core_tasks = extended.modify_core_tasks.clone(); }ifextended.init_task.is_some() {self.init_task = extended.init_task.clone(); }ifextended.end_task.is_some() {self.end_task = extended.end_task.clone(); }ifextended.on_error_task.is_some() {self.on_error_task = extended.on_error_task.clone(); }ifextended.legacy_migration_task.is_some() {self.legacy_migration_task = extended.legacy_migration_task.clone(); }ifextended.additional_profiles.is_some() {self.additional_profiles = extended.additional_profiles.clone(); }ifextended.min_version.is_some() {self.min_version = extended.min_version.clone(); }ifextended.default_to_workspace.is_some() {self.default_to_workspace = extended.default_to_workspace.clone(); }ifextended.skip_git_env_info.is_some() {self.skip_git_env_info = extended.skip_git_env_info.clone(); }ifextended.skip_rust_env_info.is_some() {self.skip_rust_env_info = extended.skip_rust_env_info.clone(); }ifextended.skip_crate_env_info.is_some() {self.skip_crate_env_info = extended.skip_crate_env_info.clone(); }ifextended.reduce_output.is_some() {self.reduce_output = extended.reduce_output.clone(); }ifextended.time_summary.is_some() {self.time_summary = extended.time_summary.clone(); }ifextended.load_cargo_aliases.is_some() {self.load_cargo_aliases = extended.load_cargo_aliases.clone(); }ifextended.disable_install.is_some() {self.disable_install = extended.disable_install.clone(); }ifextended.main_project_member.is_some() {self.main_project_member = extended.main_project_member.clone(); }ifextended.load_script.is_some() {self.load_script = extend_script_value(self.load_script.clone(), extended.load_script.clone()); }ifextended.linux_load_script.is_some() {self.linux_load_script = extend_script_value(self.linux_load_script.clone(), extended.linux_load_script.clone(), ); }ifextended.windows_load_script.is_some() {self.windows_load_script = extend_script_value(self.windows_load_script.clone(), extended.windows_load_script.clone(), ); }ifextended.mac_load_script.is_some() {self.mac_load_script = extend_script_value(self.mac_load_script.clone(), extended.mac_load_script.clone(), ); }if letSome(extended_unstable_features) = extended.unstable_features.clone() {if letSome(unstable_features) =&mutself.unstable_features { unstable_features.extend(extended_unstable_features); }else{self.unstable_features =Some(extended_unstable_features); } } }/// Returns the load script based on the current platformpub fnget_load_script(self:&ConfigSection) ->Option<ScriptValue> {letplatform_name = get_platform_name();ifplatform_name =="windows"{ifself.windows_load_script.is_some() {self.windows_load_script.clone() }else{self.load_script.clone() } }else ifplatform_name =="mac"{ifself.mac_load_script.is_some() {self.mac_load_script.clone() }else{self.load_script.clone() } }else{ifself.linux_load_script.is_some() {self.linux_load_script.clone() }else{self.load_script.clone() } } }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds the entire configuration such as task definitions and env varspub structConfig {/// Runtime configpubconfig: ConfigSection,/// The env files to setup before running the flowpubenv_files: Vec<EnvFile>,/// The env vars to setup before running the flowpubenv: IndexMap<String, EnvValue>,/// The env scripts to execute before running the flowpubenv_scripts: Vec<String>,/// All task definitionspubtasks: IndexMap<String, Task>,/// All plugin definitionspubplugins:Option<Plugins>,}implConfig {/// Apply modificationspub fnapply(self:&mutConfig, modify_config:&ModifyConfig) {self.config.apply(&modify_config);letnamespace =matchmodify_config.namespace {Some(refnamespace) => namespace,None=>"", };letmutmodified_tasks = IndexMap::<String, Task>::new();for(key, value)inself.tasks.iter() {letnamespaced_task = get_namespaced_task_name(namespace,&key);letmuttask = value.clone(); task.apply(&modify_config); modified_tasks.insert(namespaced_task, task); }self.tasks = modified_tasks; }}#[derive(Serialize, Deserialize, Debug, Clone, Default)]/// Holds the entire externally read configuration such as task definitions and env vars where all values are optionalpub structExternalConfig {/// Path to another toml file to extendpubextend:Option<Extend>,/// Runtime configpubconfig:Option<ConfigSection>,/// The env files to setup before running the flowpubenv_files:Option<Vec<EnvFile>>,/// The env vars to setup before running the flowpubenv:Option<IndexMap<String, EnvValue>>,/// The env scripts to execute before running the flowpubenv_scripts:Option<Vec<String>>,/// All task definitionspubtasks:Option<IndexMap<String, Task>>,/// All plugin definitionspubplugins:Option<Plugins>,}implExternalConfig {/// Creates and returns a new instance.pub fnnew() -> ExternalConfig { Default::default() }}#[derive(Serialize, Clone, Debug)]/// Execution plan step to executepub structStep {/// The task namepubname: String,/// The task configpubconfig: Task,}#[derive(Debug)]/// Execution plan which defines all steps to run and the order to run thempub structExecutionPlan {/// A list of steps to executepubsteps: Vec<Step>,}#[derive(Debug)]/// Command infopub structCommandSpec {/// The command to executepubcommand: String,/// The command argspubargs:Option<Vec<String>>,}