@@ -53,22 +53,117 @@ fn main() {
println!("cargo:rustc-link-arg=/stack:{}", 8 * 1024 * 1024);
}
- if cfg!(target_arch = "x86_64") {
- println!("cargo::rerun-if-changed=resources\\windows\\bin\\x64\\conpty.dll");
- println!("cargo::rerun-if-changed=resources\\windows\\bin\\x64\\OpenConsole.exe");
- let conpty_target = std::env::var("OUT_DIR").unwrap() + "\\..\\..\\..\\conpty.dll";
- match std::fs::copy("resources/windows/bin/x64/conpty.dll", &conpty_target) {
- Ok(_) => println!("Copied conpty.dll to {conpty_target}"),
- Err(e) => println!("cargo::warning=Failed to copy conpty.dll: {}", e),
- }
- let open_console_target =
- std::env::var("OUT_DIR").unwrap() + "\\..\\..\\..\\OpenConsole.exe";
- match std::fs::copy(
- "resources/windows/bin/x64/OpenConsole.exe",
- &open_console_target,
- ) {
- Ok(_) => println!("Copied OpenConsole.exe to {open_console_target}"),
- Err(e) => println!("cargo::warning=Failed to copy OpenConsole.exe: {}", e),
+ if cfg!(target_arch = "x86_64") || cfg!(target_arch = "aarch64") {
+ let out_dir = std::env::var("OUT_DIR").unwrap();
+ let out_dir: &std::path::Path = out_dir.as_ref();
+ let target_dir = std::path::Path::new(&out_dir)
+ .parent()
+ .and_then(|p| p.parent())
+ .and_then(|p| p.parent())
+ .expect("Failed to find target directory");
+
+ let conpty_dll_target = target_dir.join("conpty.dll");
+ let open_console_target = target_dir.join("OpenConsole.exe");
+
+ let conpty_url = "https://github.com/microsoft/terminal/releases/download/v1.23.13503.0/Microsoft.Windows.Console.ConPTY.1.23.251216003.nupkg";
+ let nupkg_path = out_dir.join("conpty.nupkg");
+ let extract_dir = out_dir.join("conpty");
+
+ let download_script = format!(
+ "$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '{}' -OutFile '{}'",
+ conpty_url,
+ nupkg_path.display()
+ );
+
+ let download_result = Command::new("powershell")
+ .args([
+ "-NoProfile",
+ "-NonInteractive",
+ "-Command",
+ &download_script,
+ ])
+ .output();
+
+ match download_result {
+ Ok(output) if output.status.success() => {
+ println!("Downloaded conpty nupkg successfully");
+
+ let extract_script = format!(
+ "$ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path '{}' -DestinationPath '{}' -Force",
+ nupkg_path.display(),
+ extract_dir.display()
+ );
+
+ let extract_result = Command::new("powershell")
+ .args(["-NoProfile", "-NonInteractive", "-Command", &extract_script])
+ .output();
+
+ match extract_result {
+ Ok(output) if output.status.success() => {
+ let (conpty_dll_source, open_console_source) =
+ if cfg!(target_arch = "x86_64") {
+ (
+ extract_dir.join("runtimes/win-x64/native/conpty.dll"),
+ extract_dir
+ .join("build/native/runtimes/x64/OpenConsole.exe"),
+ )
+ } else {
+ (
+ extract_dir.join("runtimes/win-arm64/native/conpty.dll"),
+ extract_dir
+ .join("build/native/runtimes/arm64/OpenConsole.exe"),
+ )
+ };
+
+ match std::fs::copy(&conpty_dll_source, &conpty_dll_target) {
+ Ok(_) => {
+ println!("Copied conpty.dll to {}", conpty_dll_target.display())
+ }
+ Err(e) => println!(
+ "cargo::warning=Failed to copy conpty.dll from {}: {}",
+ conpty_dll_source.display(),
+ e
+ ),
+ }
+
+ match std::fs::copy(&open_console_source, &open_console_target) {
+ Ok(_) => println!(
+ "Copied OpenConsole.exe to {}",
+ open_console_target.display()
+ ),
+ Err(e) => println!(
+ "cargo::warning=Failed to copy OpenConsole.exe from {}: {}",
+ open_console_source.display(),
+ e
+ ),
+ }
+ }
+ Ok(output) => {
+ println!(
+ "cargo::warning=Failed to extract conpty nupkg: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ }
+ Err(e) => {
+ println!(
+ "cargo::warning=Failed to run PowerShell for extraction: {}",
+ e
+ );
+ }
+ }
+ }
+ Ok(output) => {
+ println!(
+ "cargo::warning=Failed to download conpty nupkg: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ }
+ Err(e) => {
+ println!(
+ "cargo::warning=Failed to run PowerShell for download: {}",
+ e
+ );
+ }
}
}
@@ -202,8 +202,8 @@ function DownloadAMDGpuServices {
}
function DownloadConpty {
- $url = "https://github.com/microsoft/terminal/releases/download/v1.23.12811.0/Microsoft.Windows.Console.ConPTY.1.23.251008001.nupkg"
- $zipPath = ".\Microsoft.Windows.Console.ConPTY.1.23.251008001.nupkg"
+ $url = "https://github.com/microsoft/terminal/releases/download/v1.23.13503.0/Microsoft.Windows.Console.ConPTY.1.23.251216003.nupkg"
+ $zipPath = ".\Microsoft.Windows.Console.ConPTY.1.23.251216003.nupkg"
Invoke-WebRequest -Uri $url -OutFile $zipPath
Expand-Archive -Path $zipPath -DestinationPath ".\conpty" -Force
}