From aaa92abf49ed624fe5cfaba0a15949871151308d Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Sun, 9 Jun 2024 14:27:17 +0400 Subject: [PATCH] update deps, improve method names, impl manifest validation for specified target --- Cargo.lock | 176 +++++++++++++---------- Cargo.toml | 2 +- cargo/src/package/mod.rs | 4 +- support/build/src/metadata/source.rs | 16 +-- support/build/src/metadata/validation.rs | 17 ++- 5 files changed, 123 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9356fa9..19c22e79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,9 +98,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329972aa325176e89114919f2a80fdae4f4c040f66a370b1a1159c6c0f94e7aa" +checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" dependencies = [ "async-io 2.3.3", "async-lock 3.4.0", @@ -769,7 +769,7 @@ dependencies = [ "serde_json", "target", "toml", - "toml_edit 0.22.13", + "toml_edit 0.22.14", "try-lazy-init", "walkdir", "zip 1.1.4", @@ -816,9 +816,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", @@ -875,9 +875,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", "clap_derive", @@ -885,9 +885,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", @@ -900,9 +900,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -912,9 +912,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clru" @@ -1815,19 +1815,19 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -dependencies = [ - "fallible-iterator 0.3.0", - "stable_deref_trait", -] +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gimli" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "e2e1d97fbe9722ba9bbd0c97051c2956e726562b61f86a25a4360398a40edfc9" +dependencies = [ + "fallible-iterator 0.3.0", + "stable_deref_trait", +] [[package]] name = "git2" @@ -2619,13 +2619,13 @@ dependencies = [ [[package]] name = "goblin" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27c1b4369c2cd341b5de549380158b105a04c331be5db9110eef7b6d2742134" +checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" dependencies = [ "log", "plain", - "scroll", + "scroll 0.12.0", ] [[package]] @@ -2672,6 +2672,7 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", + "serde", ] [[package]] @@ -2829,9 +2830,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2927,6 +2928,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.5", + "serde", ] [[package]] @@ -3508,11 +3510,11 @@ dependencies = [ [[package]] name = "msvc-demangler" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb67c6dd0fa9b00619c41c5700b6f92d5f418be49b45ddb9970fbd4569df3c8" +checksum = "c4c25a3bb7d880e8eceab4822f3141ad0700d20f025991c1f03bd3d00219a5fc" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] @@ -3893,7 +3895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82040a392923abe6279c00ab4aff62d5250d1c8555dc780e4b02783a7aa74863" dependencies = [ "fallible-iterator 0.2.0", - "scroll", + "scroll 0.11.0", "uuid", ] @@ -4778,15 +4780,21 @@ name = "scroll" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" + +[[package]] +name = "scroll" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" dependencies = [ "scroll_derive", ] [[package]] name = "scroll_derive" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" +checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", @@ -5308,9 +5316,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "symbolic" -version = "12.8.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec4f53c56d7ee8809c2322925d362e193bcc7bbe7e777a3304b34ea7e85a36" +checksum = "85aabcf85c883278298596217d678c8d3ca256445d732eac59303ce04863c46f" dependencies = [ "symbolic-common", "symbolic-debuginfo", @@ -5319,9 +5327,9 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "12.8.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cccfffbc6bb3bb2d3a26cd2077f4d055f6808d266f9d4d158797a4c60510dfe" +checksum = "71297dc3e250f7dbdf8adb99e235da783d690f5819fdeb4cce39d9cfb0aca9f1" dependencies = [ "debugid", "memmap2", @@ -5331,9 +5339,9 @@ dependencies = [ [[package]] name = "symbolic-debuginfo" -version = "12.8.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb52777be67777947c5a159f1b6e8bfe4473d91fad7e5d4aff85ee4d3963cc04" +checksum = "abdc791ca87a69a5d09913d87f1e5ac95229be414ec0ff6c0fe2ddff6199f3b6" dependencies = [ "debugid", "dmsort", @@ -5341,7 +5349,7 @@ dependencies = [ "elsa", "fallible-iterator 0.3.0", "flate2", - "gimli 0.28.1", + "gimli 0.30.0", "goblin", "lazy_static", "nom", @@ -5350,7 +5358,7 @@ dependencies = [ "parking_lot 0.12.3", "pdb-addr2line", "regex", - "scroll", + "scroll 0.12.0", "serde", "serde_json", "smallvec", @@ -5358,14 +5366,15 @@ dependencies = [ "symbolic-ppdb", "thiserror", "wasmparser", - "zip 0.6.6", + "zip 2.1.1", + "zstd", ] [[package]] name = "symbolic-demangle" -version = "12.8.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a99812da4020a67e76c4eb41f08c87364c14170495ff780f30dd519c221a68" +checksum = "424fa2c9bf2c862891b9cfd354a752751a6730fd838a4691e7f6c2c7957b9daf" dependencies = [ "cc", "cpp_demangle", @@ -5376,9 +5385,9 @@ dependencies = [ [[package]] name = "symbolic-ppdb" -version = "12.8.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dace84623ccc926886fc880c36e2a81af4b17f8276abc4d77dc947ca3c6c8f8c" +checksum = "92ccffa1e6b313c007dddcc3a91166a64055a0a956e1429ee179a808fa3b2c62" dependencies = [ "flate2", "indexmap 2.2.6", @@ -5426,9 +5435,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "tar" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" dependencies = [ "filetime", "libc", @@ -5642,14 +5651,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -5676,15 +5685,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -5909,9 +5918,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -5963,9 +5972,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -6096,12 +6105,16 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasmparser" -version = "0.118.2" +version = "0.209.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f1154f1ab868e2a01d9834a805faca7bf8b50d041b4ca714d005d0dab1c50c" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" dependencies = [ + "ahash", + "bitflags 2.5.0", + "hashbrown 0.14.5", "indexmap 2.2.6", "semver", + "serde", ] [[package]] @@ -6253,9 +6266,9 @@ dependencies = [ [[package]] name = "windows-registry" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f721bc2e55efb506a1a395a545cb76c2481fb023d33b51f0050e7888716281cf" +checksum = "acc134c90a0318d873ec962b13149e9c862ff0d2669082a709a4810167a3c6ee" dependencies = [ "windows-result", "windows-targets 0.52.5", @@ -6263,9 +6276,9 @@ dependencies = [ [[package]] name = "windows-result" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ "windows-targets 0.52.5", ] @@ -6450,9 +6463,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -6500,18 +6513,6 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", -] - [[package]] name = "zip" version = "1.1.4" @@ -6539,6 +6540,23 @@ dependencies = [ "zstd", ] +[[package]] +name = "zip" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd56a4d5921bc2f99947ac5b3abe5f510b1be7376fdc5e9fce4a23c6a93e87c" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "displaydoc", + "flate2", + "indexmap 2.2.6", + "memchr", + "thiserror", + "zopfli", +] + [[package]] name = "zopfli" version = "0.8.1" diff --git a/Cargo.toml b/Cargo.toml index c0217061..a0eae196 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,4 +55,4 @@ async-std = { version = "1.12", default-features = false } [workspace.metadata.playdate.options.assets] dependencies = true -overwrite = true +overwrite = false diff --git a/cargo/src/package/mod.rs b/cargo/src/package/mod.rs index 43da04ec..608cc122 100644 --- a/cargo/src/package/mod.rs +++ b/cargo/src/package/mod.rs @@ -359,13 +359,13 @@ fn build_manifest(config: &Config, let source = ManifestSource::new(package, metadata.into()); // This validation not needed at this step. May be earlier: validate(&source); - source.manifest_for_opt(cargo_target.as_deref(), dev) + source.manifest_override_or_crate(cargo_target.as_deref(), dev) } else { let metadata = playdate_metadata(package); let source = ManifestSource::new(package, metadata.as_ref()); // This validation not needed at this step. May be earlier: validate(&source); - source.manifest_for_opt(cargo_target.as_deref(), dev) + source.manifest_override_or_crate(cargo_target.as_deref(), dev) }; // validation, lints diff --git a/support/build/src/metadata/source.rs b/support/build/src/metadata/source.rs index eba54572..4aa82e3e 100644 --- a/support/build/src/metadata/source.rs +++ b/support/build/src/metadata/source.rs @@ -104,7 +104,7 @@ pub trait PackageSource { /// Returns `None` if manifest for `target` not found, no fallback. - fn manifest_for(&self, target: &str, dev: bool) -> Option>> { + fn manifest_override_for(&self, target: &str, dev: bool) -> Option>> { let base = self.manifest_for_crate(); if let Some(root) = self.metadata() { @@ -127,8 +127,8 @@ pub trait PackageSource { } /// Returns manifest for specified `target`. If not found, returns manifest for crate. - fn manifest_for_opt(&self, target: Option<&str>, dev: bool) -> Ext> { - target.and_then(|target| self.manifest_for(target, dev)) + fn manifest_override_or_crate(&self, target: Option<&str>, dev: bool) -> Ext> { + target.and_then(|target| self.manifest_override_for(target, dev)) .unwrap_or_else(|| self.manifest_for_crate().into_owned()) } } @@ -544,8 +544,8 @@ mod tests { #[test] fn manifest_for_base() { let base = CrateInfoNoMeta.manifest_for_crate(); - let spec = CrateInfoNoMeta.manifest_for_opt("target".into(), false); - let opt = CrateInfoNoMeta.manifest_for("target", false); + let spec = CrateInfoNoMeta.manifest_override_or_crate("target".into(), false); + let opt = CrateInfoNoMeta.manifest_override_for("target", false); assert_eq!(opt, Some(spec.to_owned())); assert_eq!(spec, base.into_owned()); } @@ -633,7 +633,7 @@ mod tests { #[test] fn manifest_for_target_wrong_no_meta() { - let spec = CrateInfoNoMeta.manifest_for_opt(Some("WRONG"), false); + let spec = CrateInfoNoMeta.manifest_override_or_crate(Some("WRONG"), false); assert_eq!(Some("Name"), spec.name()); assert_eq!(Some("John"), spec.author()); @@ -645,7 +645,7 @@ mod tests { fn manifest_for_target_wrong() { let base_src = CrateInfo::new(); let base = base_src.manifest_for_crate(); - let spec = base_src.manifest_for_opt(Some("WRONG"), false); + let spec = base_src.manifest_override_or_crate(Some("WRONG"), false); assert_eq!(Some("Meta Name"), spec.name()); assert_eq!(Some("John"), spec.author()); assert_eq!(Some("0.0.0"), spec.version()); @@ -656,7 +656,7 @@ mod tests { #[test] fn manifest_for_target_bin() { let base_src = CrateInfo::new(); - let spec = base_src.manifest_for_opt(SOME_TARGET.into(), false); + let spec = base_src.manifest_override_or_crate(SOME_TARGET.into(), false); assert_eq!(Some("Bin Name"), spec.name()); assert_eq!(Some("Alex"), spec.author()); assert_eq!(Some("0.0.0"), spec.version()); diff --git a/support/build/src/metadata/validation.rs b/support/build/src/metadata/validation.rs index ad5d796b..446956a8 100644 --- a/support/build/src/metadata/validation.rs +++ b/support/build/src/metadata/validation.rs @@ -209,8 +209,21 @@ pub trait ValidateCrate: PackageSource { fn validate_for(&self, target: &str) -> impl IntoIterator { - println!("TODO: validate_for(target={target:?}) not implemented yet!"); - [] + let no_meta = self.metadata() + .is_none() + .then(|| Problem::Warning(Warning::MissingMetadata)); + + let man = self.bins() + .contains(&target) + .then_some(false) + .or_else(|| self.examples().contains(&target).then_some(true)) + .map(|dev| self.manifest_override_or_crate(target.into(), dev)) + .map_or_else( + || vec![Problem::UnknownTarget { name: target.to_owned(), }], + |m| m.validate().into_iter().collect::>(), + ); + + no_meta.into_iter().chain(man) } }