[Contents] [TitleIndex] [WordIndex

Guillaume Mazoyer - Porting Scilab on Android

Description

The goal of this project is to port Scilab on Android so it can run natively on this operating system. This needs to port all libraries used by Scilab on Android first and rewrite the user interface to make it touch friendly.

Deliverables

A modification of the Scilab source code to include the specific code for the Android target. An working .apk file that can be install on Android devices.

Progress reports

Report #1

Like a lot of French students that are at the university I still have to in class so this first report is not as big as it should be for someone which is working full time on his GSoC project. Until I pass my final exams at the end of June I still have to work on my university courses so I can't work full time on my GSoC project. So I will do bi-weekly reports at first and then after my finals I will start to make weekly reports.

My GSoC project is to port Scilab on Android. So when this year GSoC will end you should be able to group my reports together and title them "Scilab on Android, a porting story".

So what did I do during this first two weeks?

The goal of this first weeks was to get to know the code of Scilab and to compile a maximum of native dependencies so they can work on Android. This is the second task that took me the most hours to try to finish it.

To compile and run Scilab on Android all the dependencies must be compiled too. In opposition to Debian, for example, the future Android package for Scilab has to include all the necessary libraries for Scilab to run. So that what I tried and am still trying to do. Native dependencies are the most hard to port. Android provides a development kit to compile and use native code, this kit is called NDK (for Native Development Kit). So what I need to do is to include all native dependencies in the Android project for Scilab and when the build of the package (.apk file) starts all thoses libraries must be built.

So I started by creating a sample Android project with basically the minimal source code necessary to show something on the screen of the device. It is a "hello world" program for Android. Then I created a "jni" directory inside the project to put all the native libraries in it. Inside this directory, I have created 2 files: "Android.mk" and "Application.mk". These files are makefiles that the NDK reads when a build is launched. They contains all the rules to build what is inside the "jni" directory.

Luckly I found some resources on the web about how to use the NDK. I also try the examples given with it. I found some projects such as Gnash[1] and Mumble[2] which are currently being ported on Android. There is also an interesting book that I will buy as soon as I can, this book is Android NDK Beginner's Guide. It looks like it gives some good info to port libraries on Android.

For now I am trying to compile 4 native libraries:

I have managed to compile "libpcre" without any troubles but with some hacks I found on the web. For the rest, it looks to be more complicated and they do not compile on Android yet. Since all the libraries can be build thanks to the autotools, see[3].

I have also spoken with people who have ported Scilab on the Aakash tablet. They told me how they did it and I think that we can collaborate to speed up the port and having something working as soon as possible.

To port Scilab on Android I have imagined three steps:

I hope to find the proper way to compile libraries and Scilab to be able to start coding and have something "runnable" before the midterm.

Report #2

The scholar year is almost over so I can finally work more on Scilab to continue my GSoC project. I decided to review the entire process that I have imagined to build the version of Scilab for Android. Previously, I wanted to include dependencies sources and build them during the Scilab build. I ralized that it was not a good approach since it requires to embed all sources and write a makefile for each one of them. Most libraries have a build system based on autotools. So I decided to start from here. Using the autotools build system to build the libraries and then to package them in a .apk file with Scilab to install the whole thing on Android.

To make this happen, the first thing is to build a standalone Android toolchain. This is quite easy since the Android NDK has a script to do that.

${NDK}/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-andrideabi-4.3.3 --install-dir=${TOOLCHAIN}

This will create the standalone toolchain for ARM based devices in ${TOOLCHAIN}. Some `old' autotools build system don't accept Android target so it needs a little tweak to work.

for f in ${TOOLCHAIN}/bin/arm-linux-androideabi-*; do ln -sf ${f} ${f/arm-linux-androideabi-/arm-linux-eabi-}; done

Once it is done, the libraries using autotools can be configure with the classic ./configure && make && make install. This will compile the libraries with and install them in the toolchain. But this does not allows to compile Fortran libraries. The embedded GCC in the Android NDK does not allow to compile Fortran. That's a problem since we need some Fortran libraries. The following idea is still a work in progress. It needs to recompile GCC with enabling the Fortran support. It is a tricky work that can take a lot of time (depending on the machine). But someone managed to do it [1] that's why I started to follow the given instructions. Sadly, the NDK has evolved and the compilation still doesn't work for now.

To sum up a little, libxml2 and pcre have been built very easily but the Fortran libraries are still unbuildable. I hope that it will be fixed very soon. I started to write a script that takes care of downloading the tarballs, setting up the toolchain and compiling the libraries. I'll probably try to use this script and maybe write some other scripts to fully build Scilab on Android.

The idea of doing such a rework of what I have trying to do until now has come when I saw how other projects try to accomplish such a task. See [2] and [3].

Report #3

I have continued the work that has been started 2 weeks ago. The goal is still to build the needed dependencies to be able to compile and run the CLI version of Scilab on Android. Until now, libxml2 and pcre have been built successfuly. During the last couple of weeks, I have recompiled GCC of Android NDK to enable the support of Fortran. It needs a lot of hack and times to accomplish this. It needs a clean NDK, the GCC sources and other libraries such as binutils, mpfr, gmp, expat, mpc and gdb. After that, the NDK needs to be patched to build GCC with the support of Fortran.

I have started to write a script [1] to automate everything. The script is used to setup the Android toolchain, to download tarballs and to build the libraries. It is possible to enable or disable the build of each library.

With the support of Fortran enabled, it is now possible to compile BLAS and Lapack. So it remains gettext and readline. The gettext library fails to build because of problems with some headers files such as time.h and stdio.h. They look like to miss some functions like gets for stdio.h.

Final Report

http://www.google-melange.com/gsoc/project/google/gsoc2012/gmazoyer/35002

Although the project has not resulted in a final version of Scilab under Android, the work of Guillaume has set a number of critical issues, and lays the required initial groundwork for this future version. We are looking for volunteers to complete the work.


2022-09-08 09:26