From 1e0c16673c9960bd6b418eab4c116f1f8a149a17 Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Sun, 1 Feb 2026 20:45:08 -0600 Subject: [PATCH] Heck yeah, got Android building the project --- src/commands/upgrade.rs | 6 ++ src/project/mod.rs | 150 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 2 deletions(-) diff --git a/src/commands/upgrade.rs b/src/commands/upgrade.rs index 8342652..c4bea1d 100644 --- a/src/commands/upgrade.rs +++ b/src/commands/upgrade.rs @@ -55,10 +55,16 @@ pub fn upgrade_project(path: &str) -> Result<()> { // Android Studio integration — regenerated so run configs stay in // sync if deploy.sh flags or script names ever change. ".idea/workspace.xml", + ".idea/runConfigurations/Build.xml", + ".idea/runConfigurations/Build (Windows).xml", ".idea/runConfigurations/Deploy (auto).xml", + ".idea/runConfigurations/Deploy (auto) (Windows).xml", ".idea/runConfigurations/Deploy (USB).xml", + ".idea/runConfigurations/Deploy (USB) (Windows).xml", ".idea/runConfigurations/Deploy (WiFi).xml", + ".idea/runConfigurations/Deploy (WiFi) (Windows).xml", ".idea/runConfigurations/Test.xml", + ".idea/runConfigurations/Test (Windows).xml", ]; println!("{}", "Updating infrastructure files...".bright_yellow()); diff --git a/src/project/mod.rs b/src/project/mod.rs index d267042..692d83d 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -470,8 +470,57 @@ class BasicTest { // Weevil's scripts. Android Studio shows these in the Run dropdown // at the top of the IDE — no configuration needed by the student. // - // We generate platform-specific configs: .sh on Unix, .bat on Windows. - // The SCRIPT element uses $PROJECT_DIR$ so it's location-independent. + // We generate both Unix (.sh, ./gradlew) and Windows (.bat, gradlew.bat) + // variants. Android Studio automatically hides configs whose script files + // don't exist, so only the platform-appropriate ones appear in the dropdown. + + // Build (Unix) — just builds the APK without deploying + let build_unix_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Build.xml"), + build_unix_xml, + )?; + + // Build (Windows) — same, but calls build.bat + let build_windows_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Build (Windows).xml"), + build_windows_xml, + )?; // Deploy (auto) — no flags, deploy.sh auto-detects USB vs WiFi let deploy_auto_xml = r#" @@ -497,6 +546,30 @@ class BasicTest { deploy_auto_xml, )?; + // Deploy (auto) (Windows) + let deploy_auto_windows_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Deploy (auto) (Windows).xml"), + deploy_auto_windows_xml, + )?; + // Deploy (USB) — forces USB connection let deploy_usb_xml = r#" @@ -521,6 +594,30 @@ class BasicTest { deploy_usb_xml, )?; + // Deploy (USB) (Windows) + let deploy_usb_windows_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Deploy (USB) (Windows).xml"), + deploy_usb_windows_xml, + )?; + // Deploy (WiFi) — forces WiFi connection to default 192.168.43.1 let deploy_wifi_xml = r#" @@ -545,6 +642,30 @@ class BasicTest { deploy_wifi_xml, )?; + // Deploy (WiFi) (Windows) + let deploy_wifi_windows_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Deploy (WiFi) (Windows).xml"), + deploy_wifi_windows_xml, + )?; + // Test — runs the unit test suite via Gradle let test_xml = r#" @@ -569,6 +690,31 @@ class BasicTest { test_xml, )?; + // Test (Windows) + let test_windows_xml = r#" + + + +"#; + fs::write( + project_path.join(".idea/runConfigurations/Test (Windows).xml"), + test_windows_xml, + )?; + + Ok(()) }