feat: Add Windows support and stabilize SDK installation (v1.0.0-rc1)
Complete Windows compatibility overhaul with robust cross-platform SDK management. This release candidate establishes feature freeze for the 1.0.0 release. Key improvements: - Fixed Android SDK installation on Windows * Use cmd.exe wrapper for sdkmanager.bat with piped stdin * Properly reorganize cmdline-tools directory structure * Write license acceptances synchronously to avoid hangs - Fixed FTC SDK configuration * Auto-generate local.properties with Android SDK path * Escape backslashes in Kotlin build.gradle.kts strings * Support both new installs and upgrades via ensure_local_properties() - Enhanced Windows console output * Enable ANSI color support via enable_ansi_support crate * Maintain color compatibility across Windows versions - Improved error handling and debugging * Added comprehensive logging throughout SDK installation * Better context messages for troubleshooting failures Cross-platform testing verified on: - Windows 11 with Eclipse Adoptium JDK 21 - Linux (existing support maintained) Breaking changes: None This RC introduces feature freeze - subsequent 1.0.x releases will be bug fixes only. New features deferred to 1.1.0. Closes Windows compatibility milestone.
This commit is contained in:
@@ -2,16 +2,19 @@ use std::path::Path;
|
||||
use anyhow::{Result, Context};
|
||||
use git2::Repository;
|
||||
use colored::*;
|
||||
use std::fs;
|
||||
|
||||
const FTC_SDK_URL: &str = "https://github.com/FIRST-Tech-Challenge/FtcRobotController.git";
|
||||
const FTC_SDK_VERSION: &str = "v10.1.1";
|
||||
|
||||
pub fn install(sdk_path: &Path) -> Result<()> {
|
||||
pub fn install(sdk_path: &Path, android_sdk_path: &Path) -> Result<()> {
|
||||
if sdk_path.exists() {
|
||||
println!("{} FTC SDK already installed at: {}",
|
||||
"✓".green(),
|
||||
sdk_path.display()
|
||||
);
|
||||
// Make sure local.properties exists even if SDK was already installed
|
||||
create_local_properties(sdk_path, android_sdk_path)?;
|
||||
return check_version(sdk_path);
|
||||
}
|
||||
|
||||
@@ -28,11 +31,32 @@ pub fn install(sdk_path: &Path) -> Result<()> {
|
||||
repo.checkout_tree(&obj, None)?;
|
||||
repo.set_head_detached(obj.id())?;
|
||||
|
||||
// Create local.properties with Android SDK path
|
||||
create_local_properties(sdk_path, android_sdk_path)?;
|
||||
|
||||
println!("{} FTC SDK installed successfully", "✓".green());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_local_properties(sdk_path: &Path, android_sdk_path: &Path) -> Result<()> {
|
||||
// Convert path to use forward slashes (works on both Windows and Unix)
|
||||
let android_sdk_str = android_sdk_path
|
||||
.display()
|
||||
.to_string()
|
||||
.replace("\\", "/");
|
||||
|
||||
let local_properties = format!("sdk.dir={}\n", android_sdk_str);
|
||||
|
||||
let properties_path = sdk_path.join("local.properties");
|
||||
fs::write(&properties_path, local_properties)
|
||||
.context("Failed to create local.properties")?;
|
||||
|
||||
println!("{} Created local.properties with Android SDK path", "✓".green());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_version(sdk_path: &Path) -> Result<()> {
|
||||
let repo = Repository::open(sdk_path)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user