More android + picolisp fun, this time with the full picolisp.  Using the 
android SDK and NDK, I hacked a picolisp/src/makefile to work for android's arm 
processor like this: 

----------- makefile -----------

CFLAGS := -c -O2  -pipe \
        -falign-functions=64 -fomit-frame-pointer -fno-strict-aliasing \
        -W -Wimplicit -Wreturn-type -Wunused -Wformat \
        -Wuninitialized -Wstrict-prototypes \
# ?? had: -m32

NDK_ROOT = ~/android/android-ndk-r7
SYS_ROOT = $(NDK_ROOT)/platforms/android-8/arch-arm/
CC = $(NDK_BIN)/arm-linux-androideabi-gcc --sysroot=$(SYS_ROOT)
LD = $(NDK_BIN)/arm-linux-androideabi-ld
AR = $(NDK_BIN)/arm-linux-androideabi-ar
RANLIB = $(NDK_BIN)/arm-linux-androideabi-ranlib
STRIP = $(NDK_BIN)/arm-linux-androideabi-strip

        OS = Arm
        PICOLISP-FLAGS = -m32 -rdynamic
        LIB-FLAGS = -lc -lm -ldl
        DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic


Then (to my surprise) picolisp and dynamic libraries were made,

# file ../bin/picolisp  ../lib/ext  ../lib/ht ../lib/z3d  
../bin/picolisp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically 
linked (uses shared libs), stripped
../lib/ext:      ELF 32-bit LSB shared object, ARM, version 1 (SYSV), stripped
../lib/ht:       ELF 32-bit LSB shared object, ARM, version 1 (SYSV), stripped
../lib/z3d:      ELF 32-bit LSB shared object, ARM, version 1 (SYSV), stripped

So far so good...

Using this android approach generally,

I placed the picolisp executable in the assets dir and at run-time, copy it 
from assets to /data/data/ in the right place for that app.   

Since I'm using the emulator and I know where the executable was placed, I can 
run it using adb, for some command-line tests:

# adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println "X")'  '-foo 
123' -bye 

# adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (* "X" 2))'  
'-foo 123' -bye 

# adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (* "X" 2))'  
'-foo 12345' -bye 

A bit cumbersome having to unpack the executable and other files from the app's 
.apk (zip archive) to run it ... but it can be done.  And no fiddling with bits 
... no changes to the (full picolisp) source at all.   

Next step is to try to similarly unpack all the libraries and see if a picolisp 
database server application can be run. Then more testing.  And use that with 
android's browser, all within an android app. 

But I'm very confident that the full picolisp will run on the android from what 
I see so far! 

There are ways to call java from C also, so that opens up possibilities of 
using android java libraries from android picolisp too. 




Reply via email to