This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Kawa compilation for Android, weird differences in compilation size


Using some of the build scripts that craven has shared previously, I'm
experimenting with using Kawa for writing Android apps. I've run into
an issue that I do not quite understand. The program I am trying to
compile is more or less a "hello world" program, like the following:

(require 'android-defs)
(activity
 net.kjeldahl.tournman.Front
 (on-create
  (let ((view
         (android.widget.LinearLayout
          (this)
          orientation: android.widget.LinearLayout:VERTICAL
          view: (android.widget.TextView
                 (this)
                 text: "Hello, Android from Kawa Scheme again!")))
        (actbar (getActionBar))
        )
    (setContentView view)
    (actbar:show)
    )))

This file is stored in a subdir named "src" in the project, and is the
only source file used.

Compiling this using craven's "make" script (that's a shell
scriptfile, not a traditional make file), this program compiles down
to an apk of around 48kb, pretty nice. After doing some minor changes
to file naming and similar I noticed the apk almost doubled in size,
and I wanted to figure out why.

In the end it seems it depends on the name of the source file (scm)
shown above. If I name it "Front.scm", the apk doubles in size. Any
other name and it stays at 48kb.

Since the process of running it through proguard is pretty heavy (hard
to debug), I looked at the generated java class files to see if I
could find similar differences. I believe I did. If I name the source
file "Front.scm", the following class files and sizes are:

-rw-rw-r-- 1 marius marius 1729 Sep 17 08:50 Front.class
-rw-rw-r-- 1 marius marius  337 Sep 17 08:50 Front$frame.class
-rw-rw-r-- 1 marius marius  349 Sep 17 08:50 R$attr.class
-rw-rw-r-- 1 marius marius  405 Sep 17 08:50 R.class
-rw-rw-r-- 1 marius marius  409 Sep 17 08:50 R$drawable.class

Just renaming the source file to "frontsrc.scm" (or any other name
AFAIK), make generated the following files:

-rw-rw-r-- 1 marius marius 1154 Sep 17 08:51 Front.class
-rw-rw-r-- 1 marius marius  937 Sep 17 08:51 frontsrc.class
-rw-rw-r-- 1 marius marius  349 Sep 17 08:51 R$attr.class
-rw-rw-r-- 1 marius marius  405 Sep 17 08:51 R.class
-rw-rw-r-- 1 marius marius  409 Sep 17 08:51 R$drawable.class

Disregarding the sizes of the R stuff (which is identical for both
runs), you'll notice that the sum of the file sizes are more or less
equal, but depending on the name one of the is larger than in the
other run. I believe this difference is the reason why proguard is
able to get rid of more stuff.

The relevant compilation line from craven's build script is:

echo Compiling Scheme
CLASSPATH=$KAWA:$AJAR:bin/classes/ java kawa.repl -d bin/classes -P
${PACKAGE}. --module-static-run --warn-undefined-variable
--warn-unknown-member --warn-invoke-unknown-method --warn-as-error -C
$(find src -name *.scm)

I'm posting here hoping somebody knows more about the process and can
share some details on why this behaviour should or should not be
expected. I get more than a bit worried when the name of my source
files affect the generated binaries...

Thanks,

Marius K.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]