Skip to content

Commit 8880a75

Browse files
Add Cloud Agent environment setup for Arduino toolchain
Co-authored-by: DunnoCoding_Plus <dunknowcoding@users.noreply.github.com>
1 parent 5656781 commit 8880a75

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

‎.cursor/environment.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "RoboServo",
3+
"user": "ubuntu",
4+
"install": "bash .cursor/install.sh"
5+
}

‎.cursor/install.sh‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# Idempotent Cloud Agent bootstrap for the RoboServo Arduino library.
3+
# Installs the pinned Arduino CLI and the AVR core used by CI, then verifies
4+
# the toolchain by compiling the AVR driver-API examples.
5+
set -euo pipefail
6+
7+
ARDUINO_CLI_VERSION="1.5.1"
8+
ARDUINO_CLI_SHA256="28a8e119c498a25607821c36cb2dc49e8463941b261a0d99091baa7bc692dd2b"
9+
AVR_CORE_VERSION="1.8.7"
10+
11+
BIN_DIR="$HOME/.local/bin"
12+
mkdir -p "$BIN_DIR"
13+
export PATH="$BIN_DIR:$PATH"
14+
15+
# Ensure ~/.local/bin is on PATH for future non-login shells.
16+
if ! grep -qs 'HOME/.local/bin' "$HOME/.bashrc" 2>/dev/null; then
17+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"
18+
fi
19+
20+
install_arduino_cli() {
21+
if command -v arduino-cli >/dev/null 2>&1 \
22+
&& arduino-cli version 2>/dev/null | grep -q "Version: ${ARDUINO_CLI_VERSION}"; then
23+
echo "arduino-cli ${ARDUINO_CLI_VERSION} already installed."
24+
return
25+
fi
26+
local archive="/tmp/arduino-cli_${ARDUINO_CLI_VERSION}_Linux_64bit.tar.gz"
27+
curl --fail --location --retry 6 --retry-all-errors --retry-delay 10 \
28+
--output "$archive" \
29+
"https://github.com/arduino/arduino-cli/releases/download/v${ARDUINO_CLI_VERSION}/arduino-cli_${ARDUINO_CLI_VERSION}_Linux_64bit.tar.gz"
30+
echo "${ARDUINO_CLI_SHA256} ${archive}" | sha256sum --check --strict
31+
tar -xzf "$archive" -C "$BIN_DIR" arduino-cli
32+
}
33+
34+
install_arduino_cli
35+
36+
arduino-cli core update-index
37+
if arduino-cli core list 2>/dev/null | grep -q "arduino:avr[[:space:]]*${AVR_CORE_VERSION}"; then
38+
echo "arduino:avr@${AVR_CORE_VERSION} already installed."
39+
else
40+
arduino-cli core install "arduino:avr@${AVR_CORE_VERSION}"
41+
fi
42+
43+
# Verify the toolchain by compiling the driver-API examples exercised in CI.
44+
for example in HBridgeDriver StepDirDriver FourWireStepper Pca9685Servos; do
45+
arduino-cli compile --warnings all --library . \
46+
-b arduino:avr:uno "examples/${example}"
47+
done
48+
49+
echo "RoboServo environment ready: arduino-cli ${ARDUINO_CLI_VERSION}, arduino:avr@${AVR_CORE_VERSION}."

0 commit comments

Comments
 (0)