Kaydet (Commit) 4b7e7010 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst b62bead2
......@@ -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: */
......@@ -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
#
......
/* -*- 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: */
......@@ -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);
......
......@@ -2422,8 +2422,8 @@ else
fi
AC_SUBST(DISABLE_SCRIPTING)
if test $_os = iOS; then
# Disable dynamic_loading always for iOS
if test $_os = iOS -o $_os = Android; then
# Disable dynamic_loading always for iOS and Android
enable_dynamic_loading=no
elif test -z "$enable_dynamic_loading"; then
# Otherwise enable it unless speficically disabled
......
......@@ -17,7 +17,6 @@
--disable-randr
--disable-randr-link
--disable-systray
--enable-mergelibs
--without-junit
--without-ppds
--without-stlport
......
......@@ -18,7 +18,6 @@
--disable-randr
--disable-randr-link
--disable-systray
--enable-mergelibs
--without-junit
--without-ppds
--without-stlport
......
......@@ -67,6 +67,7 @@ $(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/file.h,osl/detail/file.
$(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/android_native_app_glue.h,osl/detail/android_native_app_glue.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/android-bootstrap.h,osl/detail/android-bootstrap.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/ios-bootstrap.h,osl/detail/ios-bootstrap.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/component-mapping.h,osl/detail/component-mapping.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/rtl/allocator.hxx,rtl/allocator.hxx))
$(eval $(call gb_Package_add_file,sal_inc,inc/rtl/alloc.h,rtl/alloc.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/rtl/bootstrap.h,rtl/bootstrap.h))
......
This diff is collapsed.
......@@ -29,29 +29,19 @@
#ifndef ANDROID_BOOSTRAP_H
#define ANDROID_BOOSTRAP_H
#if defined(ANDROID)
#include <jni.h>
#include <dlfcn.h>
#include <dirent.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct lo_apk_dir lo_apk_dir;
char **lo_dlneeds(const char *library);
void *lo_dlopen(const char *library);
#include <osl/detail/component-mapping.h>
void *lo_dlsym(void *handle,
const char *symbol);
int lo_dladdr(void *addr,
Dl_info *info);
int lo_dlclose(void *handle);
typedef struct lo_apk_dir lo_apk_dir;
void *lo_apkentry(const char *filename,
size_t *size);
......@@ -77,6 +67,7 @@ struct android_app *lo_get_app(void);
#endif
#endif // ANDROID
#endif // ANDROID_BOOTSTRAP_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http: *www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2011 Tor Lillqvist <tml@iki.fi> (initial developer)
* Copyright (C) 2011 SUSE Linux http://suse.com (initial developer's employer)
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef COMPONENT_MAPPING_H
#define COMPONENT_MAPPING_H
#ifdef DISABLE_DYNLOADING
#ifdef __cplusplus
extern "C" {
#endif
/* On iOS and perhaps Android static linking of the LO code into one
* executable (on Android, into one shared library) is used. In order to get
* the needed UNO coponent linked in, the "main" code for an app needs to
* implement the lo_get_libmap() function to map UNO component library names
* as produced in a build for iOS (like configmgr.uno.a or libsclo.a) to the
* corresponding component_getFactory functions.
*/
typedef struct {
const char *lib;
void * (*component_getFactory_function)(const char *, void *, void *);
} lib_to_component_mapping;
const lib_to_component_mapping *lo_get_libmap(void);
#ifdef __cplusplus
}
#endif
#endif /* DISABLE_DYNLOADING */
#endif /* COMPONENT_MAPPING_H */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -36,19 +36,7 @@
extern "C" {
#endif
/* On iOS static linking is used. In order to get the needed UNO
* coponent linked in, the "main" code for an app needs to implement
* the lo_get_libmap() function to map UNO component library names as
* produced in a build for iOS (like configmgr.uno.a or libsclo.a) to
* the corresponding component_getFactory functions.
*/
typedef struct {
const char *lib;
void * (*component_getFactory_function)(const char *, void *, void *);
} lib_to_component_mapping;
const lib_to_component_mapping *lo_get_libmap(void);
#include <osl/detail/component-mapping.h>
#ifdef __cplusplus
}
......
......@@ -76,3 +76,5 @@ LINKFLAGSRUNPATH_URELIB=
LINKFLAGSRUNPATH_UREBIN=
LINKFLAGSRUNPATH_OOO=
LINKFLAGSRUNPATH_SDKBIN=
DLLPOST=.a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment