diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-03-14 15:40:11 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-04-07 16:17:20 +0000 |
commit | 4cbf2aa11503a34bc0b7bb7014116b0994f80c6c (patch) | |
tree | 85863d1a809b14db6d195941db988b9bafe44952 | |
parent | 7619c4693e1b77dc72d0f9646f97f72a0f8d1a0e (diff) |
Generate openoffice_dat.c from source.
Change-Id: I78f00cc0fb38cc5121a9d543197792a9f12e9177
-rw-r--r-- | i18npool/breakiterator/OpenOffice_dat.c | 51 | ||||
-rw-r--r-- | i18npool/breakiterator/OpenOffice_tmp.c | 48 | ||||
-rw-r--r-- | i18npool/meson.build | 9 | ||||
-rwxr-xr-x | i18npool/oogen.py | 54 |
4 files changed, 62 insertions, 100 deletions
diff --git a/i18npool/breakiterator/OpenOffice_dat.c b/i18npool/breakiterator/OpenOffice_dat.c deleted file mode 100644 index 3afacea7466e..000000000000 --- a/i18npool/breakiterator/OpenOffice_dat.c +++ /dev/null @@ -1,51 +0,0 @@ -#ifdef _MSC_VER -#pragma warning(disable : 4229) -#endif -/* - * ICU common data table of contents for OpenOffice.tmp - * Automatically generated by icu/source/tools/gencmn/gencmn . - */ - -#include "unicode/utypes.h" -#include "unicode/udata.h" - -/* external symbol declarations for data (13 files) */ -extern const char OpenOffice_char_brk[], OpenOffice_char_in_brk[], OpenOffice_count_word_brk[], - OpenOffice_dict_word_brk[], OpenOffice_dict_word_he_brk[], OpenOffice_dict_word_hu_brk[], - OpenOffice_dict_word_nodash_brk[], OpenOffice_dict_word_prepostdash_brk[], - OpenOffice_edit_word_brk[], OpenOffice_edit_word_he_brk[], OpenOffice_edit_word_hu_brk[], - OpenOffice_line_brk[], OpenOffice_sent_brk[]; - -U_EXPORT struct -{ - uint16_t headerSize; - uint8_t magic1, magic2; - UDataInfo info; - char padding[8]; - uint32_t count, reserved; - struct - { - const char* name; - const void* data; - } toc[13]; -} U_EXPORT2 OpenOffice_dat - = { 32, - 0xda, - 0x27, - { 20, 0, 0, 0, 2, 0, { 0x54, 0x6f, 0x43, 0x50 }, { 1, 0, 0, 0 }, { 0, 0, 0, 0 } }, - "", - 13, - 0, - { { "OpenOffice/char.brk", OpenOffice_char_brk }, - { "OpenOffice/char_in.brk", OpenOffice_char_in_brk }, - { "OpenOffice/count_word.brk", OpenOffice_count_word_brk }, - { "OpenOffice/dict_word.brk", OpenOffice_dict_word_brk }, - { "OpenOffice/dict_word_he.brk", OpenOffice_dict_word_he_brk }, - { "OpenOffice/dict_word_hu.brk", OpenOffice_dict_word_hu_brk }, - { "OpenOffice/dict_word_nodash.brk", OpenOffice_dict_word_nodash_brk }, - { "OpenOffice/dict_word_prepostdash.brk", OpenOffice_dict_word_prepostdash_brk }, - { "OpenOffice/edit_word.brk", OpenOffice_edit_word_brk }, - { "OpenOffice/edit_word_he.brk", OpenOffice_edit_word_he_brk }, - { "OpenOffice/edit_word_hu.brk", OpenOffice_edit_word_hu_brk }, - { "OpenOffice/line.brk", OpenOffice_line_brk }, - { "OpenOffice/sent.brk", OpenOffice_sent_brk } } }; diff --git a/i18npool/breakiterator/OpenOffice_tmp.c b/i18npool/breakiterator/OpenOffice_tmp.c deleted file mode 100644 index 150392c4879f..000000000000 --- a/i18npool/breakiterator/OpenOffice_tmp.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ICU common data table of contents for OpenOffice.tmp - * Automatically generated by icu/source/tools/gencmn/gencmn . - */ - -#include "unicode/utypes.h" -#include "unicode/udata.h" - -/* external symbol declarations for data (13 files) */ -extern const char OpenOffice_char_brk[], OpenOffice_char_in_brk[], OpenOffice_count_word_brk[], - OpenOffice_dict_word_brk[], OpenOffice_dict_word_he_brk[], OpenOffice_dict_word_hu_brk[], - OpenOffice_dict_word_nodash_brk[], OpenOffice_dict_word_prepostdash_brk[], - OpenOffice_edit_word_brk[], OpenOffice_edit_word_he_brk[], OpenOffice_edit_word_hu_brk[], - OpenOffice_line_brk[], OpenOffice_sent_brk[]; - -U_EXPORT struct -{ - uint16_t headerSize; - uint8_t magic1, magic2; - UDataInfo info; - char padding[8]; - uint32_t count, reserved; - struct - { - const char* name; - const void* data; - } toc[13]; -} U_EXPORT2 OpenOffice_dat - = { 32, - 0xda, - 0x27, - { 20, 0, 0, 0, 2, 0, { 0x54, 0x6f, 0x43, 0x50 }, { 1, 0, 0, 0 }, { 0, 0, 0, 0 } }, - "", - 13, - 0, - { { "OpenOffice/char.brk", OpenOffice_char_brk }, - { "OpenOffice/char_in.brk", OpenOffice_char_in_brk }, - { "OpenOffice/count_word.brk", OpenOffice_count_word_brk }, - { "OpenOffice/dict_word.brk", OpenOffice_dict_word_brk }, - { "OpenOffice/dict_word_he.brk", OpenOffice_dict_word_he_brk }, - { "OpenOffice/dict_word_hu.brk", OpenOffice_dict_word_hu_brk }, - { "OpenOffice/dict_word_nodash.brk", OpenOffice_dict_word_nodash_brk }, - { "OpenOffice/dict_word_prepostdash.brk", OpenOffice_dict_word_prepostdash_brk }, - { "OpenOffice/edit_word.brk", OpenOffice_edit_word_brk }, - { "OpenOffice/edit_word_he.brk", OpenOffice_edit_word_he_brk }, - { "OpenOffice/edit_word_hu.brk", OpenOffice_edit_word_hu_brk }, - { "OpenOffice/line.brk", OpenOffice_line_brk }, - { "OpenOffice/sent.brk", OpenOffice_sent_brk } } }; diff --git a/i18npool/meson.build b/i18npool/meson.build index cf64487bbac4..078d7301319f 100644 --- a/i18npool/meson.build +++ b/i18npool/meson.build @@ -19,6 +19,12 @@ break_sources = g.process('source/breakiterator/data/char.txt', 'source/breakiterator/data/sent.txt', ) +openoffice_c = custom_target('openoffice.c', + output: 'OpenOffice_dat.c', + command: [find_program('oogen.py'), + '@OUTPUT@', + '@PRIVATE_DIR@']) + i18npool_lib = shared_library('i18npoollo', 'source/breakiterator/breakiterator_cjk.cxx', 'source/breakiterator/breakiteratorImpl.cxx', @@ -93,7 +99,8 @@ i18npool_lib = shared_library('i18npoollo', 'source/transliteration/transliteration_Numeric.cxx', 'source/transliteration/transliteration_OneToOne.cxx', break_sources, - 'breakiterator/OpenOffice_dat.c', + openoffice_c, + #'breakiterator/OpenOffice_dat.c', udk_fake_h, off_fake_h, cpp_args: ['-DLIBO_INTERNAL_ONLY'], include_directories: [main_inc, udkh_inc, offapi_inc, 'inc'], diff --git a/i18npool/oogen.py b/i18npool/oogen.py new file mode 100755 index 000000000000..5b53552cb196 --- /dev/null +++ b/i18npool/oogen.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +import os, sys, subprocess + +output_name = sys.argv[1] +output_dir = os.path.split(output_name)[0] +dattmp_name = os.path.splitext(output_name)[0] + '.tmp' +gncmtmp_name = output_name.replace('_dat.c', '_tmp.c') +priv_dir = sys.argv[2] +rsp_name = os.path.join(priv_dir, dattmp_name) + +if not os.path.isdir(priv_dir): + os.mkdir(priv_dir) + +open(dattmp_name, 'w').write('''char_in.brk +char.brk +count_word.brk +dict_word_he.brk +dict_word_hu.brk +dict_word_nodash.brk +dict_word_prepostdash.brk +dict_word.brk +edit_word_he.brk +edit_word_hu.brk +edit_word.brk +line.brk +sent.brk +''') + +rc = subprocess.call(['gencmn', + '-n', + 'OpenOffice', + '-t', + 'tmp', + '-S', + '-d', + output_dir, + '0', + dattmp_name]) + +os.unlink(dattmp_name) + +if rc != 0: + sys.exit(rc) + +d = open(gncmtmp_name, 'r').read() +with open(output_name, 'w') as ofile: + ofile.write('''#ifdef _MSC_VER +#pragma warning(disable : 4229) +#endif +''') + ofile.write(d) + +os.unlink(gncmtmp_name) |