diff options
author | Tor Lillqvist <tml@iki.fi> | 2012-09-24 10:38:43 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2012-10-11 10:07:05 +0300 |
commit | 4b7e701024219be48b7f8154a508c79cb0a6fdc1 (patch) | |
tree | 4642c4c47de58d99fd027eac0d595c6c747baa24 /android | |
parent | b62bead21d0c956a7da239931069b7e972bfbaf1 (diff) |
Use DISABLE_DYNLOADING on Android
IN this branch these changes are not conditional. Unclear yet whether
this is what we finally will want to use or not. Maybe should make
these changes conditional and do this stuff in master instead?
Change-Id: I379d570a0e00648d295c675fd90eba6594ba3182
Diffstat (limited to 'android')
4 files changed, 213 insertions, 148 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java index b97adfb6261a..2c8d2e7b31d1 100644 --- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java +++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java @@ -62,21 +62,9 @@ public class Bootstrap extends NativeActivity String apkFile, String[] ld_library_path); - public static native boolean setup(int lo_main_ptr, - Object lo_main_argument, + public static native boolean setup(Object lo_main_argument, int lo_main_delay); - // This is not just a wrapper for the C library dlopen(), but also - // loads recursively dependent libraries. - public static native int dlopen(String library); - - // This is just a wrapper for the C library dlsym(). - public static native int dlsym(int handle, String symbol); - - // To be called after you are sure libgnustl_shared.so - // has been loaded - static native void patch_libgnustl_shared(); - // Extracts files in the .apk that need to be extraced into the app's tree static native void extract_files(); @@ -148,11 +136,6 @@ public class Bootstrap extends NativeActivity if (!setup(dataDir, activity.getApplication().getPackageResourcePath(), llpa)) return; - // We build LO code against the shared GNU C++ library - dlopen("libgnustl_shared.so"); - // and need to patch it. - patch_libgnustl_shared(); - // Extract files from the .apk that can't be used mmapped directly from it extract_files(); @@ -224,35 +207,8 @@ public class Bootstrap extends NativeActivity System.arraycopy(argv, 0, newargv, 1, argv.length); argv = newargv; - // Load the LO "program" here and look up lo_main - int loLib = dlopen(mainLibrary); - - if (loLib == 0) { - Log.i(TAG, String.format("Error: could not load %s", mainLibrary)); - mainLibrary = "libmergedlo.so"; - loLib = dlopen(mainLibrary); - if (loLib == 0) { - Log.i(TAG, String.format("Error: could not load fallback %s", mainLibrary)); - return; - } - } - - int lo_main = dlsym(loLib, "lo_main"); - if (lo_main == 0) { - Log.i(TAG, String.format("No lo_main in %s", mainLibrary)); - return; - } - - // Get extra libraries to load early, so that it's easier to debug - // them even with a buggy ndk-gdb that doesn't grok debugging - // information from libraries loaded after it has been attached to the - // process. - String extraLibs = getIntent().getStringExtra("lo-extra-libs"); - if (extraLibs != null) { - for (String lib : extraLibs.split(":")) { - dlopen(lib); - } - } + // Load the LO "program" here + System.loadLibrary(mainLibrary); // Start a strace on ourself if requested. @@ -272,7 +228,7 @@ public class Bootstrap extends NativeActivity delay = Integer.parseInt(sdelay); // Tell lo-bootstrap.c the stuff it needs to know - if (!setup(lo_main, argv, delay)) + if (!setup(argv, delay)) return; // Finally, call our super-class, NativeActivity's onCreate(), @@ -286,14 +242,12 @@ public class Bootstrap extends NativeActivity super.onCreate(savedInstanceState); } - // This is used to load the 'lo-bootstrap' library on application - // startup. The library has already been unpacked into - // /data/data/<app name>/lib/liblo-bootstrap.so at installation - // time by the package manager. + // Now with static loading we always have all native code in one native + // library which we always call liblo-native-code.so, regardless of the + // app. The library has already been unpacked into /data/data/<app + // name>/lib at installation time by the package manager. static { - System.loadLibrary("lo-bootstrap"); - System.loadLibrary("gnustl_shared"); - System.loadLibrary("libotouchlo"); + System.loadLibrary("lo-native-code"); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/experimental/DocumentLoader/Makefile b/android/experimental/DocumentLoader/Makefile index d4504092830c..a357e6b0b022 100644 --- a/android/experimental/DocumentLoader/Makefile +++ b/android/experimental/DocumentLoader/Makefile @@ -19,15 +19,154 @@ APP_DATA_PATH=/data/data/$(APP_PACKAGE) SODEST=libs/$(ANDROID_APP_ABI) OBJLOCAL=obj/local/$(ANDROID_APP_ABI) -define COPYSO -cp $(1) $(SODEST)$(if $(2),/$(2)) && $(STRIP) --strip-debug $(SODEST)$(if $(2),/$(2),/$(notdir $(1))) && \ -cp $(1) $(OBJLOCAL)$(if $(2),/$(2)) -endef - define COPYJAR cp $(1) libs endef +LIBS = \ + -Wl,--start-group \ + $(addprefix -l,$(strip \ + ascii_expat_xmlparse \ + avmedialo \ + basebmp \ + basegfxlo \ + bootstrap.uno \ + canvastoolslo \ + collator_data \ + comphelpgcc3 \ + configmgr.uno \ + cppcanvaslo \ + crypto \ + dbaxmllo \ + dbtoolslo \ + deploymentmisclo \ + dict_ja \ + dict_zh \ + drawinglayerlo \ + editenglo \ + expat_xmlparse \ + expat_xmltok \ + expwrap.uno \ + fastsax.uno \ + filterconfiglo \ + fontconfig \ + forlo \ + foruilo \ + freetype \ + frmlo \ + fsstorage.uno \ + fwelo \ + fwilo \ + fwklo \ + gcc3_uno \ + hwplo \ + i18nisolang1gcc3 \ + i18npool.uno \ + i18nregexplo \ + i18nsearch.uno \ + i18nutilgcc3 \ + icudata \ + icui18n \ + icule \ + icutu \ + icuuc \ + index_data \ + introspection.uno \ + java_uno \ + jpeg \ + jvmaccessgcc3 \ + jvmfwk \ + lcms2 \ + libotouchlo \ + lnglo \ + lo-bootstrap \ + localedata_en \ + localedata_es \ + localedata_euro \ + localedata_others \ + loglo \ + log_uno_uno \ + lpsolve55 \ + lwpftlo \ + msfilterlo \ + mswordlo \ + ooxlo \ + orcus \ + package2 \ + reflection.uno \ + reg \ + saxlo \ + sax_shared \ + sblo \ + sclo \ + scdlo \ + scfiltlo \ + sddlo \ + sdfiltlo \ + sdlo \ + sfxlo \ + smdlo \ + smlo \ + sotlo \ + spllo \ + stocservices.uno \ + store \ + svgfilterlo \ + svllo \ + svtlo \ + svxcorelo \ + svxlo \ + swdlo \ + swlo \ + t602filterlo \ + textconv_dict \ + textconversiondlgslo \ + textfdlo \ + textinstream.uno \ + textoutstream.uno \ + tklo \ + tllo \ + ucb1 \ + ucbhelper4gcc3 \ + ucpfile1 \ + ucppkg1 \ + uno_cppu \ + uno_cppuhelpergcc3 \ + uno_sal \ + uno_salhelpergcc3 \ + uno_cppuhelpergcc3 \ + unordflo \ + unoxmllo \ + utllo \ + uuilo \ + vbahelperlo \ + vbaswobj.uno \ + vcllo \ + wpftdrawlo \ + wpftwriterlo \ + xml2 \ + xmlfalo \ + xmlfdlo \ + xmlreader \ + xmlscriptlo \ + xmlsecurity \ + xoflo \ + xolo \ + xsec_fw \ + xslt \ + xsltdlglo \ + xsltfilterlo \ + xstor \ + )) \ + -Wl,--end-group + +WHOLELIBS = \ + -Wl,--whole-archive \ + $(addprefix -l,$(strip \ + juh \ + )) \ + -Wl,--no-whole-archive + # The default target just builds. all: build-ant @@ -39,87 +178,16 @@ properties: echo "APP_ABI := $(ANDROID_APP_ABI)" >>jni/Application.mk echo "APP_PLATFORM := android-14" >>jni/Application.mk +link-so: +# Build the single .so for this app + mkdir -p $(OBJLOCAL) + $(CXX) -Wl,-Map,liblo-native-code.map -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/liblo-native-code.so -I$(OUTDIR)/inc native-code.cxx -L$(OUTDIR)/lib $(WHOLELIBS) $(LIBS) -lgnustl_static -landroid -llog -lz + mkdir -p $(SODEST) + cp $(OBJLOCAL)/liblo-native-code.so $(SODEST) + $(STRIP) --strip-debug $(SODEST)/liblo-native-code.so + copy-stuff: -# First always clean - rm -rf libs $(OBJLOCAL) - mkdir -p $(SODEST) $(OBJLOCAL) -# -# Copy shared libraries (including UNO components) we need to -# libs/$(ANDROID_APP_ABI) so that ant will include them in the .apk. -# -# Copy them to obj/local/$(ANDROID_APP_ABI), too, where gdb will look for -# them. -# - for F in $(strip \ - basegfxlo \ - bootstrap.uno \ - comphelpgcc3 \ - dbaxmllo \ - dbtoolslo \ - expwrap.uno \ - frmlo \ - gcc3_uno \ - i18nisolang1gcc3 \ - icudatalo \ - icui18nlo \ - iculelo \ - icuuclo \ - introspection.uno \ - java_uno \ - juh \ - juhx \ - jvmaccessgcc3 \ - jvmfwk \ - libotouchlo \ - lo-bootstrap \ - localedata_en \ - localedata_others \ - lwpftlo \ - mergedlo \ - msfilterlo \ - mswordlo \ - ooxlo \ - reflection.uno \ - reg \ - sclo \ - scdlo \ - scfiltlo \ - sddlo \ - smdlo \ - stocservices.uno \ - store \ - svgfilterlo \ - swdlo \ - swlo \ - t602filterlo \ - textinstream.uno \ - tllo \ - ucbhelper4gcc3 \ - ucppkg1 \ - uno_cppu \ - uno_cppuhelpergcc3 \ - uno_sal \ - uno_salhelpergcc3 \ - uno_cppuhelpergcc3 \ - unordflo \ - unoxmllo \ - vbahelperlo \ - vbaswobj.uno \ - wpftdrawlo \ - wpftwriterlo \ - xml2 \ - xmlfdlo \ - xmlreader \ - xmlsecurity \ - xslt \ - ); do \ - $(call COPYSO,$(OUTDIR)/lib/lib$${F}.so); \ - done -# -# Then the shared GNU C++ library - $(call COPYSO,$(ANDROID_NDK_HOME)/sources/cxx-stl/gnu-libstdc++/$(ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR)libs/$(ANDROID_APP_ABI)/libgnustl_shared.so) -# -# Then other "assets". Let the directory structure under assets mimic +# Then "assets". Let the directory structure under assets mimic # that under solver for now. # # Please note that I have no idea what all of this is really necessary and for @@ -216,10 +284,11 @@ copy-stuff: # # Then gdbserver and gdb.setup so that we can debug with ndk-gdb. # + mkdir -p $(SODEST) cp $(ANDROID_NDK_GDBSERVER) $(SODEST) echo set solib-search-path ./obj/local/$(ANDROID_APP_ABI) >$(SODEST)/gdb.setup -build-ant: copy-stuff properties +build-ant: copy-stuff link-so properties # # Copy jar files we need # diff --git a/android/experimental/DocumentLoader/native-code.cxx b/android/experimental/DocumentLoader/native-code.cxx new file mode 100644 index 000000000000..415c6737ff26 --- /dev/null +++ b/android/experimental/DocumentLoader/native-code.cxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "osl/detail/android-bootstrap.h" + +extern "C" +{ + extern void * hwp_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * sc_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * scd_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * scfilt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * sw_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * swd_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * unoxml_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * xmlfd_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * xo_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); + extern void * xof_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); +} + +extern "C" +__attribute__ ((visibility("default"))) +const lib_to_component_mapping * +lo_get_libmap(void) +{ + static lib_to_component_mapping map[] = { + { "libhwplo.a", hwp_component_getFactory }, + { "libscdlo.a", scd_component_getFactory }, + { "libscfiltlo.a", scfilt_component_getFactory }, + { "libsclo.a", sc_component_getFactory }, + { "libswdlo.a", swd_component_getFactory }, + { "libswlo.a", sw_component_getFactory }, + { "libunoxmllo.a", unoxml_component_getFactory }, + { "libxmlfdlo.a", xmlfd_component_getFactory }, + { "libxoflo.a", xof_component_getFactory }, + { "libxolo.a", xo_component_getFactory }, + { NULL, NULL } + }; + + return map; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java index 638c9b950a05..894fdab502a5 100644 --- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java +++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -929,13 +929,7 @@ public class DocumentLoader Bootstrap.setup(this); // Avoid all the old style OSL_TRACE calls especially in vcl - Bootstrap.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl"); - - // Load a lot of shlibs here explicitly in advance because that - // makes debugging work better, sigh - Bootstrap.dlopen("libmergedlo.so"); - Bootstrap.dlopen("libswdlo.so"); - Bootstrap.dlopen("libswlo.so"); + Bootstrap.putenv("SAL_LOG=+WARN+INFO"); // Log.i(TAG, "Sleeping NOW"); // Thread.sleep(20000); |