From a45369329bc9a159ac99d74eff79970689691bdb Mon Sep 17 00:00:00 2001 From: Scott driggers Date: Thu, 5 Oct 2023 00:15:08 -0400 Subject: [PATCH 1/2] Adding option to include debug libs - Adding env and cli flag to control including debug libs (defaulting to false) - Updating readme to document the change --- README.md | 13 +++++++------ src/common.rs | 11 ++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5406006..894f675 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,13 @@ for example, `cargo xwin test --target x86_64-pc-windows-msvc` The Microsoft CRT and Windows SDK can be customized using the following environment variables or CLI options. -| Environment Variable | CLI option | Description | -|----------------------|--------------------|--------------------------------------------------------------------------------------------------------------------| -| `XWIN_ARCH` | `--xwin-arch` | The architectures to include, defaults to `x86_64,aarch64`, possible values: x86, x86_64, aarch, aarch64 | -| `XWIN_VARIANT` | `--xwin-variant` | The variants to include, defaults to `desktop`, possible values: desktop, onecore, spectre | -| `XWIN_VERSION` | `--xwin-version` | The version to retrieve, defaults to 16, can either be a major version of 15 or 16, or a `.` version | -| `XWIN_CACHE_DIR` | `--xwin-cache-dir` | xwin cache directory to put CRT and SDK files | +| Environment Variable | CLI option | Description | +| ------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| `XWIN_ARCH` | `--xwin-arch` | The architectures to include, defaults to `x86_64,aarch64`, possible values: x86, x86_64, aarch, aarch64 | +| `XWIN_VARIANT` | `--xwin-variant` | The variants to include, defaults to `desktop`, possible values: desktop, onecore, spectre | +| `XWIN_VERSION` | `--xwin-version` | The version to retrieve, defaults to 16, can either be a major version of 15 or 16, or a `.` version | +| `XWIN_CACHE_DIR` | `--xwin-cache-dir` | xwin cache directory to put CRT and SDK files | +| `XWIN_INCLUDE_DEBUG_LIBS` | `--xwin-include-debug-libs` | Whether or not to include debug libs in installation (default false). | ### CMake Support diff --git a/src/common.rs b/src/common.rs index ada696e..23cc171 100644 --- a/src/common.rs +++ b/src/common.rs @@ -50,6 +50,10 @@ pub struct XWinOptions { /// a "." version. #[arg(long, env = "XWIN_VERSION", default_value = "16", hide = true)] pub xwin_version: String, + + /// Whether or not to include debug libs + #[arg(long, env = "XWIN_INCLUDE_DEBUG_LIBS", hide = true)] + pub xwin_include_debug_libs: bool, } impl Default for XWinOptions { @@ -59,6 +63,7 @@ impl Default for XWinOptions { xwin_arch: vec![xwin::Arch::X86_64, xwin::Arch::Aarch64], xwin_variant: vec![xwin::Variant::Desktop], xwin_version: "16".to_string(), + xwin_include_debug_libs: false, } } } @@ -110,7 +115,7 @@ impl XWinOptions { for target in &targets { if target.contains("msvc") { - self.setup_msvc_crt(xwin_cache_dir.clone())?; + self.setup_msvc_crt(xwin_cache_dir.clone(), self.xwin_include_debug_libs)?; let env_target = target.to_lowercase().replace('-', "_"); if which_in("clang-cl", Some(env_path.clone()), env::current_dir()?).is_err() { @@ -250,7 +255,7 @@ impl XWinOptions { Ok(()) } - fn setup_msvc_crt(&self, cache_dir: PathBuf) -> Result<()> { + fn setup_msvc_crt(&self, cache_dir: PathBuf, include_debug_libs: bool) -> Result<()> { let done_mark_file = cache_dir.join("DONE"); let xwin_arches: HashSet<_> = self .xwin_arch @@ -285,7 +290,7 @@ impl XWinOptions { .fold(0, |acc, var| acc | *var as u32); let pruned = xwin::prune_pkg_list(&pkg_manifest, arches, variants, false)?; let op = xwin::Ops::Splat(xwin::SplatConfig { - include_debug_libs: false, + include_debug_libs, include_debug_symbols: false, enable_symlinks: !cfg!(target_os = "macos"), preserve_ms_arch_notation: false, From c1decae260b37537719f06ca02e8196ef5d51dc3 Mon Sep 17 00:00:00 2001 From: Scott driggers Date: Thu, 5 Oct 2023 00:38:20 -0400 Subject: [PATCH 2/2] Addressing feedback --- src/common.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.rs b/src/common.rs index 23cc171..459bf44 100644 --- a/src/common.rs +++ b/src/common.rs @@ -115,7 +115,7 @@ impl XWinOptions { for target in &targets { if target.contains("msvc") { - self.setup_msvc_crt(xwin_cache_dir.clone(), self.xwin_include_debug_libs)?; + self.setup_msvc_crt(xwin_cache_dir.clone())?; let env_target = target.to_lowercase().replace('-', "_"); if which_in("clang-cl", Some(env_path.clone()), env::current_dir()?).is_err() { @@ -255,7 +255,7 @@ impl XWinOptions { Ok(()) } - fn setup_msvc_crt(&self, cache_dir: PathBuf, include_debug_libs: bool) -> Result<()> { + fn setup_msvc_crt(&self, cache_dir: PathBuf) -> Result<()> { let done_mark_file = cache_dir.join("DONE"); let xwin_arches: HashSet<_> = self .xwin_arch @@ -290,7 +290,7 @@ impl XWinOptions { .fold(0, |acc, var| acc | *var as u32); let pruned = xwin::prune_pkg_list(&pkg_manifest, arches, variants, false)?; let op = xwin::Ops::Splat(xwin::SplatConfig { - include_debug_libs, + include_debug_libs: self.xwin_include_debug_libs, include_debug_symbols: false, enable_symlinks: !cfg!(target_os = "macos"), preserve_ms_arch_notation: false,