Movatterモバイル変換


[0]ホーム

URL:


cli/
types.rs

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467
//! # 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>>,}

[8]ページ先頭

©2009-2025 Movatter.jp