summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-03-14 15:40:11 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2020-03-14 15:40:11 +0200
commit9155cd367309311eff5369d52beec3a20c9bdc54 (patch)
tree1bb7d190faf9c13d419b08206bd610ecc1c9c5bd
parent9f3a72e4fa5d3050babc07b8ec9ee3433b1181f7 (diff)
Generate openoffice_dat.c from source.
Change-Id: I78f00cc0fb38cc5121a9d543197792a9f12e9177
-rw-r--r--i18npool/breakiterator/OpenOffice_dat.c51
-rw-r--r--i18npool/breakiterator/OpenOffice_tmp.c48
-rw-r--r--i18npool/meson.build9
-rwxr-xr-xi18npool/oogen.py54
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)