aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2013-05-30 13:35:37 +0200
committerMatthijs Kooijman <matthijs@stdin.nl>2013-05-30 19:27:11 +0200
commit1f043bb819064d786d106d40ffbff5b92b1a0ced (patch)
tree97760ab55c37a811ffda24f0f345882832824f96
parent97fa5ae161e3aae3fb5f503effc8b8cb0ee65935 (diff)
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.
-rw-r--r--arduino-mk/Arduino.mk24
1 files 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 <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)