Avoiding unnecessary compilation

30 views
Skip to first unread message

Brendan Ribera

unread,
Dec 8, 2011, 7:00:44 PM12/8/11
to mirah
I'm using Mirah and Pindah to create a full-featured Android
application. My project is 33 mirah source files that expand into 196
classfiles.

Each time I build the app, I get to twiddle my thumbs for 80 seconds
while *everything* is compiled from scratch. The more code I write,
the longer this time gets; I remember fondly when this lag was "only"
30 seconds. This is especially frustrating if all I've changed is an
xml resource, for example.

Ideally, source files that have not changed would require no
compilation. This is in line with an existing-but-far-too-general
ticket [1].

I'm going to commit a few hours to try to implement this, but any
ideas/pointers/collaboration would be appreciated. Thanks!

-Brendan

1. https://github.com/mirah/mirah/issues/14

Rib Rdb

unread,
Dec 8, 2011, 7:13:36 PM12/8/11
to mi...@googlegroups.com
The tricky thing is that we don't know what files a .class file depends on. There could be multiple mirah files contributing when macros are used, or even non-mirah files if you're using edb.  The easiest thing to do is express the dependencies in your build configuration and let the build tool figure out which files to recompile.  This isn't hard with rake, but you're probably using ant for android development? I don't know how to do that with ant.

Roger Pack

unread,
Dec 8, 2011, 7:25:40 PM12/8/11
to mi...@googlegroups.com
On Thu, Dec 8, 2011 at 5:13 PM, Rib Rdb <rib...@gmail.com> wrote:
The tricky thing is that we don't know what files a .class file depends on.

Maybe after compilation it should write out some "meta" file -- "I generated these class files!"
Then you could compare the mtime of that file with the .mirah file itself

Tyler Smith

unread,
Dec 27, 2011, 1:11:35 PM12/27/11
to The Mirah Programming Language
Hey Rib Rdb,

Do you have any resources about how to do this with rake? I've tried
modifying the Dubious Rakefile, but it rebuilds things every time
(since there doesn't seem to be anything telling it not to). I've
done a lot of Googling, but as far as I can tell this is something
most people do with ant/ivy.

Is there already a good way to handle this? Or should I roll my own
using some kind of metafile that keeps track of what .class files are
up to date?

Thanks,
-Tyler

On Dec 8, 6:13 pm, Rib Rdb <rib...@gmail.com> wrote:
> The tricky thing is that we don't know what files a .class file depends on.
> There could be multiple mirah files contributing when macros are used, or
> even non-mirah files if you're using edb.  The easiest thing to do is
> express the dependencies in your build configuration and let the build tool
> figure out which files to recompile.  This isn't hard with rake, but you're
> probably using ant for android development? I don't know how to do that
> with ant.
>

Rib Rdb

unread,
Dec 28, 2011, 2:33:28 PM12/28/11
to mi...@googlegroups.com
I can't find a really good example of this at the moment, but the mirah-parser Rakefile is the best I can find at the moment.


This tells rake that NodeMeta.class needs to be rebuilt whenever its source file changes:
file 'build/org/mirahparser/ast/NodeMeta.class' => 'src/org/mirah/ast/meta.mirah' do
  mirahc('src/org/mirah/ast/meta.mirah',
         :dest => 'build'
         #:options => ['-V']
         )
end

This says that Node.class needs to be rebuilt when any of its source files change or when NodeMeta.class changes (because Node uses macros from NodeMeta).
file 'build/mirahparser/lang/ast/Node.class' =>
    ['build/org/mirahparser/ast/NodeMeta.class'] + Dir['src/mirah/lang/ast/*.mirah'] do
      mirahc('.',
             :dir => 'src/mirah/lang/ast',
             :dest => 'build',
             :options => ['--classpath', 'build'])
end

Tyler Smith

unread,
Dec 29, 2011, 3:53:22 PM12/29/11
to The Mirah Programming Language
Thank you so much! I've got things going much better now.
Reply all
Reply to author
Forward
0 new messages