Compare commits
5 Commits
v1.0.0-bet
...
b664565321
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b664565321 | ||
|
|
6b05a33daa | ||
|
|
9a41138d4c | ||
|
|
d92d49254b | ||
|
|
90ed42b3c5 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -22,6 +22,11 @@ Cargo.lock
|
|||||||
*.so
|
*.so
|
||||||
*.exe
|
*.exe
|
||||||
|
|
||||||
|
# Release packaging (uploaded to releases, not checked in)
|
||||||
|
/release-artifacts/
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -86,7 +86,7 @@ weevil sdk status
|
|||||||
### From Source
|
### From Source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/yourusername/weevil.git
|
git clone https://www.nxgit.dev/nexus-workshops/weevil.git
|
||||||
cd weevil
|
cd weevil
|
||||||
cargo build --release
|
cargo build --release
|
||||||
sudo cp target/release/weevil /usr/local/bin/
|
sudo cp target/release/weevil /usr/local/bin/
|
||||||
@@ -255,7 +255,7 @@ weevil new competition-bot
|
|||||||
cd competition-bot
|
cd competition-bot
|
||||||
|
|
||||||
# Project is already a git repo!
|
# Project is already a git repo!
|
||||||
git remote add origin https://github.com/team/robot.git
|
git remote add origin https://nxgit.dev/team/robot.git
|
||||||
git push -u origin main
|
git push -u origin main
|
||||||
|
|
||||||
# Make changes
|
# Make changes
|
||||||
@@ -287,7 +287,7 @@ git push
|
|||||||
**Project Structure is Portable:**
|
**Project Structure is Portable:**
|
||||||
```bash
|
```bash
|
||||||
# Team member clones repo
|
# Team member clones repo
|
||||||
git clone https://github.com/team/robot.git
|
git clone https://nxgit.dev/team/robot.git
|
||||||
cd robot
|
cd robot
|
||||||
|
|
||||||
# Check SDK location
|
# Check SDK location
|
||||||
@@ -466,7 +466,7 @@ Contributions welcome! Please:
|
|||||||
### Development Setup
|
### Development Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/yourusername/weevil.git
|
git clone https://www.nxgit.dev/nexus-workshops/weevil.git
|
||||||
cd weevil
|
cd weevil
|
||||||
cargo build
|
cargo build
|
||||||
cargo test
|
cargo test
|
||||||
@@ -511,7 +511,7 @@ Built with frustration at unnecessarily complex robotics frameworks, and hope th
|
|||||||
|
|
||||||
## Project Status
|
## Project Status
|
||||||
|
|
||||||
**Current Version:** 1.0.0-beta1
|
**Current Version:** 1.0.0-beta2
|
||||||
|
|
||||||
**What Works:**
|
**What Works:**
|
||||||
- ✅ Project generation
|
- ✅ Project generation
|
||||||
@@ -532,4 +532,4 @@ Built with frustration at unnecessarily complex robotics frameworks, and hope th
|
|||||||
|
|
||||||
**Questions? Issues? Suggestions?**
|
**Questions? Issues? Suggestions?**
|
||||||
|
|
||||||
Open an issue on GitHub or reach out to the FTC community. Let's make robot programming accessible for everyone! 🚀
|
Open an issue on NXGit or reach out to the FTC community. Let's make robot programming accessible for everyone! 🚀
|
||||||
80
build-release.sh
Executable file
80
build-release.sh
Executable file
@@ -0,0 +1,80 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Build release binaries for distribution
|
||||||
|
# This script builds both Linux and Windows binaries (cross-compile)
|
||||||
|
#
|
||||||
|
# For Windows-only builds, use build-release.ps1 on Windows
|
||||||
|
# For Linux-only builds, comment out the Windows section below
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
VERSION=${1:-$(git describe --tags --always)}
|
||||||
|
RELEASE_DIR="release-artifacts"
|
||||||
|
|
||||||
|
echo "Building Weevil $VERSION release binaries..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Clean previous artifacts
|
||||||
|
rm -rf "$RELEASE_DIR"
|
||||||
|
mkdir -p "$RELEASE_DIR"
|
||||||
|
|
||||||
|
# Build Linux binary (optimized)
|
||||||
|
echo "Building Linux x86_64 binary..."
|
||||||
|
cargo build --release
|
||||||
|
strip target/release/weevil
|
||||||
|
|
||||||
|
# Package Linux binary
|
||||||
|
echo "Packaging Linux binaries..."
|
||||||
|
cd target/release
|
||||||
|
tar -czf "../../$RELEASE_DIR/weevil-${VERSION}-linux-x86_64.tar.gz" weevil
|
||||||
|
zip -q "../../$RELEASE_DIR/weevil-${VERSION}-linux-x86_64.zip" weevil
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Build Windows binary (cross-compile)
|
||||||
|
echo ""
|
||||||
|
echo "Building Windows x86_64 binary..."
|
||||||
|
|
||||||
|
# Check if Windows target is installed
|
||||||
|
if ! rustup target list | grep -q "x86_64-pc-windows-gnu (installed)"; then
|
||||||
|
echo "Installing Windows target..."
|
||||||
|
rustup target add x86_64-pc-windows-gnu
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if MinGW is installed
|
||||||
|
if ! command -v x86_64-w64-mingw32-gcc &> /dev/null; then
|
||||||
|
echo "Warning: MinGW not found. Install with: sudo apt install mingw-w64"
|
||||||
|
echo "Skipping Windows build."
|
||||||
|
else
|
||||||
|
cargo build --release --target x86_64-pc-windows-gnu
|
||||||
|
x86_64-w64-mingw32-strip target/x86_64-pc-windows-gnu/release/weevil.exe
|
||||||
|
|
||||||
|
# Package Windows binary
|
||||||
|
echo "Packaging Windows binary..."
|
||||||
|
cd target/x86_64-pc-windows-gnu/release
|
||||||
|
zip -q "../../../$RELEASE_DIR/weevil-${VERSION}-windows-x86_64.zip" weevil.exe
|
||||||
|
cd ../../..
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate checksums
|
||||||
|
echo ""
|
||||||
|
echo "Generating checksums..."
|
||||||
|
cd "$RELEASE_DIR"
|
||||||
|
sha256sum * > SHA256SUMS
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Display results
|
||||||
|
echo ""
|
||||||
|
echo "═══════════════════════════════════════════════════════════"
|
||||||
|
echo " ✓ Release artifacts built successfully!"
|
||||||
|
echo "═══════════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo "Artifacts in $RELEASE_DIR/:"
|
||||||
|
ls -lh "$RELEASE_DIR"
|
||||||
|
echo ""
|
||||||
|
echo "Checksums:"
|
||||||
|
cat "$RELEASE_DIR/SHA256SUMS"
|
||||||
|
echo ""
|
||||||
|
echo "Upload these files to your Gitea release:"
|
||||||
|
echo " 1. Go to: Releases → $VERSION → Edit Release"
|
||||||
|
echo " 2. Drag and drop files from $RELEASE_DIR/"
|
||||||
|
echo " 3. Save"
|
||||||
|
echo ""
|
||||||
@@ -87,6 +87,10 @@ enum SdkCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
// Enable colors on Windows
|
||||||
|
#[cfg(windows)]
|
||||||
|
colored::control::set_virtual_terminal(true).ok();
|
||||||
|
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
|
||||||
print_banner();
|
print_banner();
|
||||||
|
|||||||
@@ -434,14 +434,14 @@ class BasicTest {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_executable(&self, project_path: &Path) -> Result<()> {
|
fn make_executable(&self, _project_path: &Path) -> Result<()> {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
let scripts = vec!["gradlew", "build.sh", "deploy.sh"];
|
let scripts = vec!["gradlew", "build.sh", "deploy.sh"];
|
||||||
for script in scripts {
|
for script in scripts {
|
||||||
let path = project_path.join(script);
|
let path = _project_path.join(script);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
let mut perms = fs::metadata(&path)?.permissions();
|
let mut perms = fs::metadata(&path)?.permissions();
|
||||||
perms.set_mode(0o755);
|
perms.set_mode(0o755);
|
||||||
|
|||||||
@@ -8,19 +8,33 @@ use colored::*;
|
|||||||
|
|
||||||
const ANDROID_SDK_URL_LINUX: &str = "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip";
|
const ANDROID_SDK_URL_LINUX: &str = "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip";
|
||||||
const ANDROID_SDK_URL_MAC: &str = "https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip";
|
const ANDROID_SDK_URL_MAC: &str = "https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip";
|
||||||
|
const ANDROID_SDK_URL_WINDOWS: &str = "https://dl.google.com/android/repository/commandlinetools-win-11076708_latest.zip";
|
||||||
|
|
||||||
pub fn install(sdk_path: &Path) -> Result<()> {
|
pub fn install(sdk_path: &Path) -> Result<()> {
|
||||||
|
// Check if SDK exists AND is complete
|
||||||
if sdk_path.exists() {
|
if sdk_path.exists() {
|
||||||
|
match verify(sdk_path) {
|
||||||
|
Ok(_) => {
|
||||||
println!("{} Android SDK already installed at: {}",
|
println!("{} Android SDK already installed at: {}",
|
||||||
"✓".green(),
|
"✓".green(),
|
||||||
sdk_path.display()
|
sdk_path.display()
|
||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
Err(_) => {
|
||||||
|
println!("{} Android SDK found but incomplete, reinstalling...",
|
||||||
|
"⚠".yellow()
|
||||||
|
);
|
||||||
|
// Continue with installation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println!("{}", "Installing Android SDK...".bright_yellow());
|
println!("{}", "Installing Android SDK...".bright_yellow());
|
||||||
|
|
||||||
let url = if cfg!(target_os = "macos") {
|
let url = if cfg!(target_os = "windows") {
|
||||||
|
ANDROID_SDK_URL_WINDOWS
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
ANDROID_SDK_URL_MAC
|
ANDROID_SDK_URL_MAC
|
||||||
} else {
|
} else {
|
||||||
ANDROID_SDK_URL_LINUX
|
ANDROID_SDK_URL_LINUX
|
||||||
@@ -58,11 +72,37 @@ pub fn install(sdk_path: &Path) -> Result<()> {
|
|||||||
let mut archive = zip::ZipArchive::new(file)?;
|
let mut archive = zip::ZipArchive::new(file)?;
|
||||||
|
|
||||||
std::fs::create_dir_all(sdk_path)?;
|
std::fs::create_dir_all(sdk_path)?;
|
||||||
archive.extract(sdk_path)?;
|
archive.extract(sdk_path)
|
||||||
|
.context("Failed to extract Android SDK")?;
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
std::fs::remove_file(&temp_zip)?;
|
std::fs::remove_file(&temp_zip)?;
|
||||||
|
|
||||||
|
// The zip extracts to cmdline-tools/ but we need it in cmdline-tools/latest/
|
||||||
|
let extracted_tools = sdk_path.join("cmdline-tools");
|
||||||
|
let target_location = sdk_path.join("cmdline-tools").join("latest");
|
||||||
|
|
||||||
|
if extracted_tools.exists() && !target_location.exists() {
|
||||||
|
println!("Reorganizing cmdline-tools directory structure...");
|
||||||
|
|
||||||
|
let temp_dir = sdk_path.join("cmdline-tools-temp");
|
||||||
|
std::fs::rename(&extracted_tools, &temp_dir)
|
||||||
|
.context("Failed to rename cmdline-tools to temp directory")?;
|
||||||
|
|
||||||
|
std::fs::create_dir_all(&target_location)
|
||||||
|
.context("Failed to create cmdline-tools/latest directory")?;
|
||||||
|
|
||||||
|
for entry in std::fs::read_dir(&temp_dir)? {
|
||||||
|
let entry = entry?;
|
||||||
|
let dest = target_location.join(entry.file_name());
|
||||||
|
std::fs::rename(entry.path(), dest)
|
||||||
|
.with_context(|| format!("Failed to move {} to latest/", entry.file_name().to_string_lossy()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fs::remove_dir_all(&temp_dir)
|
||||||
|
.context("Failed to remove temporary directory")?;
|
||||||
|
}
|
||||||
|
|
||||||
// Install required packages
|
// Install required packages
|
||||||
install_packages(sdk_path)?;
|
install_packages(sdk_path)?;
|
||||||
|
|
||||||
@@ -74,68 +114,120 @@ pub fn install(sdk_path: &Path) -> Result<()> {
|
|||||||
fn install_packages(sdk_path: &Path) -> Result<()> {
|
fn install_packages(sdk_path: &Path) -> Result<()> {
|
||||||
println!("Installing Android SDK packages...");
|
println!("Installing Android SDK packages...");
|
||||||
|
|
||||||
let sdkmanager = sdk_path
|
let sdkmanager_path = sdk_path.join("cmdline-tools").join("latest").join("bin");
|
||||||
.join("cmdline-tools/bin/sdkmanager");
|
|
||||||
|
let sdkmanager = if cfg!(target_os = "windows") {
|
||||||
|
sdkmanager_path.join("sdkmanager.bat")
|
||||||
|
} else {
|
||||||
|
sdkmanager_path.join("sdkmanager")
|
||||||
|
};
|
||||||
|
|
||||||
if !sdkmanager.exists() {
|
if !sdkmanager.exists() {
|
||||||
// Try alternate location
|
anyhow::bail!(
|
||||||
let alt = sdk_path.join("cmdline-tools/latest/bin/sdkmanager");
|
"sdkmanager not found at expected location: {}\n\
|
||||||
if alt.exists() {
|
Directory structure may be incorrect.",
|
||||||
return run_sdkmanager(&alt, sdk_path);
|
sdkmanager.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to move cmdline-tools to correct location
|
println!("Found sdkmanager at: {}", sdkmanager.display());
|
||||||
let from = sdk_path.join("cmdline-tools");
|
|
||||||
let to = sdk_path.join("cmdline-tools/latest");
|
|
||||||
if from.exists() {
|
|
||||||
std::fs::create_dir_all(sdk_path.join("cmdline-tools"))?;
|
|
||||||
std::fs::rename(&from, &to)?;
|
|
||||||
return run_sdkmanager(&to.join("bin/sdkmanager"), sdk_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run_sdkmanager(&sdkmanager, sdk_path)
|
run_sdkmanager(&sdkmanager, sdk_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_sdkmanager(sdkmanager: &Path, sdk_root: &Path) -> Result<()> {
|
fn run_sdkmanager(sdkmanager: &Path, sdk_root: &Path) -> Result<()> {
|
||||||
use std::process::Command;
|
use std::process::{Command, Stdio};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
// Accept licenses
|
println!("Accepting licenses...");
|
||||||
let mut yes_cmd = Command::new("yes");
|
|
||||||
let yes_output = yes_cmd.output()?;
|
|
||||||
|
|
||||||
let mut cmd = Command::new(sdkmanager);
|
// Build command based on OS
|
||||||
cmd.arg("--sdk_root")
|
let mut cmd = if cfg!(target_os = "windows") {
|
||||||
.arg(sdk_root)
|
let mut c = Command::new("cmd");
|
||||||
.arg("--licenses")
|
c.arg("/c");
|
||||||
.stdin(std::process::Stdio::piped())
|
c.arg(sdkmanager);
|
||||||
.spawn()?
|
c
|
||||||
.stdin
|
} else {
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.write_all(&yes_output.stdout)?;
|
|
||||||
|
|
||||||
// Install packages
|
|
||||||
Command::new(sdkmanager)
|
Command::new(sdkmanager)
|
||||||
.arg("--sdk_root")
|
};
|
||||||
.arg(sdk_root)
|
|
||||||
|
cmd.arg(format!("--sdk_root={}", sdk_root.display()))
|
||||||
|
.arg("--licenses")
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped());
|
||||||
|
|
||||||
|
let mut child = cmd.spawn()
|
||||||
|
.context("Failed to spawn sdkmanager for licenses")?;
|
||||||
|
|
||||||
|
// Write 'y' responses to accept all licenses
|
||||||
|
if let Some(mut stdin) = child.stdin.take() {
|
||||||
|
// Create a string with many 'y' responses
|
||||||
|
let responses = "y\n".repeat(20);
|
||||||
|
stdin.write_all(responses.as_bytes())
|
||||||
|
.context("Failed to write license responses")?;
|
||||||
|
// Explicitly drop stdin to close the pipe
|
||||||
|
drop(stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = child.wait_with_output()
|
||||||
|
.context("Failed to wait for license acceptance")?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
eprintln!("License stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
eprintln!("License stdout: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
println!("{} License acceptance may have failed, continuing anyway...", "⚠".yellow());
|
||||||
|
} else {
|
||||||
|
println!("{} Licenses accepted", "✓".green());
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Installing SDK packages (this may take a few minutes)...");
|
||||||
|
|
||||||
|
// Build command for package installation
|
||||||
|
let mut cmd = if cfg!(target_os = "windows") {
|
||||||
|
let mut c = Command::new("cmd");
|
||||||
|
c.arg("/c");
|
||||||
|
c.arg(sdkmanager);
|
||||||
|
c
|
||||||
|
} else {
|
||||||
|
Command::new(sdkmanager)
|
||||||
|
};
|
||||||
|
|
||||||
|
let status = cmd
|
||||||
|
.arg(format!("--sdk_root={}", sdk_root.display()))
|
||||||
.arg("platform-tools")
|
.arg("platform-tools")
|
||||||
.arg("platforms;android-34")
|
.arg("platforms;android-34")
|
||||||
.arg("build-tools;34.0.0")
|
.arg("build-tools;34.0.0")
|
||||||
.status()?;
|
.stdout(Stdio::inherit())
|
||||||
|
.stderr(Stdio::inherit())
|
||||||
|
.status()
|
||||||
|
.context("Failed to run sdkmanager for package installation")?;
|
||||||
|
|
||||||
|
if !status.success() {
|
||||||
|
anyhow::bail!("Failed to install Android SDK packages");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn verify(sdk_path: &Path) -> Result<()> {
|
pub fn verify(sdk_path: &Path) -> Result<()> {
|
||||||
if !sdk_path.exists() {
|
if !sdk_path.exists() {
|
||||||
anyhow::bail!("Android SDK not found at: {}", sdk_path.display());
|
anyhow::bail!(
|
||||||
|
"Android SDK not found at: {}\n\
|
||||||
|
Run 'weevil sdk install' to download it automatically,\n\
|
||||||
|
or install manually from: https://developer.android.com/studio#command-tools",
|
||||||
|
sdk_path.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let platform_tools = sdk_path.join("platform-tools");
|
let platform_tools = sdk_path.join("platform-tools");
|
||||||
if !platform_tools.exists() {
|
if !platform_tools.exists() {
|
||||||
anyhow::bail!("Android SDK incomplete: platform-tools not found");
|
anyhow::bail!(
|
||||||
|
"Android SDK incomplete: platform-tools not found\n\
|
||||||
|
Expected at: {}\n\
|
||||||
|
Run 'weevil sdk install' to complete the installation",
|
||||||
|
platform_tools.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user