mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Use Windows ARM64 cargo/node binaries during build
We can't provide ARM64 wheels to users yet due to #4079, but we can at least speed up the build. The rustls -> native-tls change on Windows is because ring requires clang to compile for ARM64, and I figured it's best to keep our Windows deps consistent. We already built the wheels with native-tls.
This commit is contained in:
parent
9fd23f79ed
commit
c7e9cb2d88
11 changed files with 53 additions and 24 deletions
|
@ -5,16 +5,18 @@ use std::env;
|
|||
|
||||
use ninja_gen::archives::Platform;
|
||||
|
||||
/// Usually None to use the host architecture; can be overriden by setting
|
||||
/// MAC_X86 to build for x86_64 on Apple Silicon
|
||||
/// Please see [`overriden_python_target_platform()`] for details.
|
||||
pub fn overriden_rust_target_triple() -> Option<&'static str> {
|
||||
overriden_python_target_platform().map(|p| p.as_rust_triple())
|
||||
}
|
||||
|
||||
/// Usually None to use the host architecture; can be overriden by setting
|
||||
/// MAC_X86 to build for x86_64 on Apple Silicon
|
||||
/// Usually None to use the host architecture, except on Windows which
|
||||
/// always uses x86_64.
|
||||
/// On a Mac, set MAC_X86 to build for x86_64 on Apple Silicon.
|
||||
pub fn overriden_python_target_platform() -> Option<Platform> {
|
||||
if env::var("MAC_X86").is_ok() {
|
||||
if cfg!(target_os = "windows") {
|
||||
Some(Platform::WindowsX64)
|
||||
} else if env::var("MAC_X86").is_ok() {
|
||||
Some(Platform::MacX64)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -50,7 +50,7 @@ pub fn build_pylib(build: &mut Build) -> Result<()> {
|
|||
output: &format!(
|
||||
"pylib/anki/_rsbridge.{}",
|
||||
match build.host_platform {
|
||||
Platform::WindowsX64 => "pyd",
|
||||
Platform::WindowsX64 | Platform::WindowsArm => "pyd",
|
||||
_ => "so",
|
||||
}
|
||||
),
|
||||
|
|
|
@ -118,6 +118,7 @@ impl BuildAction for BuildWheel {
|
|||
Platform::MacX64 => "macosx_12_0_x86_64",
|
||||
Platform::MacArm => "macosx_12_0_arm64",
|
||||
Platform::WindowsX64 => "win_amd64",
|
||||
Platform::WindowsArm => "win_arm64",
|
||||
};
|
||||
format!("cp39-abi3-{platform_tag}")
|
||||
} else {
|
||||
|
|
|
@ -17,11 +17,16 @@ itertools.workspace = true
|
|||
maplit.workspace = true
|
||||
num_cpus.workspace = true
|
||||
regex.workspace = true
|
||||
reqwest = { workspace = true, features = ["blocking", "json", "rustls-tls"] }
|
||||
serde_json.workspace = true
|
||||
walkdir.workspace = true
|
||||
which.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
reqwest = { workspace = true, features = ["blocking", "json", "native-tls"] }
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
reqwest = { workspace = true, features = ["blocking", "json", "rustls-tls"] }
|
||||
|
||||
[[bin]]
|
||||
name = "update_uv"
|
||||
path = "src/bin/update_uv.rs"
|
||||
|
|
|
@ -26,22 +26,21 @@ pub enum Platform {
|
|||
MacX64,
|
||||
MacArm,
|
||||
WindowsX64,
|
||||
WindowsArm,
|
||||
}
|
||||
|
||||
impl Platform {
|
||||
pub fn current() -> Self {
|
||||
if cfg!(windows) {
|
||||
Self::WindowsX64
|
||||
} else {
|
||||
let os = std::env::consts::OS;
|
||||
let arch = std::env::consts::ARCH;
|
||||
match (os, arch) {
|
||||
("linux", "x86_64") => Self::LinuxX64,
|
||||
("linux", "aarch64") => Self::LinuxArm,
|
||||
("macos", "x86_64") => Self::MacX64,
|
||||
("macos", "aarch64") => Self::MacArm,
|
||||
_ => panic!("unsupported os/arch {os} {arch} - PR welcome!"),
|
||||
}
|
||||
let os = std::env::consts::OS;
|
||||
let arch = std::env::consts::ARCH;
|
||||
match (os, arch) {
|
||||
("linux", "x86_64") => Self::LinuxX64,
|
||||
("linux", "aarch64") => Self::LinuxArm,
|
||||
("macos", "x86_64") => Self::MacX64,
|
||||
("macos", "aarch64") => Self::MacArm,
|
||||
("windows", "x86_64") => Self::WindowsX64,
|
||||
("windows", "aarch64") => Self::WindowsArm,
|
||||
_ => panic!("unsupported os/arch {os} {arch} - PR welcome!"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +61,7 @@ impl Platform {
|
|||
Platform::MacX64 => "x86_64-apple-darwin",
|
||||
Platform::MacArm => "aarch64-apple-darwin",
|
||||
Platform::WindowsX64 => "x86_64-pc-windows-msvc",
|
||||
Platform::WindowsArm => "aarch64-pc-windows-msvc",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ fn fetch_uv_release_info() -> Result<String, Box<dyn Error>> {
|
|||
("MacX64", "x86_64-apple-darwin"),
|
||||
("MacArm", "aarch64-apple-darwin"),
|
||||
("WindowsX64", "x86_64-pc-windows-msvc"),
|
||||
("WindowsArm", "aarch64-pc-windows-msvc"),
|
||||
];
|
||||
|
||||
let mut match_blocks = Vec::new();
|
||||
|
@ -126,7 +127,7 @@ mod tests {
|
|||
let content = fs::read_to_string("src/python.rs").unwrap();
|
||||
let original_lines = content.lines().count();
|
||||
|
||||
const EXPECTED_LINES_REMOVED: usize = 32;
|
||||
const EXPECTED_LINES_REMOVED: usize = 38;
|
||||
|
||||
let updated = update_uv_text(&content, "").unwrap();
|
||||
let updated_lines = updated.lines().count();
|
||||
|
|
|
@ -38,6 +38,10 @@ pub fn node_archive(platform: Platform) -> OnlineArchive {
|
|||
url: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-win-x64.zip",
|
||||
sha256: "893115cd92ad27bf178802f15247115e93c0ef0c753b93dca96439240d64feb5",
|
||||
},
|
||||
Platform::WindowsArm => OnlineArchive {
|
||||
url: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-win-arm64.zip",
|
||||
sha256: "89c1f7034dcd6ff5c17f2af61232a96162a1902f862078347dcf274a938b6142",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub fn protoc_archive(platform: Platform) -> OnlineArchive {
|
|||
sha256: "e3324d3bc2e9bc967a0bec2472e0ec73b26f952c7c87f2403197414f780c3c6c",
|
||||
}
|
||||
}
|
||||
Platform::WindowsX64 => {
|
||||
Platform::WindowsX64 | Platform::WindowsArm => {
|
||||
OnlineArchive {
|
||||
url: "https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-win64.zip",
|
||||
sha256: "3657053024faa439ff5f8c1dd2ee06bac0f9b9a3d660e99944f015a7451e87ec",
|
||||
|
@ -67,7 +67,7 @@ fn clang_format_archive(platform: Platform) -> OnlineArchive {
|
|||
sha256: "238be68d9478163a945754f06a213483473044f5a004c4125d3d9d8d3556466e",
|
||||
}
|
||||
}
|
||||
Platform::WindowsX64 => {
|
||||
Platform::WindowsX64 | Platform::WindowsArm=> {
|
||||
OnlineArchive {
|
||||
url: "https://github.com/ankitects/clang-format-binaries/releases/download/anki-2021-01-09/clang-format_windows_x86_64.zip",
|
||||
sha256: "7d9f6915e3f0fb72407830f0fc37141308d2e6915daba72987a52f309fbeaccc",
|
||||
|
|
|
@ -54,6 +54,12 @@ pub fn uv_archive(platform: Platform) -> OnlineArchive {
|
|||
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-x86_64-pc-windows-msvc.zip",
|
||||
sha256: "e199b10bef1a7cc540014483e7f60f825a174988f41020e9d2a6b01bd60f0669",
|
||||
}
|
||||
},
|
||||
Platform::WindowsArm => {
|
||||
OnlineArchive {
|
||||
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-aarch64-pc-windows-msvc.zip",
|
||||
sha256: "bb40708ad549ad6a12209cb139dd751bf0ede41deb679ce7513ce197bd9ef234",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ camino.workspace = true
|
|||
clap.workspace = true
|
||||
flate2.workspace = true
|
||||
junction.workspace = true
|
||||
reqwest = { workspace = true, features = ["rustls-tls", "rustls-tls-native-roots"] }
|
||||
sha2.workspace = true
|
||||
tar.workspace = true
|
||||
termcolor.workspace = true
|
||||
|
@ -24,3 +23,9 @@ which.workspace = true
|
|||
xz2.workspace = true
|
||||
zip.workspace = true
|
||||
zstd.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
reqwest = { workspace = true, features = ["native-tls"] }
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
reqwest = { workspace = true, features = ["rustls-tls", "rustls-tls-native-roots"] }
|
||||
|
|
|
@ -9,7 +9,12 @@ You must be running 64 bit Windows 10, version 1703 or newer.
|
|||
**Rustup**:
|
||||
|
||||
As mentioned in development.md, rustup must be installed. If you're on
|
||||
ARM Windows, you must set the default target to x86_64-pc-windows-msvc.
|
||||
ARM Windows and install the ARM64 version of rust-up, from this project folder,
|
||||
run
|
||||
|
||||
```
|
||||
rustup target add x86_64-pc-windows-msvc
|
||||
```
|
||||
|
||||
**Visual Studio**:
|
||||
|
||||
|
|
Loading…
Reference in a new issue