Go Down

Topic: Arduino bundle for TextMate (Read 5 times) previous topic - next topic

mellis

The automatic prototype generation works with a simple regular expression to try to detect function definitions, and then just ignores setup() and loop().  It doesn't work all that well (it gets confused if your return type is multiple words like "unsigned int" or is on a different line than the rest of your function header).  Still, it's been okay for most things.

In fact, here it is: ^(\w+)\s+(\w+)\s*\(([^)]*)\)\s*{

westfw

#16
Aug 30, 2007, 02:19 am Last Edit: Aug 30, 2007, 02:22 am by westfw Reason: 1
There is cproto (http://cproto.sourceforge.net/) which will generate prototypes for you.
I guess you COULD create a makefile that would do all that the arduino program does.  You'd have rules like:
Code: [Select]

%.cpph: &.cpp
  cproto %.cpp >%.cpph

%.elf: %.cpp %.cpph
   $(GCC) -I$(ARDUINOINC)/prefix.h -I%.cpph %.cpp ...


(that's probably WAY wrong.  I HATE makefiles.  make is a lovely example of a 1970s program that should have been replaced long ago instead of patching it to handle modern circumstances.   A good percentage of Arduinos goodness probably comes from letting the user never have to deal with makefiles!)

Oliver Keller

#17
Aug 30, 2007, 12:22 pm Last Edit: Aug 30, 2007, 12:22 pm by ozel Reason: 1
@westfw
Well i'm not after a substitution of the current java compile with a makefile. I just like to keep an alternative, when not working with the IDE.
It's not that I like makefiles, but for microcontroller programming is still not too hard to use it - IMHO.
Although I frequently forget important makefile knowledge... :-)
Speaking of it, i think there is a dependency erro in my makefile. Did anybody try it?

Cproto is interesting, thanks! Maybe mellis will use it in the IDE?
But as long as it's not a standard install on unix systems I wouldn't want to use it in a makefile.

On the other hand I think using a makefile, even if it's only in the background of an IDE, is a better standard than doing some custom java-based compile process in the IDE, like it's now. Esp. for maintainance between different IDE versions a certain compile standard could be better...

Of coruse, I agree that the Ardunio goodness comes with the current software and IDE!
But I think it's also good, that the Ardunio IDE doesn't allow too much simplification of C code.
I think the current state of preprocessing is a perfect compromise.
I hope it won't walk away any further from standard avr-gcc C code. Incorporating an alternative  language than C, though, would be again a different question. E.g. ruby arduino developement: http://rad.rubyforge.org/  

mellis

#18
Aug 30, 2007, 03:35 pm Last Edit: Aug 30, 2007, 03:36 pm by mellis Reason: 1
Using Makefiles as a backend from the IDE sounds good, but it was a nightmare in practice (we did it in the original versions of Arduino).  Especially on Windows, it was impossible to get working consistently - some machines seemed to want / as the path separator, some wanted \ and some wanted \\.  We had to maintain multiple slightly different makefile version.

It was also difficult for people to make changes to the build process, because they'd get thrown by the common Makefile problem (like using spaces instead of tabs, etc.)  Now, with the preferences file, there aren't many things you can change, but they are relatively easy.  We could just pass all the variables on to the makefiles, but at this point there are some decisions being made that we be a pain to replicate in makefiles.  

I kind of like the idea that the IDE does it's own thing, but we also provide a Makefile for people who want one.

It would be good to have a better way to generate function prototypes, but it's also a hassle to include another program, and so far, the current method seems to be "good enough".

Of course, these are all interesting ideas, and I appreciate the discussion.

Oliver Keller

I fully understand this. Maybe cmake is worth a try... Though cmake would add many more MBs.

I forgot one thing that's really great about using a makefile now:
You can have your preferences saved with the projects.
E.g. on some boards you prefer to use the bootloader while with others you're setup requires an AVRISP MKII - in any case you just set it once. Esp. ATmega8 vs. ATmega168 switching becomes obsolete! I guess some catch this problem often nowadays when having diecimila and older boards around at the same time. Also you can have different clock speeds and baudrates without changing preferences everytime you switch projects etc...

Yes, this is rather advanced stuff, but it's nice beeing still able to do it with a makefile - just as you said, david. I agree, as long as prototype creation works most of the time, better don't touch it...

Go Up