Using tup in Eclipse

336 views
Skip to first unread message

Freddie Chopin

unread,
Dec 5, 2012, 4:51:16 PM12/5/12
to tup-...@googlegroups.com
This message is a small tutorial how to make tup faster in Eclipse.

I've got a project that builds with tup from command line in about 35s, but running the build in Eclipse the first time ("tup upd" configured as "make target", but it can also be configured to be main project builder via project properties), took 2x longer - 72s. It makes no difference to disable build logging, lower the number of lines of console or change some strange options deep in the internals of Eclipse, so just leave that at the default or whatever you have already set. After some investigation I've come to conclusion that the culprit is the "error parser" of Eclipse, which scans the output of build tool, compares that to some RegEx patterns in search for errors, warnings, infos etc. so that you could have errors linked with file and line where it actually is. As tup is not make, Eclipse was trying all the parsers, matching neither of them, which took quite a lot of time.

The easiest solution is to disable this feature, but that's not the best idea (;

The better solution is to add error parser specific to tup, configure it to be the first one so that tup output would be consumed as fast as possible, only leaving actual compiler output to the other parsers. To do that go to Window > Preferences > C/C++ > Build > Settings and open the Error Parsers tab. In there add a new one, call it whatever you like (I named mine Tup Ignore Parser, you'll see in a moment why) and move it to the very top of the list. Now select it and add following 4 entries:
1. "tup warning: .*"
2. "[ \t0-9]+% [0-9]+\) \[[0-9.]+s\] .*"
3. "\[ tup \] \[[0-9.]+s\] .*"
4. "tup error: .*"
Of course ommit the quotes.
All of them have "Ignore" severity, so they do nothing, except for catching the output early and not giving it to further patterns (; The first one is for warnings about tup being unable to unlink some depfiles (seems to be some kind of Windows bug), and also info about file being removed/changed outside of tup. The second one is for actual compilation lines, where tup gives a percentage, number and time of each command, so that's not interesting at all. The third one is for "main" tup messages like "scanning filesystem", "executing commands", "updated" etc. that are prefixed with a "[ tup ]" tag. The fourth one could be worth parsing as that's where the real errors are displayed (the ones about problem in tup files etc.). There is a small problem that VERY long lines are still not being detected by the rules (like archiving a lot of objects), but that's maybe 1% of all commands executed, so not a big deal.

So you've got the parser, now it's time to enable it for the project you have, so select your project in the Project Explorer and go to Project > Properties > C/C++ Build > Settings and select Error Parsers tab. Select your previously created tup parser, enable it with a checkbox and move it to the top of the list.

And you're done!

With this modifications the build in Eclipse takes more or less exactly the same time as in command line, so I guess a full success!

There's a small inconvenience that the output of Eclipse console seems to be coming in "waves", so instead of seeing a nice "flow" of commands, there's a rush of 50 lines and a pause, but I try to blame that on tup being too fast (;

There is also a bigger inconvenience that tup's output cannot be parsed by Eclipse's path discovery, so you cannot have the include paths of the project magically discovered... That's because tup works like a recursive make - the commands are executed from the folder of the Tupfile - but it doesn't produce the output of make (make[x]: Entering / Leaving directory ...), which seems essential for this thing to work. For my project I run the "normal" make build (which is 3-4x longer, due to Makefiles running a single job) for Eclipse to get the paths, but that's just because there's a ready make system there... Otherwise I'd probably have to set that manually, or maybe there would be a way to mimic these output lines of make with some strange commands in tup - I don't know... The parser that does this thing is not configurable - it's CDT pushd/popd CWD Locator. You'd probably have to do that in Eclipse's source...

If anyone would come with an improvements of the above patterns it would be nice to share them (; If I come to making the parser actually parse something I'll share too!

4\/3!!

Mike Shal

unread,
Dec 6, 2012, 10:36:01 PM12/6/12
to tup-...@googlegroups.com
Nice! Sounds like a frustrating issue to debug. Can I put this on the
tips & tricks page as well?

Thanks,
-Mike

Freddie Chopin

unread,
Dec 7, 2012, 2:12:05 AM12/7/12
to tup-...@googlegroups.com
W dniu piątek, 7 grudnia 2012 04:36:01 UTC+1 użytkownik mar...@gmail.com napisał:
Nice! Sounds like a frustrating issue to debug.

Indeed. For a moment I was seriously thinking (again) about using something else instead of Eclipse [; Fortunately I don't have to (;
 
Can I put this on the
tips & tricks page as well?

Of course! If you don't plan on rewriting that you may want to fix some spelling or grammar, as I'm sure there are a couple of stupid mistakes there (I'm not a native speaker)...

4\/3!!
Reply all
Reply to author
Forward
0 new messages