From 1f043bb819064d786d106d40ffbff5b92b1a0ced Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:35:37 +0200 Subject: [PATCH] Compile .ino and .pde files directly Before, they were copied to a .cpp file to add the Arduino.h/WProgram.h include. However, this would cause the compiler error messages to not refer to the right filename, making it hard to use the compiler output in an editor like vim to point out errors. By using gcc's -include option, there is no need to modify the ino/pde file before compiling. However, we will need to explicitely tell gcc that the source file is c++, because of the non-standard extensions. --- arduino-mk/Arduino.mk | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f2ec06e..8ca4026 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -858,21 +858,21 @@ $(OBJDIR)/%.d: %.S $(COMMON_DEPS) $(OBJDIR)/%.d: %.s $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) -# the pde -> cpp -> o file -$(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) - $(ECHO) '#include "$(PDE_INCLUDE)"\n#line 1' > $@ - $(CAT) $< >> $@ +# the pde -> o file +$(OBJDIR)/%.o: %.pde + $(CXX) -x c++ -include $(PDE_INCLUDE) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -# the ino -> cpp -> o file -$(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) - $(ECHO) '#include \n#line 1' > $@ - $(CAT) $< >> $@ +# the pde -> d file +$(OBJDIR)/%.d: %.pde + $(CXX) -x c++ -include $(PDE_INCLUDE) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ +# the ino -> o file +$(OBJDIR)/%.o: %.ino + $(CXX) -x c++ -include Arduino.h -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) +# the ino -> d file +$(OBJDIR)/%.d: %.ino + $(CXX) -x c++ -include Arduino.h -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) # generated assembly $(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS)