From 8880a75243ada55aa8070502aca0bd956e8e4e38 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 26 Aug 2026 17:21:14 +0000 Subject: [PATCH] Add Cloud Agent environment setup for Arduino toolchain Co-authored-by: DunnoCoding_Plus --- .cursor/environment.json | 5 ++++ .cursor/install.sh | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .cursor/environment.json create mode 100755 .cursor/install.sh diff --git a/.cursor/environment.json b/.cursor/environment.json new file mode 100644 index 0000000..33935e9 --- /dev/null +++ b/.cursor/environment.json @@ -0,0 +1,5 @@ +{ + "name": "RoboServo", + "user": "ubuntu", + "install": "bash .cursor/install.sh" +} diff --git a/.cursor/install.sh b/.cursor/install.sh new file mode 100755 index 0000000..a43c38d --- /dev/null +++ b/.cursor/install.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# Idempotent Cloud Agent bootstrap for the RoboServo Arduino library. +# Installs the pinned Arduino CLI and the AVR core used by CI, then verifies +# the toolchain by compiling the AVR driver-API examples. +set -euo pipefail + +ARDUINO_CLI_VERSION="1.5.1" +ARDUINO_CLI_SHA256="28a8e119c498a25607821c36cb2dc49e8463941b261a0d99091baa7bc692dd2b" +AVR_CORE_VERSION="1.8.7" + +BIN_DIR="$HOME/.local/bin" +mkdir -p "$BIN_DIR" +export PATH="$BIN_DIR:$PATH" + +# Ensure ~/.local/bin is on PATH for future non-login shells. +if ! grep -qs 'HOME/.local/bin' "$HOME/.bashrc" 2>/dev/null; then + echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc" +fi + +install_arduino_cli() { + if command -v arduino-cli >/dev/null 2>&1 \ + && arduino-cli version 2>/dev/null | grep -q "Version: ${ARDUINO_CLI_VERSION}"; then + echo "arduino-cli ${ARDUINO_CLI_VERSION} already installed." + return + fi + local archive="/tmp/arduino-cli_${ARDUINO_CLI_VERSION}_Linux_64bit.tar.gz" + curl --fail --location --retry 6 --retry-all-errors --retry-delay 10 \ + --output "$archive" \ + "https://github.com/arduino/arduino-cli/releases/download/v${ARDUINO_CLI_VERSION}/arduino-cli_${ARDUINO_CLI_VERSION}_Linux_64bit.tar.gz" + echo "${ARDUINO_CLI_SHA256} ${archive}" | sha256sum --check --strict + tar -xzf "$archive" -C "$BIN_DIR" arduino-cli +} + +install_arduino_cli + +arduino-cli core update-index +if arduino-cli core list 2>/dev/null | grep -q "arduino:avr[[:space:]]*${AVR_CORE_VERSION}"; then + echo "arduino:avr@${AVR_CORE_VERSION} already installed." +else + arduino-cli core install "arduino:avr@${AVR_CORE_VERSION}" +fi + +# Verify the toolchain by compiling the driver-API examples exercised in CI. +for example in HBridgeDriver StepDirDriver FourWireStepper Pca9685Servos; do + arduino-cli compile --warnings all --library . \ + -b arduino:avr:uno "examples/${example}" +done + +echo "RoboServo environment ready: arduino-cli ${ARDUINO_CLI_VERSION}, arduino:avr@${AVR_CORE_VERSION}."