Building games from the command line under Linux

(Miloslav Číž) #1

This is not a nice and tidy tutorial, it’s a helping hand to probably only a few people who may be looking for a specific information.

I finally got Arduboy to fit my CLI workflow and would like to share how I did it for people whose workflow is similar.

I have kind of a quick and dirty script that however seems to work. I am sharing it because I haven’t found any similar tutorial here, so hopefully it may help some other GNU/Linux newcomer to jump right in. Feel free to share any improvements on this.

I use vim as a text editor under GNU/Linux and so I want to compile and run everything from the command line. Here is the Bash script I use (I left in the variables set for my current project so that you have an idea of what to change them to):



clear; clear;

mkdir "$SKETCH_DIR/build"

./arduino-builder -hardware ./hardware -tools ./hardware/tools/avr -tools ./tools-builder -libraries ./libraries -libraries "$LIBRARY_DIR" -build-path "$SKETCH_DIR/build" -fqbn arduino:avr:leonardo "$SKETCH_DIR/$SKETCH_FILE"

if [ $? -eq 0 ]; then
  cd "$ABE_DIR"
  ./ProjectABE "$SKETCH_DIR/build/$SKETCH_FILE.hex"

It compiles the sketch using arduino-builder and if the build is successful, runs it in the ProjectABE emulator.

TIP: If it’s reasonably simple, I find it useful to make the .ino file compilable (using a few #ifdefs) for PC with the normal compiler (gcc) for quick debugging. It’s quicker, allows you to print out values in a way you’re used to and allows use of tools such as valgrind, gdb etc. (It also makes you separate the Arduboy specific code from the general logic, which later makes porting to other platforms easier.)

Better Development Environment?
(Matt) #2

There’s also the Arduino Makefiles, which work well for the ArduBoy

I added one more rule to mine to launch the game in ProjectABE.

(Miloslav Číž) #3

@FManga informed me that ProjectABE detects when the hex file changes and reloads it automatically, so it’s actually not even needed to launch it from the CLI. I also find it better because when launching from CLI, the window has a wrong size and position and has to be adjusted with mouse.

(Matt) #4

Oh nice, I didn’t realize that. I could position the emulator up in the corner and just leave it running then.