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.
This commit is contained in:
Matthijs Kooijman 2013-05-30 13:35:37 +02:00
parent 97fa5ae161
commit 1f043bb819

View file

@ -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 <Arduino.h>\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)