Pages: [1]   Go Down
Author Topic: Patch for Arduino.mk to support errors pointing to the .ino file  (Read 779 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Emacs & Catapults
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

  I'm programming my arduino with Emacs, and using the Arduino.mk that came with the install on my Linux box (version 1.0).  A distraction is that errors from the .ino file show up pointing at the temporary cpp file.  For example, errors point at build-cli/Blink.cpp instead Blink.ino.  My patch adds a #line compile directive so that Blink.cpp reports errors from the  ino file.  The output now looks like this and is parsable by Emacs:

make
echo '#include <Arduino.h>' > build-cli/Blink.cpp
echo '#line 1 "Blink.ino"' >> build-cli/Blink.cpp
cat  Blink.ino >> build-cli/Blink.cpp
/usr/bin/avr-g++ -MM -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard  -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/Blink.cpp -MF build-cli/Blink.d -MT build-cli/Blink.o
cat build-cli/Blink.d > build-cli/depends.mk
/usr/bin/avr-g++ -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard  -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/Blink.cpp -o build-cli/Blink.o
Blink.ino: In function ‘void loop()’:
Blink.ino:24:3: error: ‘moose’ was not declared in this scope
Blink.ino:29:1: error: expected ‘;’ before ‘}’ token
make: *** [build-cli/Blink.o] Error 1


This was accomplished by adjusting 2 rules in Arduino.mk like this:


Code:
# the pde -> cpp -> o file
$(OBJDIR)/%.cpp: %.pde
$(ECHO) '#include "WProgram.h"' > $@
$(ECHO) '#line 1 "$<"' >> $@
$(CAT)  $< >> $@

# the ino -> cpp -> o file
$(OBJDIR)/%.cpp: %.ino
$(ECHO) '#include <Arduino.h>' > $@
$(ECHO) '#line 1 "$<"' >> $@
$(CAT)  $< >> $@

My side project lately has been automating the compilation of sketches via Emacs using the defaults tools in the Arduino development install such as the default Arduino.mk.   Here is a link to that corner of the doc for my project: http://www.randomsample.de/cedetdocs/common/cedet/Arduino-Features.html
Logged

Pages: [1]   Go Up
Jump to: