From 5c38b183951512d940afee7920088694bcb75087 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 8 Aug 2023 18:45:03 -0500 Subject: [PATCH] =?UTF-8?q?feat(core):=20update=20icu=20dependencies=20?= =?UTF-8?q?=F0=9F=99=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - enable icui18n - .. without breaking anything else in ldml tests For: #9121 --- core/src/ldml/ldml_transforms.cpp | 10 +++++++ core/src/meson.build | 27 +++++++++++++++++-- core/subprojects/icu-minimal.wrap | 3 +-- .../packagefiles/icu/source/meson.build | 3 +-- core/tests/unit/ldml/ldml_test_source.cpp | 1 - core/tests/unit/ldml/meson.build | 23 +++------------- 6 files changed, 40 insertions(+), 27 deletions(-) diff --git a/core/src/ldml/ldml_transforms.cpp b/core/src/ldml/ldml_transforms.cpp index 821f48e0dd..b8c1f5190e 100644 --- a/core/src/ldml/ldml_transforms.cpp +++ b/core/src/ldml/ldml_transforms.cpp @@ -11,6 +11,16 @@ #include #include "kmx/kmx_xstring.h" +#if defined(HAVE_ICU4C) +// TODO-LDML: Needed this for some compiler warnings +#define U_FALLTHROUGH +#include "unicode/uniset.h" +#include "unicode/usetiter.h" +#include "unicode/regex.h" +#else +#error icu4c is required for this code +#endif + #ifndef assert #define assert(x) // TODO-LDML diff --git a/core/src/meson.build b/core/src/meson.build index 97b9291646..2f8c2a1882 100644 --- a/core/src/meson.build +++ b/core/src/meson.build @@ -21,6 +21,27 @@ if cpp_compiler.get_id() == 'emscripten' defns += ['-DKMN_KBP'] endif +# ICU4C is used for repertoire tests and core implementation + +if target_machine.system() == 'linux' + # use pkg-config when targetting linux + pkgconfig = 'pkg-config' + icu_uc = dependency('icu-uc', required: true) + icu_i18n = dependency('icu-i18n', required: true) +else + # load ICU from wrap + # Requires meson of about 0.57+ + icu4c = subproject('icu-minimal', default_options: [ 'default_library=static', 'cpp_std=c++17', 'warning_level=0', +'werror=false']) # TODO-LDML: options: static, no data (these are in the meson build files) + icu_uc = icu4c.get_variable('icuuc_dep') + icu_i18n = icu4c.get_variable('icui18n_dep') +endif + +if icu_uc.found() + defns += '-DHAVE_ICU4C' +endif + + kmx_files = files( 'option.cpp', 'keyboard.cpp', @@ -85,11 +106,13 @@ lib = library('kmnkbp0', version: lib_version, include_directories: inc, pic: true, - install: true) + install: true, + dependencies: [icu_uc, icu_i18n], + ) headerdirs = [ '.', 'keyman' ] # subdirectories of ${prefix}/include to add to header path -kmnkbp = declare_dependency(link_with: lib, include_directories: inc) +kmnkbp = declare_dependency(link_with: lib, include_directories: inc, dependencies: [icu_uc, icu_i18n]) pkg = import('pkgconfig') pkg.generate( diff --git a/core/subprojects/icu-minimal.wrap b/core/subprojects/icu-minimal.wrap index fe509b48e0..3c85940c60 100644 --- a/core/subprojects/icu-minimal.wrap +++ b/core/subprojects/icu-minimal.wrap @@ -10,5 +10,4 @@ patch_directory = icu [provide] icu-uc = icuuc_dep -# TODO-LDML: not including i18n at present -#icu-i18n = icui18n_dep +icu-i18n = icui18n_dep diff --git a/core/subprojects/packagefiles/icu/source/meson.build b/core/subprojects/packagefiles/icu/source/meson.build index 7d08a1e3cb..a304720dfb 100644 --- a/core/subprojects/packagefiles/icu/source/meson.build +++ b/core/subprojects/packagefiles/icu/source/meson.build @@ -9,8 +9,7 @@ endif subdir('stubdata') subdir('common') -# TODO-LDML: Not used now, will need for regex -# subdir('i18n') +subdir('i18n') ## Note: The following subdirs are not used by Keyman (at present) diff --git a/core/tests/unit/ldml/ldml_test_source.cpp b/core/tests/unit/ldml/ldml_test_source.cpp index da65e62a27..1caae7de60 100644 --- a/core/tests/unit/ldml/ldml_test_source.cpp +++ b/core/tests/unit/ldml/ldml_test_source.cpp @@ -25,7 +25,6 @@ #include "ldml/keyboardprocessor_ldml.h" #include "ldml/ldml_processor.hpp" - #include "path.hpp" #include "state.hpp" #include "utfcodec.hpp" diff --git a/core/tests/unit/ldml/meson.build b/core/tests/unit/ldml/meson.build index 679acbe599..f54c94ef28 100644 --- a/core/tests/unit/ldml/meson.build +++ b/core/tests/unit/ldml/meson.build @@ -4,25 +4,6 @@ # Authors: Marc Durdin # -# ICU4C is used for repertoire tests - - -if target_machine.system() == 'linux' - # use pkg-config when targetting linux - pkgconfig = 'pkg-config' - icu_uc = dependency('icu-uc', required: true) -else - # load ICU from wrap - # Requires meson of about 0.57+ - icu4c = subproject('icu-minimal', default_options: [ 'default_library=static', 'cpp_std=c++17', 'warning_level=0', -'werror=false']) # TODO-LDML: options: static, no data (these are in the meson build files) - icu_uc = icu4c.get_variable('icuuc_dep') -endif - -if icu_uc.found() - defns += '-DHAVE_ICU4C' -endif - # TODO -- why are these differing from the standard.meson.build flags? if cpp_compiler.get_id() == 'gcc' or cpp_compiler.get_id() == 'clang' or cpp_compiler.get_id() == 'emscripten' warns = [ @@ -75,8 +56,9 @@ ldml = executable('ldml', cpp_args: defns + warns, include_directories: [inc, libsrc, '../../../../developer/src/ext/json'], link_args: links + tests_flags, - objects: lib.extract_all_objects(recursive: false), dependencies: [icu_uc], + # link_with: [lib], + objects: lib.extract_all_objects(recursive: false), ) # Run tests on all keyboards (`tests` defined in keyboards/meson.build) @@ -110,5 +92,6 @@ t = executable('test_transforms', 'test_transforms.cpp', cpp_args: defns + warns, include_directories: [inc, libsrc, '../../../../developer/src/ext/json'], link_args: links + tests_flags, + dependencies: [icu_uc], objects: lib.extract_all_objects(recursive: false)) test('test_transforms', t, suite: 'ldml')