diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-03-27 22:58:15 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-04-07 16:17:21 +0000 |
commit | 709a55c271ebff1167776455d372306581da5821 (patch) | |
tree | c4116599a93adfd24e03711f36c55a9ab072f1b6 | |
parent | 16d8d6ae21cb58120e0aa2bf0bc838bd5fc8c9a0 (diff) |
Generate the locale registry (it is still broken, though).
Change-Id: I6e84b7a240a33f01260cb297516951b2406acb40
-rwxr-xr-x | cppuhelper/genservices.py | 22 | ||||
-rw-r--r-- | cppuhelper/hackdir/genservices.py | 86 | ||||
-rw-r--r-- | cppuhelper/hackdir/meson.build | 12 | ||||
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | officecfg/genregistry.py | 106 | ||||
-rw-r--r-- | officecfg/meson.build | 60 |
6 files changed, 286 insertions, 1 deletions
diff --git a/cppuhelper/genservices.py b/cppuhelper/genservices.py index cbd4d6116746..4de80b0445e9 100755 --- a/cppuhelper/genservices.py +++ b/cppuhelper/genservices.py @@ -125,6 +125,21 @@ components = [ # 'ucb/source/ucp/gio/ucpgio', ] +def check_identicality(c): + import pathlib + p = pathlib.Path('/mnt/scratch/libreofficemeson/workdir/ComponentTarget') + l = list(p.glob('**/' + os.path.split(c)[1])) + assert(len(l) == 1) + truth = l[0] + truthcomponent = ET.parse(truth) + truthcomponent.write('temppi.xml', xml_declaration=True) + d1 = open(c).read() + d2 = open('temppi.xml').read() + if d1 != d2: + print(c) + print(d1) + sys.exit(1) + # This is terrible and hacky and should be replaced with # introspection or something similar. def determine_libname(source_root, component_base): @@ -156,6 +171,7 @@ with tempfile.TemporaryDirectory() as tmpdir: cbase = os.path.basename(c) iname = os.path.join('..', c + '.component') oname = os.path.join(tmpdir, cbase + '.component') + assert 'xmlns' in open(iname).read() assert(not os.path.exists(oname)) n = ET.SubElement(root, 'filename') n.text = oname @@ -167,9 +183,13 @@ with tempfile.TemporaryDirectory() as tmpdir: croot.attrib['uri'] = 'vnd.sun.star.expand:$LO_LIB_DIR/' + libname new_root = ET.Element('components') new_root.append(component.getroot()) - new_root.attrib['xmlns'] = 'http://openoffice.org/2010/uno-components' +# new_root.attrib['xmlns'] = 'http://openoffice.org/2010/uno-components' tree = ET.ElementTree(new_root) tree.write(oname, xml_declaration=True) + hack = open(oname).read() + hack = hack.replace('ns0:', '').replace(':ns0', '') + open(oname, 'w').write(hack) + #check_identicality(oname) tree = ET.ElementTree(root) tmp_xml = os.path.join(tmpdir, 'servicelist.xml') diff --git a/cppuhelper/hackdir/genservices.py b/cppuhelper/hackdir/genservices.py new file mode 100644 index 000000000000..fb7e48dc576e --- /dev/null +++ b/cppuhelper/hackdir/genservices.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +import os, sys, subprocess, shutil, tempfile +import xml.etree.ElementTree as ET + +output_name = sys.argv[1] +input_name = sys.argv[2] + +components = [ + 'binaryurp/source/binaryurp', + 'io/source/io', + 'stoc/util/bootstrap', + 'stoc/source/inspect/introspection', + 'stoc/source/invocation_adapterfactory/invocadapt', + 'stoc/source/invocation/invocation', + 'stoc/source/namingservice/namingservice', + 'stoc/source/proxy_factory/proxyfac', + 'stoc/source/corereflection/reflection', + 'stoc/util/stocservices', + 'remotebridges/source/unourl_resolver/uuresolver', +# 'stoc/source/javaloader/javaloader', +# 'stoc/source/javavm/javavm', +] + + +# This is terrible and hacky and should be replaced with +# introspection or something similar. +def determine_libname(source_root, component_base): + component_name = os.path.split(component_base)[1] + component_dir = component_base.split('/', 1)[0] + meson_file = os.path.join(source_root, component_dir, 'meson.build') + assert(os.path.exists(meson_file)) + losearch = "shared_library('{}lo'".format(component_name) + nolosearch = "shared_library('{}'".format(component_name) + with open(meson_file) as mfile: + for line in mfile: + if losearch in line: + return 'lib{}lo.so'.format(component_name) + if nolosearch in line: + return 'lib{}.so'.format(component_name) + # Haximus Maximux + if component_name == 'comphelp': + return 'libcomphelper.so' + if component_name == 'filterconfig1': + return 'libfilterconfiglo.so' + if component_name == 'lwpfilter': + return 'liblwpft.so' + sys.exit('Could not find shared library for {}.'.format(component_base)) + +with tempfile.TemporaryDirectory() as tmpdir: + root = ET.Element('list') + + for c in components: + cbase = os.path.basename(c) + iname = os.path.join('..', c + '.component') + oname = os.path.join(tmpdir, cbase + '.component') + assert(not os.path.exists(oname)) + n = ET.SubElement(root, 'filename') + n.text = oname + component = ET.parse(iname) + libname = determine_libname('..', c) + croot = component.getroot() + assert('environment' in croot.attrib) + croot.attrib['environment'] = 'gcc3' + croot.attrib['uri'] = 'vnd.sun.star.expand:$LO_LIB_DIR/' + libname + new_root = ET.Element('components') + new_root.append(component.getroot()) + new_root.attrib['xmlns'] = 'http://openoffice.org/2010/uno-components' + tree = ET.ElementTree(new_root) + tree.write(oname, xml_declaration=True) + + tree = ET.ElementTree(root) + tmp_xml = os.path.join(tmpdir, 'servicelist.xml') + tree.write(tmp_xml, xml_declaration=True) + + rc = subprocess.call(['xsltproc', + #'-v', + '--nonet', + '-o', + output_name, + input_name, + tmp_xml, + ]) + + if rc != 0: + sys.exit(rc) diff --git a/cppuhelper/hackdir/meson.build b/cppuhelper/hackdir/meson.build new file mode 100644 index 000000000000..de46286f5f52 --- /dev/null +++ b/cppuhelper/hackdir/meson.build @@ -0,0 +1,12 @@ +# This is in its own dir because the output file has the same +# name as the other services file. +services2_rdb = custom_target('services_rdb', + input: '../../solenv/bin/packcomponents.xslt', + output: 'services.rdb', + command: [find_program('genservices.py'), + '@OUTPUT@', + '@INPUT@', + ], + install: true, + install_dir: get_option('bindir'), +) diff --git a/meson.build b/meson.build index 51036878a25f..7c3691f5e8eb 100644 --- a/meson.build +++ b/meson.build @@ -264,3 +264,4 @@ subdir('scripting') subdir('dtrans') subdir('sdext') subdir('instsetoo_native') +#subdir('postprocess') diff --git a/officecfg/genregistry.py b/officecfg/genregistry.py new file mode 100644 index 000000000000..03048f522bfb --- /dev/null +++ b/officecfg/genregistry.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 + +import sys, os, subprocess, tempfile, shutil +import xml.etree.ElementTree as ET + +srcdir = sys.argv[1] +srcroot = os.path.normpath(os.path.join(srcdir, '..')) +outname = sys.argv[2] +infiles = sys.argv[3:] + +xsltproc = shutil.which('xsltproc') +schemaroot = os.path.join(srcroot, 'officecfg/registry/schema') +registrydir = os.path.join(srcroot, 'officecfg/registry') +xcsdir = os.path.join(srcroot, 'org/openoffice/Office/UI') # WRONG + +'''S=/mnt/scratch/libreoffice && I=$S/instdir && W=$S/workdir && + mkdir -p $W/XcuResTarget/registry/en-US/org/openoffice/Office/UI/ && + xsltproc --nonet -o $W/XcuResTarget/registry/en-US/org/openoffice/Office/UI/Effects.xcu + --stringparam xcs + $W/XcsTarget/org/openoffice/Office/UI/Effects.xcs + --stringparam schemaRoot $S/officecfg/registry/schema +--stringparam locale en-US +--stringparam LIBO_SHARE_FOLDER share +--stringparam LIBO_SHARE_HELP_FOLDER help +--path $S/officecfg/registry $S/officecfg/util/alllang.xsl + $S/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu''' + +l = '''S=/mnt/scratch/libreoffice && I=$S/instdir && W=$S/workdir && + find $W/XcuResTarget/registry/en-US/ + $W/XcuResTarget/driver_calc/en-US/ + $W/XcuResTarget/driver_dbase/en-US/ + $W/XcuResTarget/driver_flat/en-US/ + $W/XcuResTarget/driver_odbc/en-US/ + $W/XcuResTarget/driver_mysql_jdbc/en-US/ + $W/XcuResTarget/driver_mork/en-US/ +$W/XcuResTarget/driver_hsqldb/en-US/ + $W/XcuResTarget/driver_jdbc/en-US/ + $W/XcuResTarget/driver_firebird_sdbc/en-US/ + $W/XcuResTarget/driver_mysqlc/en-US/ + $W/XcuResTarget/driver_writer/en-US/ + $W/XcuResTarget/driver_mysql_jdbc/en-US/ + $W/XcuResTarget/driver_postgresql/en-US/ + -name *.xcu | LC_ALL=C sort | + awk 'BEGIN{print "<list>"} {print "<filename>"$0"</filename>"} END {print "</list>"}' > $W/CustomTarget/postprocess/registry/registry_en-US.list +''' + +final = '''S=/mnt/scratch/libreoffice && +I=$S/instdir && + W=$S/workdir && +mkdir -p $W/XcdTarget/ && +xsltproc +--nonet -o +$W/XcdTarget/registry_en-US.xcd + $S/solenv/bin/packregistry.xslt +$W/CustomTarget/postprocess/registry/registry_en-US.list +''' + +with tempfile.TemporaryDirectory() as tmpdir: + xcus = [] + for i in infiles: + ofilename = os.path.split(i)[1] + xcsname = os.path.splitext(ofilename)[0] + '.xcs' + ofilename_abs = os.path.join(tmpdir, ofilename) + rc = subprocess.call([xsltproc, + '--nonet', + '-o', + ofilename_abs, + '--stringparam', + 'xcs', + xcsname, + '--stringparam', + 'schemaRoot', + schemaroot, + '--stringparam', + 'locale', + 'en-US', + '--stringparam', + 'LIBO_SHARE_FOLDER', + 'share', + '--stringparam', + 'LIBO_SHARE_HELP_FOLDER', + 'help', + '--path', + registrydir, + os.path.join(srcroot, 'officecfg/util/alllang.xsl'), + i, + ]) + if rc != 0: + sys.exit(rc) + xcus.append(ofilename_abs) + root = ET.Element('list') + for xcu in sorted(xcus): + n = ET.SubElement(root, 'filename') + n.text = xcu + tree = ET.ElementTree(root) + tmp_xml = os.path.join(tmpdir, 'registry_en-US.list') + tree.write(tmp_xml, xml_declaration=True) + rc = subprocess.call([xsltproc, + '--nonet', + '-o', + outname, + os.path.join(srcroot, 'solenv/bin/packregistry.xslt'), + tmp_xml, + ]) + if rc != 0: + sys.exit(rc) diff --git a/officecfg/meson.build b/officecfg/meson.build index b2029efccb41..ee3a66a4ba2f 100644 --- a/officecfg/meson.build +++ b/officecfg/meson.build @@ -54,3 +54,63 @@ inet_hxx = custom_target('Inet.hxx', '@INPUT@']) setup_inc = include_directories('..') # HACK + +registry_en_us_xcu = custom_target('registry_en_US', + output: 'registry_en-US.xcd', + input: [ + 'registry/data/org/openoffice/Setup.xcu', + 'registry/data/org/openoffice/Office/Accelerators.xcu', + 'registry/data/org/openoffice/Office/Addons.xcu', + 'registry/data/org/openoffice/Office/Common.xcu', + 'registry/data/org/openoffice/Office/DataAccess.xcu', + 'registry/data/org/openoffice/Office/PresentationMinimizer.xcu', + 'registry/data/org/openoffice/Office/PresenterScreen.xcu', + 'registry/data/org/openoffice/Office/TableWizard.xcu', + 'registry/data/org/openoffice/Office/UI.xcu', + 'registry/data/org/openoffice/Office/Embedding.xcu', + 'registry/data/org/openoffice/Office/ExtendedColorScheme.xcu', + 'registry/data/org/openoffice/Office/FormWizard.xcu', + 'registry/data/org/openoffice/Office/Writer.xcu', + 'registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu', + 'registry/data/org/openoffice/Office/UI/BibliographyCommands.xcu', + 'registry/data/org/openoffice/Office/UI/CalcCommands.xcu', + 'registry/data/org/openoffice/Office/UI/ChartCommands.xcu', + 'registry/data/org/openoffice/Office/UI/ChartWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbuCommands.xcu', + 'registry/data/org/openoffice/Office/UI/BaseWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbQueryWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbTableWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbRelationWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbBrowserWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DbTableDataWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu', + 'registry/data/org/openoffice/Office/UI/Effects.xcu', + 'registry/data/org/openoffice/Office/UI/GenericCommands.xcu', + 'registry/data/org/openoffice/Office/UI/MathCommands.xcu', + 'registry/data/org/openoffice/Office/UI/BasicIDEWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/CalcWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/DrawWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/MathWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/ReportCommands.xcu', + 'registry/data/org/openoffice/Office/UI/Sidebar.xcu', + 'registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/XFormsWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu', + 'registry/data/org/openoffice/Office/UI/WriterCommands.xcu', + 'registry/data/org/openoffice/Office/UI/GenericCategories.xcu', + 'registry/data/org/openoffice/Office/UI/ToolbarMode.xcu', + ], + command: [find_program('genregistry.py'), + meson.current_source_dir(), + '@OUTPUT@', + '@INPUT@', + ], + install: true, + install_dir: get_option('datadir') / 'registry/res', +)
\ No newline at end of file |