diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-19 15:32:54 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-20 13:00:24 +0100 |
commit | a17c0950c04693411cc7e46a21c65d45216d8c52 (patch) | |
tree | e2fb876605ea219ef0177126be7fc564821b845e | |
parent | 57a80a49ce3726a096a26f49a8e0b7c4f689da54 (diff) |
Add tool to generate native-code.cxx for Android.
Should be extended to be helpfull for iOS too.
Change-Id: I862731b6386d5f9cbb508e0c138f45fbe1cb3f46
-rw-r--r-- | android/.gitignore | 3 | ||||
-rw-r--r-- | android/experimental/DocumentLoader/Makefile | 6 | ||||
-rw-r--r-- | android/experimental/DocumentLoader/native-code.cxx | 45 | ||||
-rw-r--r-- | android/experimental/LibreOffice4Android/Makefile | 5 | ||||
-rw-r--r-- | android/experimental/LibreOffice4Android/native-code.cxx | 51 | ||||
-rw-r--r-- | android/experimental/desktop/Makefile | 6 | ||||
-rw-r--r-- | android/experimental/desktop/native-code.cxx | 64 | ||||
-rwxr-xr-x | solenv/bin/native-code.py | 85 |
8 files changed, 104 insertions, 161 deletions
diff --git a/android/.gitignore b/android/.gitignore index 9034b9895557..dca2c57fff27 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -3,4 +3,5 @@ bin gen libs obj -local.properties
\ No newline at end of file +local.properties +native-code.cxx diff --git a/android/experimental/DocumentLoader/Makefile b/android/experimental/DocumentLoader/Makefile index 49b28959fa7d..5295c8086bcd 100644 --- a/android/experimental/DocumentLoader/Makefile +++ b/android/experimental/DocumentLoader/Makefile @@ -11,6 +11,12 @@ APP_PACKAGE=org.libreoffice.android.examples BOOTSTRAPDIR=../../Bootstrap include $(BOOTSTRAPDIR)/Makefile.shared +native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py + $< \ + -f EXTENDED_CORE -f BASE_CORE -f CALC_CORE -f DRAW_CORE -f MATH -f WRITER \ + -s protocolhandler -s sb \ + > $@ + copy-stuff: # Then "assets". Let the directory structure under assets mimic # that under solver for now. diff --git a/android/experimental/DocumentLoader/native-code.cxx b/android/experimental/DocumentLoader/native-code.cxx deleted file mode 100644 index 7cba3773f5e8..000000000000 --- a/android/experimental/DocumentLoader/native-code.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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" -__attribute__ ((visibility("default"))) -const lib_to_factory_mapping * -lo_get_factory_map(void) -{ - static lib_to_factory_mapping map[] = { - LO_EXTENDED_CORE_FACTORY_MAP - LO_BASE_CORE_FACTORY_MAP - LO_CALC_CORE_FACTORY_MAP - LO_DRAW_CORE_FACTORY_MAP - LO_MATH_FACTORY_MAP - LO_WRITER_FACTORY_MAP - { "libprotocolhandlerlo.a", protocolhandler_component_getFactory }, - { "libsblo.a", sb_component_getFactory }, - { NULL, NULL } - }; - - return map; -} - -extern "C" -__attribute__ ((visibility("default"))) -const lib_to_constructor_mapping * -lo_get_constructor_map(void) -{ - static lib_to_constructor_mapping map[] = { - NON_APP_SPECIFIC_CONSTRUCTOR_MAP - { NULL, NULL } - }; - - return map; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/experimental/LibreOffice4Android/Makefile b/android/experimental/LibreOffice4Android/Makefile index 9f8dccea0857..92f0668b906e 100644 --- a/android/experimental/LibreOffice4Android/Makefile +++ b/android/experimental/LibreOffice4Android/Makefile @@ -12,6 +12,11 @@ APP_PACKAGE=org.libreoffice BOOTSTRAPDIR=../../Bootstrap include $(BOOTSTRAPDIR)/Makefile.shared +native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py + $< -f EXTENDED_CORE -f BASE_CORE -f CALC_CORE -f DRAW_CORE -f MATH -f WRITER \ + -s dlgprov -s protocolhandler -s scriptframe -s sb -s stringresource -s vbaswobj -s vbaevents \ + > $@ + copy-stuff: # Then "assets". Let the directory structure under assets mimic # that under solver for now. diff --git a/android/experimental/LibreOffice4Android/native-code.cxx b/android/experimental/LibreOffice4Android/native-code.cxx deleted file mode 100644 index 44cb862da480..000000000000 --- a/android/experimental/LibreOffice4Android/native-code.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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" -__attribute__ ((visibility("default"))) -const lib_to_factory_mapping * -lo_get_factory_map(void) -{ - static lib_to_factory_mapping map[] = { - LO_EXTENDED_CORE_FACTORY_MAP - LO_BASE_CORE_FACTORY_MAP - LO_CALC_CORE_FACTORY_MAP - LO_DRAW_CORE_FACTORY_MAP - LO_MATH_FACTORY_MAP - LO_WRITER_FACTORY_MAP - { "libdlgprovlo.a", dlgprov_component_getFactory }, - { "libprotocolhandlerlo.a", protocolhandler_component_getFactory }, - { "libscriptframe.a", scriptframe_component_getFactory }, - { "libsblo.a", sb_component_getFactory }, - { "libscriptframe.a", scriptframe_component_getFactory }, - { "libstringresource.uno.a", stringresource_component_getFactory }, - { "libvbaswobj.uno.a", vbaswobj_component_getFactory }, - { "libvbaevents.uno.a", vbaevents_component_getFactory }, - { NULL, NULL } - }; - - return map; -} - -extern "C" -__attribute__ ((visibility("default"))) -const lib_to_constructor_mapping * -lo_get_constructor_map(void) -{ - static lib_to_constructor_mapping map[] = { - NON_APP_SPECIFIC_CONSTRUCTOR_MAP - { NULL, NULL } - }; - - return map; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/experimental/desktop/Makefile b/android/experimental/desktop/Makefile index 145a9fbebe2f..610bf874e1f8 100644 --- a/android/experimental/desktop/Makefile +++ b/android/experimental/desktop/Makefile @@ -11,6 +11,12 @@ APP_PACKAGE=org.libreoffice.experimental.desktop BOOTSTRAPDIR=../../Bootstrap include $(BOOTSTRAPDIR)/Makefile.shared +native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py + $< -j \ + -f EXTENDED_CORE -f BASE_CORE -f CALC_CORE -f DRAW_CORE -f MATH -f WRITER \ + -s basprov -s dlgprov -s cui -s protocolhandler -s scriptframe -s sb -s spl -s stringresource -s uui -s vbaswobj -s vbaevents \ + > $@ + # The name of the Bootstrap activity class BOOTSTRAP=org.libreoffice.android.Bootstrap diff --git a/android/experimental/desktop/native-code.cxx b/android/experimental/desktop/native-code.cxx deleted file mode 100644 index 6b8deab7d4c6..000000000000 --- a/android/experimental/desktop/native-code.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- 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" -__attribute__ ((visibility("default"))) -const lib_to_factory_mapping * -lo_get_factory_map(void) -{ - static lib_to_factory_mapping map[] = { - LO_EXTENDED_CORE_FACTORY_MAP - LO_BASE_CORE_FACTORY_MAP - LO_CALC_CORE_FACTORY_MAP - LO_DRAW_CORE_FACTORY_MAP - LO_MATH_FACTORY_MAP - LO_WRITER_FACTORY_MAP - { "libbasprovlo.a", basprov_component_getFactory }, - { "libdlgprovlo.a", dlgprov_component_getFactory }, - { "libcuilo.a", cui_component_getFactory }, - { "libprotocolhandlerlo.a", protocolhandler_component_getFactory }, - { "libscriptframe.a", scriptframe_component_getFactory }, - { "libsblo.a", sb_component_getFactory }, - { "libspllo.a", spl_component_getFactory }, - { "libscriptframe.a", scriptframe_component_getFactory }, - { "libstringresourcelo.a", stringresource_component_getFactory }, - { "libuuilo.a", uui_component_getFactory }, - { "libvbaswobjlo.a", vbaswobj_component_getFactory }, - { "libvbaeventslo.a", vbaevents_component_getFactory }, - { NULL, NULL } - }; - - // Guard against possible function-level link-time pruning of - // "unused" code. We need to pull these in, too, as they aren't in - // any of the libs we link with -Wl,--whole-archive. Is this necessary? - extern void Java_org_libreoffice_android_AppSupport_runMain(); - volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain; - - extern void Java_org_libreoffice_android_AppSupport_renderVCL(); - p = (void *) Java_org_libreoffice_android_AppSupport_renderVCL; - - return map; -} - -extern "C" -__attribute__ ((visibility("default"))) -const lib_to_constructor_mapping * -lo_get_constructor_map(void) -{ - static lib_to_constructor_mapping map[] = { - NON_APP_SPECIFIC_CONSTRUCTOR_MAP - { NULL, NULL } - }; - - return map; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py new file mode 100755 index 000000000000..99cefb8050af --- /dev/null +++ b/solenv/bin/native-code.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# 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/. + +from __future__ import print_function +from optparse import OptionParser + +single_component_map = { + 'basprov' : '{ "libbasprovlo.a", basprov_component_getFactory },', + 'cui' : '{ "libcuilo.a", cui_component_getFactory },', + 'dlgprov' : '{ "libdlgprovlo.a", dlgprov_component_getFactory },', + 'protocolhandler' : '{ "libprotocolhandlerlo.a", protocolhandler_component_getFactory },', + 'scriptframe' : '{ "libscriptframe.a", scriptframe_component_getFactory },', + 'sb' : '{ "libsblo.a", sb_component_getFactory },', + 'spl' : '{ "libspllo.a", spl_component_getFactory },', + 'stringresource' :'{ "libstringresourcelo.a", stringresource_component_getFactory },', + 'uui' : '{ "libuuilo.a", uui_component_getFactory },', + 'vbaswobj' : '{ "libvbaswobjlo.a", vbaswobj_component_getFactory },', + 'vbaevents' :'{ "libvbaeventslo.a", vbaevents_component_getFactory },'} + +opts = OptionParser() +opts.add_option("-j", "--java-guard", action="store_true", help="include external java functions", dest="java", default=False) +opts.add_option("-f", "--factory", action="append", help="list of factory groups to get into lib_to_factory_mapping", dest="factories") +opts.add_option("-s", "--single-component", action="append", help="list of single getFactories to get into lib_to_factory_mapping", dest="components") +opts.add_option("-c", "--constructor", action="append", help="list of constructor groups to get into lib_to_constructor_mapping", dest="constructors") + +(options, args) = opts.parse_args() + +print ("""#include "osl/detail/android-bootstrap.h" + +extern "C" +__attribute__ ((visibility("default"))) +const lib_to_factory_mapping * +lo_get_factory_map(void) +{ + static lib_to_factory_mapping map[] = {""") + +if options.factories: + for f in options.factories: + print (' LO_' + f + '_FACTORY_MAP') + +if options.components: + for c in options.components: + print (' ' + single_component_map[c]) + +print (""" + { NULL, NULL } + };""") + +if options.java: + print (""" + // Guard against possible function-level link-time pruning of + // "unused" code. We need to pull these in, too, as they aren't in + // any of the libs we link with -Wl,--whole-archive. Is this necessary? + extern void Java_org_libreoffice_android_AppSupport_runMain(); + volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain; + + extern void Java_org_libreoffice_android_AppSupport_renderVCL(); + p = (void *) Java_org_libreoffice_android_AppSupport_renderVCL;""") + +print (""" + return map; +} + +extern "C" +__attribute__ ((visibility("default"))) +const lib_to_constructor_mapping * +lo_get_constructor_map(void) +{ + static lib_to_constructor_mapping map[] = { + NON_APP_SPECIFIC_CONSTRUCTOR_MAP""") + +if options.constructors: + for c in options.constructors: + print (c) + +print (""" + { NULL, NULL } + }; + + return map; +}""") |