Hi all,
In relation to some ideas around regression testing I began looking at adapting the preprocessing/compilation portion of the Arduino IDE so that it could be run from the command line.
Under the assumption it would be easier (and more fun) to be using Python rather than Java but still wanting to leverage the existing Java code I began to explore using Jython.
I've documented my experience so far with the
Arduino IDE and Jython. This is post is a summary of my findings so far.
I've managed to run the pre-preprocessor successfully on a sketch from the commandline with a very short Jython script.With the preprocessor accessible in this manner it should be possible to modify the Makefile to work on a standard PDE file I think. I presume it would also be possible to make this behaviour work as a command line option for the IDE with some work.
Unfortunately, when I moved on to trying to get the example compiled as well, I discovered the IDE is highly coupled—even between UI and non-UI-specific classes. The source also has a lot of code (sometimes commented out, sometimes not) that is only required for its original use in the Processing IDE. Many of the comments have not been changed from the Java-specific comments of the Processing IDE to the C++ ones of the Arduino IDE.
The biggest issue is that you need to have a
Sketch instance and to create one you need to supply it an
Editor instance—which pulls in GUI related code. The
Editor class accesses
Base and
Preferences classes as well, which then brings in dependencies on preferences files, file paths and operating systems and it all blows up in a mess.
The sketch shouldn't require an Editor instance in order to compile it. I tried supplying a Null but it barfs. I then tried sub-classing the Editor class in order to dummy out the routines causing problems, but there seems to be no way to stop the original/super constructor from being called.
So, it seems without extensive re-working getting the compilation stage to work independently of the IDE won't be a goer. IMO the two should be totally separated but I suspect it would be an uphill battle trying to change the IDE code if there's a desire to stay inline with the Processing IDE.
I think there would be a lot of benefit in having the GUI code de-coupled from the preprocessing/compilation stages in terms of development and testing. I must admit I am skeptical about the integration work required to make this happen being supported by the core Arduino and Processing teams however given other, more obvious, demands. But I could be surprised. :-)
None the less, I'm pleased it at least seems possible to get the pre-processor to run separately and will continue poking at this as required by progress with the testing side of my project.
Feedback?
--Phil.
[
Also posted to the Developers list.]