solenv/bin/native-code.py | 125 +++++++++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 39 deletions(-)
New commits: commit 9c5f1a4b5766e221c9c891e26aefc8a3d1670415 Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Jan 27 10:51:57 2015 +0100 native-code.py: When filtering the services.rdb, keep also the factories. Change-Id: I663e82322a05b7b6f140cb9adecbe1465f320f95 diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 8afb2ce..41796fb 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -8,6 +8,7 @@ from __future__ import print_function from optparse import OptionParser +import re import sys import xml.etree.ElementTree as ET @@ -195,11 +196,26 @@ def limit_rdb(services_rdb, full_factory_map, full_constructor_map): root = tree.getroot() for component in root.findall('{http://openoffice.org/2010/uno-components}component'): + # direct + uri = component.get('uri') + component_name = None + if uri != None: + component_name = re.sub('^vnd.sun.star.expand:\$LO_LIB_DIR/([^.]*).so$', '\\1.a', uri) + if component_name in full_factory_map: + continue + + # via a constructor - limit only to those we have + has_constructor = False for implementation in component.findall('{http://openoffice.org/2010/uno-components}implementation'): constructor = implementation.get('constructor') - if constructor != None and constructor not in full_constructor_map: + if constructor in full_constructor_map: + has_constructor = True + else: component.remove(implementation) + if not has_constructor: + root.remove(component) + tree.write(services_rdb[0] + '.out', xml_declaration = True, method = 'xml') commit 30624664488365a54e9021b404afcf9b6293233e Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Jan 27 09:51:47 2015 +0100 native-code.py: Share more code around the factories too. Change-Id: Iff0909ee110058cd3e351e4a96738d5b8e6ba62e diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 2f58a8e..8afb2ce 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -189,7 +189,7 @@ constructor_map = { # instead of outputting native-code.cxx, reduce the services.rdb according to # the constraints, so that we can easily emulate what services do we need to # add for a fully functional file loading / saving / ... -def limit_rdb(services_rdb, full_constructor_map): +def limit_rdb(services_rdb, full_factory_map, full_constructor_map): ET.register_namespace('','http://openoffice.org/2010/uno-components') tree = ET.parse(services_rdb[0]) root = tree.getroot() @@ -211,15 +211,27 @@ opts.add_option("-r", "--limit-rdb", action="append", help="instead of outputtin (options, args) = opts.parse_args() -# construct a list of all the contructors that we need according to -g's +# dict of all the contructors that we need according to -g's full_constructor_map = {} if options.groups: for constructor_group in options.groups: for constructor in constructor_map[constructor_group]: full_constructor_map[constructor] = True +# dict of all the factories that we need according to -g's +full_factory_map = {} +if options.groups: + for factory_group in options.groups: + for entry in factory_map[factory_group]: + factory_guard = None + if len(entry) > 2: + factory_guard = entry[2] + map_entry = { 'function': entry[1], 'guard': factory_guard } + full_factory_map[entry[0]] = map_entry + +# are we only shuffling the services.rdb? if options.services: - limit_rdb(options.services, full_constructor_map) + limit_rdb(options.services, full_factory_map, full_constructor_map) exit(0) print ("""/* @@ -232,19 +244,14 @@ print ("""/* extern "C" { """) -if options.groups: - for factory_group in options.groups: - for entry in factory_map[factory_group]: - factory_name = entry[0] - factory_function = entry[1] - factory_guard = None - if len(entry) > 2: - factory_guard = entry[2] - if factory_guard: - print (factory_guard) - print ('void * '+factory_function+'( const char* , void* , void* );') - if factory_guard: - print ('#endif') +for entry in sorted(full_factory_map.keys()): + factory_function = full_factory_map[entry]['function'] + factory_guard = full_factory_map[entry]['guard'] + if factory_guard: + print (factory_guard) + print('void * ' + factory_function + '( const char* , void* , void* );') + if factory_guard: + print ('#endif') print ('') for constructor in sorted(full_constructor_map.keys()): @@ -256,19 +263,14 @@ lo_get_factory_map(void) { static lib_to_factory_mapping map[] = {""") -if options.groups: - for factory_group in options.groups: - for entry in factory_map[factory_group]: - factory_name = entry[0] - factory_function = entry[1] - factory_guard = None - if len(entry) > 2: - factory_guard = entry[2] - if factory_guard: - print (factory_guard) - print (' { "'+factory_name+'", '+factory_function+' },') - if factory_guard: - print ('#endif') +for entry in sorted(full_factory_map.keys()): + factory_function = full_factory_map[entry]['function'] + factory_guard = full_factory_map[entry]['guard'] + if factory_guard: + print (factory_guard) + print(' { "' + entry + '", ' + factory_function + ' },') + if factory_guard: + print ('#endif') print (""" { 0, 0 } commit fa4dd49f209252d70faed615f0d0bc2be29f246f Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Jan 27 09:17:01 2015 +0100 native-code.py: Sort the constructors. Change-Id: I3b7b5a13c1384313a12ec9f11714a85be2ad1693 diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 18a9899..2f58a8e 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -247,9 +247,8 @@ if options.groups: print ('#endif') print ('') -if options.groups: - for constructor in full_constructor_map.keys(): - print ('void * '+constructor+'( void *, void * );') +for constructor in sorted(full_constructor_map.keys()): + print ('void * '+constructor+'( void *, void * );') print (""" const lib_to_factory_mapping * @@ -303,9 +302,8 @@ lo_get_constructor_map(void) { static lib_to_constructor_mapping map[] = {""") -if options.groups: - for constructor in full_constructor_map.keys(): - print (' { "' +constructor+ '", ' +constructor+ ' },') +for constructor in sorted(full_constructor_map.keys()): + print (' { "' +constructor+ '", ' +constructor+ ' },') print (""" { 0, 0 } commit f679fb9cff7542b5ee4c121ff150e277729cc975 Author: Jan Holesovsky <ke...@collabora.com> Date: Tue Jan 27 00:53:28 2015 +0100 native-code.py: Add a mode that allows filtering out services.rdb. Limit only the constructors for the moment. Limiting services.rdb will be useful for finding out what services are actually missing when loading various document types. Change-Id: Ifd6c2c0c43defac79d3eba1853347614ce7c0b46 diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index e387473..18a9899 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -8,6 +8,9 @@ from __future__ import print_function from optparse import OptionParser +import sys +import xml.etree.ElementTree as ET + # foo_component_getFactory functions are split into groups, so that you could # choose e.g. 'core' and 'writer' functionality and through factory_map, # relevant function sections will be referenced in lo_get_factory_map(). @@ -183,12 +186,42 @@ constructor_map = { 'writer' : writer_constructor_list, } +# instead of outputting native-code.cxx, reduce the services.rdb according to +# the constraints, so that we can easily emulate what services do we need to +# add for a fully functional file loading / saving / ... +def limit_rdb(services_rdb, full_constructor_map): + ET.register_namespace('','http://openoffice.org/2010/uno-components') + tree = ET.parse(services_rdb[0]) + root = tree.getroot() + + for component in root.findall('{http://openoffice.org/2010/uno-components}component'): + for implementation in component.findall('{http://openoffice.org/2010/uno-components}implementation'): + constructor = implementation.get('constructor') + if constructor != None and constructor not in full_constructor_map: + component.remove(implementation) + + tree.write(services_rdb[0] + '.out', xml_declaration = True, method = 'xml') + + +# do the actual work opts = OptionParser() opts.add_option("-j", "--java-guard", action="store_true", help="include external java functions", dest="java", default=False) opts.add_option("-g", "--group", action="append", help="group of implementations to make available in application", dest="groups") +opts.add_option("-r", "--limit-rdb", action="append", help="instead of outputting native-code.cxx, limit the services.rdb only to the services defined by the groups", dest="services") (options, args) = opts.parse_args() +# construct a list of all the contructors that we need according to -g's +full_constructor_map = {} +if options.groups: + for constructor_group in options.groups: + for constructor in constructor_map[constructor_group]: + full_constructor_map[constructor] = True + +if options.services: + limit_rdb(options.services, full_constructor_map) + exit(0) + print ("""/* * This is a generated file. Do not edit. * file generated by solenv/bin/native-code.py @@ -215,9 +248,8 @@ if options.groups: print ('') if options.groups: - for constructor_group in options.groups: - for constructor in constructor_map[constructor_group]: - print ('void * '+constructor+'( void *, void * );') + for constructor in full_constructor_map.keys(): + print ('void * '+constructor+'( void *, void * );') print (""" const lib_to_factory_mapping * @@ -272,9 +304,8 @@ lo_get_constructor_map(void) static lib_to_constructor_mapping map[] = {""") if options.groups: - for constructor_group in options.groups: - for constructor in constructor_map[constructor_group]: - print (' { "' +constructor+ '", ' +constructor+ ' },') + for constructor in full_constructor_map.keys(): + print (' { "' +constructor+ '", ' +constructor+ ' },') print (""" { 0, 0 } commit a1af08633edde32c6d7420188e77927101c864aa Author: Jan Holesovsky <ke...@collabora.com> Date: Mon Jan 26 23:20:44 2015 +0100 native-code.py: We need these services everywhere anyway. Change-Id: I97cfedb54d91f6d689f357e65599c91a6cd9f3d3 diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 52d98c9..e387473 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -49,9 +49,9 @@ core_factory_list = [ ("libxolo.a", "xo_component_getFactory"), ("libxsec_xmlsec.a", "xsec_xmlsec_component_getFactory", "#ifndef ANDROID"), ("libxstor.a", "xstor_component_getFactory"), - ("libcanvasfactorylo.a", "canvasfactory_component_getFactory", "#ifdef ANDROID"), - ("libvclcanvaslo.a", "vclcanvas_component_getFactory", "#ifdef ANDROID"), - ("libmtfrendererlo.a", "mtfrenderer_component_getFactory", "#ifdef ANDROID"), + ("libcanvasfactorylo.a", "canvasfactory_component_getFactory"), + ("libvclcanvaslo.a", "vclcanvas_component_getFactory"), + ("libmtfrendererlo.a", "mtfrenderer_component_getFactory"), ] core_constructor_list = [ @@ -150,14 +150,14 @@ draw_factory_list = [ ("libsvgfilterlo.a", "svgfilter_component_getFactory"), ("libdeployment.a", "deployment_component_getFactory"), ("libemboleobj.a", "emboleobj_component_getFactory"), - ("libanimcorelo.a", "animcore_component_getFactory", "#ifdef ANDROID"), + ("libanimcorelo.a", "animcore_component_getFactory"), ] draw_constructor_list = [ ] writer_factory_list = [ - ("libsblo.a", "sb_component_getFactory", "#ifdef ANDROID"), + ("libsblo.a", "sb_component_getFactory"), ("libswdlo.a", "swd_component_getFactory"), ("libswlo.a", "sw_component_getFactory"), ("libwriterfilterlo.a", "writerfilter_component_getFactory"), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits