This was good while it lasted, but keeping this up to date with changes to the Arduino distribution is not something that I want to put effort into.
PlatformIO seems to be the current best replacement for this project.
An alternative way of building arduino sketches with SCons.
This project is designed to be:
- Flexible. Code generation? Multiple builds for different boards uploaded to the correct ports from one script? No problem.
- Easy to understand. No source munging. No automatic library detection. No magic.
This can either be installed system-wide, or per-project. Either way,
arduino.py
should be installed into $SITE_SCONS/site_tools
, where
$SITE_SCONS
is one of the directories listed in the
SCons man page under
the --site-dir
flag.
On Linux the following directories are appropriate:
/usr/share/scons/site_scons
$HOME/.scons/site_scons
./site_scons
Installing into $HOME/.scons/site_scons
can be accomplished by running
./install.sh
.
This script does not do any munging of your source files, so you may need
reorder your functions (or add function prototypes), and add
#include <Arduino.h>
. Your sketch should be in a .cpp
file, rather than an
.ino
file.
A script to compile and upload a basic sketch might look something like this:
env = Environment(tools=["default", "arduino"])
env.ConfigureBoard("atmega328")
core = env.ArduinoCore()
sketch = env.Sketch("blink", ["blink.cpp", core])
env.Upload(sketch)
See the examples
directory for more examples.
Installing the tool into an environment gives it the following methods:
This sets defaults for a whole bunch of environment variables (described
below), based on the board name. The supported boards and their settings can be
found in $ARDUINO_HOME/hardware/arduino/boards.txt
.
Compile the arduino core library into a static library.
Compile a standard arduino library into a static library, and add it to the include path.
Compile an arduino library in a given directory into a static library, and add it to the include path.
Uses.env.Program
and env.Hex
to compile a list of sources (either source
files or libraries) into a hex file (named name.hex) for uploading.
Adds an alias (named upload by default) which uploads the given hex file to an
arduino connected to $UPLOAD_PORT
. Strange things happen if this is called
multiple times with the same name; either add an alias which defers to multiple
upload targets, or use env.UploadAll()
.
Add an alias which defers to all upload targets in $ALL_UPLOADS
, which is
updated by env.Upload
.
The root of the arduino install. By default this is taken from the environment
variable of the same name; if this is not found, /usr/share/arduino
is used.
The name of the board passed to env.ConfigureBoard
.
CPU frequency in Hz.
MCU string passed to gcc and avrdude.
Board variant.
Directory for the above variant.
Core name for this board; always "arduino".
Directory of the core library for this board.
The directory to build in, by default build/$BOARD
.
The avrdude binary to use.
Flags to pass to avrdude.
The full avrdude command line.
The upload protocol to use with avrdude.
Upload speed for this board.
USB port to upload to, by default /dev/ttyUSB0
.
The following variables have their standard meanings, and are set by env.ConfigureBoard
:
MIT licensed; see LICENSE
.