Comments on Arduino 1.5 Specifications

cmaglie:

Jantje:
It is with pain in the hart that I conclude that I currently see no other option than stopping my Arduino eclipse plugin purely for this library specification.

Believe me, this is the last thing that I want to see happen. So, first, thanks for your patience, I'm sure we can find a solution.

I'm happy to hear this.

cmaglie:

Jantje:
In the .cpp and .c files in the library folder
add a #ifdef ARDUINO_ARCH_{build.arch} at the top and #endif at the bottom.
This would mean that all *.c *.cpp files in avr start with

#ifdef ARDUINO_ARCH_AVR

and end with

#endif

well, this is what we are trying to avoid: repeating the same #ifdef when its not needed.

I don't see why you use the word repeating. if each implementation has 1 header and 1 source file each #ifdef ARDUINO_ARCH_{build.arch} is only needed once (source code) and to be perfect twice (source code and header so the indexer does not see double declarations)
I do not see why you are trying to avoid this. Each and every header file should have something similar to handle multiple inclusions.
IMHO it is also good that you can see (and get guarantee) that this code is only used for a certain platform.

cmaglie:

Jantje:
I know how I can modify the Arduino eclipse plugin so the makefile is ok. However this will not work for the indexer. As such the indexer will not know whether you are using sam or avr which reduces the added value of using a real IDE.

There are basically 2 options I still see possible.
The first is to add a lot of code to add and remove path variables when libraries get added or removed.

What your plugin does when a user adds a library?

When a library is added the plugin adds a symbolic link to the root of the library folder at the location [project]/libraries/[libraryname].
It also adds a include link for all languages (C and C++ in V2 and C C++ asm in V1).
The end user needs to add the include to the code himself.
Note I do not have a delete library functionality. A user can delete the link but that will not remove the includes.

cmaglie:
I see that you already handle the variant folder: for the libraries it should be the same, or something very similar, what I'm missing?

You are right about the variant folder being similar but it is not the same.
Let me first explain how I handle the variant/core
I create 2 symbolic links one with the name [project]/arduino/core and one with [project]/arduino/variant. These link to the appropriate location on disk.
I also create 2 include links to /arduino/core and arduino/variant.
This means that when the user selects another board I may need to update the link location of the link names /arduino/core and arduino/variant.
Note that this solution breaks the symmetry between the "disk situation" and the "eclipse project situation".
The main reason why this works is because arduino only uses

#include "pins_arduino.h"

In other words it relies on the include path to find the file.
When we have a mega; makefile will find it at arduino-1.5.2/hardware/arduino/avr/variants/mega/pins_arduino.h.
The indexer however will find it at [project]/arduino/variant/pins_arduino.h
Understanding this difference is important for the next part.

Suppose I do something similar for a library.
I create 2 link locations [project]/libraries/[libname]/lib/arch and [project]/libraries/[libname]/src.
[project]/libraries/[libname]/lib/arch links to ../libraries/[libname]/lib/[arch]
[project]/libraries/[libname]/arch links to ../libraries/[libname]/src
I add [project]/libraries/[libname]/lib/arch and [project]/libraries/[libname]/src. to the include path.
Apart from the maintenance nightmare (There is no delete lib and I don't know how to make one) and apart from the potential performance impact when changing board I expect this to work in all cases for the makefile but not for the indexer.

One scenario I think of is the following:
I'm building a board that has a "different" architecture than avr but is very much alike. Some libraries need to change but some are 100% compatible. Suppose this architecture is called "jantje"
For each library I support I create the folder jantje under [libname]/lib/ where I place my code.
Assume that the Servo lib I need is 100% compatible with the avr lib. What I will do is create 2 files:
Servo.cpp which looks like this

#include ../avr/Servo.cpp

ServoTimers.h which looks like this

#include ../avr/ServoTimers.h

This will work fine for the makefile but not for the indexer as [project]/libraries/[libname]/avr does not exist.

I hope this explanation is understandable; it is clearly not as simple as embedXcode .
Best regards
Jantje