Proposals for advanced Library Handling:
Use statement '#library Foo' instead of '#include <Foo.h>' to import librariesWhy:
Much easier to comprehend than the include statement.
Users know exactly where they pull in Arduino library code and where avr-libc code is referenced.
The IDE-Preprocessor knows exactly which libaries to include. It can give an early warning
"Library 'FooHoo' not found"
before the compiler chokes on the unsatisfied #include statement and spits out some incomprehensible tech-message
Support a library.properties fileWhy:
Two questions come up regulary
- A) Library X does not work with board Y
- B) Why can't I import an existing library into my own library
Solution:
A Library Foo can have (optionally) a config-file named
Foo.properties. This file is parsed be the IDE every time the Verify/Upload process is started and a Sketch inludes the library.
The File supports (for a start) two entries
#properties for library Foo
depends=Wire
boards=arduino.Mega arduino.Nano xmega.XPlain
The
depends entry lists all Libraries that the current Library is build upon and which have to be compiled and linked into to project to make the sketch work.
I our example Library Foo uses the Wire-lib.
There is no need for hacks anymore, like mentioning the Wire-Lib in the Sketch-code even though it is never exlicitly called.
The
boards entry lists all the boards that are supported for by the code.
boards.txt should provide a unique key for each board like the examples used above. The
arduino. is a kind of namespace-id which will make is possible to write a Library for third party boards.
myXMega.XPlain in the example would be a board from the external myXMega project. The parser supports wildcards
arduino.*.
For backward compatibility the existance of such a file is not enforced. If no Foo.properties files exists, the library will be comiled for all boards (no matter if it supports the hardware or not).