Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ dotenvy = { version = "0.15.7" }
dunce = { version = "1.0.5" }
either = { version = "1.13.0" }
encoding_rs_io = { version = "0.1.7" }
embed-manifest = { version = "1.5.0" }
etcetera = { version = "0.11.0" }
fastrand = { version = "2.3.0" }
flate2 = { version = "1.0.33", default-features = false, features = ["zlib-rs"] }
Expand Down
5 changes: 5 additions & 0 deletions crates/uv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ arrayvec = { workspace = true }
self-replace = { workspace = true }
windows = { workspace = true }

[build-dependencies]
uv-version = { workspace = true }

embed-manifest = { workspace = true }

[dev-dependencies]
uv-publish = { workspace = true, features = ["test"] }

Expand Down
39 changes: 39 additions & 0 deletions crates/uv/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! This embeds a "manifest" - a special XML document - into the uv binary on Windows builds.
//!
//! It includes reasonable defaults for Windows binaries:
//! - `System` codepage to retain backwards compatibility with previous uv releases.
//! We can set to the utf-8 codepage in a future breaking release which lets us use the
//! *A versions of Windows API functions without utf-16 conversion.
//! - Long path awareness allows paths longer than 260 characters in Windows operations.
//! This still requires `LongPathsEnabled` to be set in the Windows registry.
//! - Declared Windows 7-10+ compatibility to avoid legacy compat layers from being potentially
//! applied by not specifying any. This does not imply actual Windows 7, 8.0, 8.1 support. In
//! cases where the application is run on Windows 7, the app is treated as Windows 7 aware
//! rather than an unspecified legacy application (e.g. Windows XP).
//! - Standard invoker execution levels for CLI applications to disable UAC virtualization.
//!
//! See <https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests>
use embed_manifest::manifest::{ActiveCodePage, ExecutionLevel, Setting, SupportedOS};
use embed_manifest::{embed_manifest, empty_manifest};

fn main() {
if std::env::var_os("CARGO_CFG_WINDOWS").is_some() {
let [major, minor, patch] = uv_version::version()
.splitn(3, '.')
.map(str::parse)
.collect::<Result<Vec<u16>, _>>()
.ok()
.and_then(|v| v.try_into().ok())
.expect("uv version must be in x.y.z format");
let manifest = empty_manifest()
.name("uv")
.version(major, minor, patch, 0)
.active_code_page(ActiveCodePage::System)
// "Windows10" includes Windows 10 and 11, and Windows Server 2016, 2019 and 2022
.supported_os(SupportedOS::Windows7..=SupportedOS::Windows10)
.requested_execution_level(ExecutionLevel::AsInvoker)
.long_path_aware(Setting::Enabled);
embed_manifest(manifest).expect("unable to embed manifest");
}
println!("cargo:rerun-if-changed=build.rs");
}
Loading