office-gobmx/android/experiments/DocumentLoader/Makefile
Tor Lillqvist 5510127e89 Android code refactorig and hacking
Sorry for the large unstructured commit. But hey, the Android code is
experimental so far.

Extract the native lo-bootstrap code into a fairly normal library
built in sal. (Previously it was the JNI part of the "Bootstrap" app.)
Just linkink normally to liblo-bootstrap from C++ code that uses it
works fine, no need to do a dlsym lookup.

Bootstrap is still a subclass of NativeActivity and can thus still be
used as an "app" (to start unit tests, or whatever), but can also be
used from some other app's Java code to just get access to the
lo-bootstrap native methods.

Introduce a new top-level "module", android, for Bootstrap and the
experiments with DocumentLoader.

Note that the experimental DocumentLoader app still crashes. It can't
create the com.sun.star.frame.Desktop instance.

I spent lots of time debugging in the painfully inadequate
ndk-gdb. (Even the newer gdb build from the "mingw-and-ndk" project is
quite crappy in many ways.) I should really experiment with
corresponding code on a normal platform first before even trying on
Android. Basically, I think that if I just can get the concept of Java
code that instantiates and uses LO components *in-process* working on
a normal desktop platform, it should work on Android, too.
2011-11-30 21:52:52 +02:00

120 lines
3 KiB
Makefile

NDK_HOME:=$(shell type -p ndk-build)
NDK_HOME:=$(shell dirname $(NDK_HOME))
SODEST=libs/armeabi-v7a
OBJLOCAL=obj/local/armeabi-v7a
define COPYSO
cp $(1) $(SODEST)$(if $(2),/$(2)) && \
arm-linux-androideabi-strip --strip-debug $(SODEST)$(if $(2),/$(2),/$(notdir $(1))) && \
cp $(1) $(OBJLOCAL)$(if $(2),/$(2))
endef
define COPYJAR
cp $(1) libs
endef
# The default target just builds.
all: build-ant
copy-stuff:
# First always clean
rm -rf libs $(OBJLOCAL)
mkdir -p $(SODEST) $(OBJLOCAL)
#
# Copy jar files we need, and even construct one.
#
for F in $(strip \
java_uno \
juh \
jurt \
ridl \
unoloader \
); do \
$(call COPYJAR,$(OUTDIR)/bin/$${F}.jar); \
done
#
# lo-bootstrap.jar from ../../Bootstrap
#
cp ../../Bootstrap/lo-bootstrap.jar libs
#
# com.sun.star.frame.XComponentLoader is not in any jar
#
cd libs && \
LD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
DYLD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
$(OUTDIR_FOR_BUILD)/bin/javamaker -BUCR -nD \
$(OUTDIR)/bin/udkapi.rdb $(OUTDIR)/bin/offapi.rdb \
-Tcom.sun.star.frame.XComponentLoader && \
jar cvf more.jar com
#
# Copy shared libraries (including UNO components) we need to
# libs/armeabi-v7a so that ant will include them in the .apk.
#
# Copy them to obj/local/armeabi-v7a, too, where gdb will look for
# them.
#
for F in $(strip \
comphelpgcc3 \
gcc3_uno \
i18nisolang1gcc3 \
i18nutilgcc3 \
icudatalo \
icui18nlo \
icuuclo \
java_uno \
juh \
juhx \
jvmaccessgcc3 \
lo-bootstrap \
localedata_en \
localedata_others \
reg \
sal_textenc \
store \
ucbhelper4gcc3 \
uno_cppu \
uno_sal \
uno_salhelpergcc3 \
uno_cppuhelpergcc3 \
xml2 \
xmlreader \
bootstrap.uno \
i18npool.uno \
); do \
$(call COPYSO,$(OUTDIR)/lib/lib$${F}.so); \
done
#
# Then the shared GNU C++ library
$(call COPYSO,$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libgnustl_shared.so)
#
# Then other "assets". Let the directory structure under assets mimic
# that under solver for now.
mkdir -p assets/bin assets/lib assets/xml/ure assets/ComponentTarget/i18npool/util
cp $(OUTDIR)/bin/udkapi.rdb assets/bin
cp $(OUTDIR)/bin/types.rdb assets/bin
cp $(OUTDIR)/bin/uno.ini assets
cp $(OUTDIR)/xml/ure/services.rdb assets/xml/ure
cp $(SRC_ROOT)/odk/examples/java/DocumentHandling/test/test1.odt assets
cp $(WORKDIR)/ComponentTarget/i18npool/util/i18npool.component assets/ComponentTarget/i18npool/util
#
# Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
#
cp $(NDK_HOME)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver $(SODEST)
echo set solib-search-path ./obj/local/armeabi-v7a >$(SODEST)/gdb.setup
build-ant: copy-stuff
unset JAVA_HOME && ant debug
install: copy-stuff
unset JAVA_HOME && ant debug install
@echo
@echo 'Run it with something like what "make run" does (see Makefile)'
@echo
run: install
adb shell am start -n org.libreoffice.android.examples/.DocumentLoader -e input /assets/test1.odt
clean:
rm -rf bin assets