diff --git a/Cargo.lock b/Cargo.lock index 3ec5328..3493827 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,6 +527,15 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.4" @@ -615,6 +624,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -654,6 +669,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num_cpus" version = "1.13.1" @@ -1391,6 +1416,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "versions" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee97e1d97bd593fb513912a07691b742361b3dd64ad56f2c694ea2dbfe0665d3" +dependencies = [ + "itertools", + "nom", +] + [[package]] name = "walkdir" version = "2.3.2" @@ -1592,6 +1627,7 @@ dependencies = [ "tracing-subscriber", "twox-hash", "ureq", + "versions", "walkdir", "zip", ] diff --git a/Cargo.toml b/Cargo.toml index 3785e09..3e4dfde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,8 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [ ] } # Hashing twox-hash = "1.6" +# Determine the latest CRT and SDK versions +versions = "4.1.0" # Unpacking of VSIX "packages" zip = { version = "0.6", default-features = false, features = ["deflate"] } diff --git a/src/lib.rs b/src/lib.rs index e9eef32..98069fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -339,15 +339,17 @@ fn get_crt( .get("Microsoft.VisualStudio.Product.BuildTools") .context("unable to find root BuildTools item")?; - let crt_version = build_tools + let crt_version_rs_versions = build_tools .dependencies .keys() .filter_map(|key| { key.strip_prefix("Microsoft.VisualStudio.Component.VC.") .and_then(|s| s.strip_suffix(".x86.x64")) + .and_then(versions::Version::new) }) - .last() + .max() .context("unable to find latest CRT version")?; + let crt_version = &crt_version_rs_versions.to_string(); // The CRT headers are in the "base" package // `Microsoft.VC..CRT.Headers.base` @@ -519,11 +521,17 @@ fn get_sdk( arches: u32, pruned: &mut Vec, ) -> Result<(), Error> { - let sdk = pkgs - .values() - .filter(|mi| mi.id.starts_with("Win10SDK_10.")) + let sdk_version_rs_versions = pkgs + .keys() + .filter_map(|key| { + key.strip_prefix("Win10SDK_") + .and_then(versions::Version::new) + }) .max() .context("unable to find latest Win10SDK version")?; + let sdk = pkgs + .get(&format!("Win10SDK_{sdk_version_rs_versions}")) + .unwrap(); // So. There are multiple SDK Desktop Headers, one per architecture. However, // all of the non-x86 ones include either 0 or few files, with x86 containing