]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
icu: Add knobs to generate a subset of ICU data
authorKhem Raj <raj.khem@gmail.com>
Sat, 4 Apr 2020 23:02:57 +0000 (16:02 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 5 Apr 2020 10:46:34 +0000 (11:46 +0100)
Recent versions of ICU (64+) provides a tool for configuring ICU
locale data file with finer granularity [1]

Default generated size for libicudata.so.66.1 is ~27M, which is quite
large for embedded systems and all of them may not even need all locale
data.

This patch calls the icudata buildtool during configure on the icudata
and utilizes a filter called 'filter.json` ( empty by default) to
create the data, default behavior should remain same but someone can
add a filter.json in own layer to configure this data, e.g.

{
  "localeFilter": {
    "filterType": "language",
    "whitelist": [
      "en",
      "de",
      "it"
    ]
  }
}

would only generate the locale data for english/german/italian

This would reduce the size of libicudata.so.66.1 to 12M

Ensure that icudata is generated using host-tools so it can deal with
endianness correctly, when host and target systems have different
endianness

install the icudtata file back into in/ folder so that main build
can now pickup this data file instead of regenerating it and wiping
out the filter changes that are expected to take effect

Use native compiler tools

Update the big-endian support patch to apply to latest Makefile.in
from icudata source and mark it as backport

defer applying 0001-Fix-big-endian-build.patch after moving new data/ in

[1] https://github.com/unicode-org/icu/blob/master/docs/userguide/icu_data/buildtool.md

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Suggested-by: Wouter Meek <w.meek@metrological.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-support/icu/icu/0001-Fix-big-endian-build.patch
meta/recipes-support/icu/icu/filter.json [new file with mode: 0644]
meta/recipes-support/icu/icu_66.1.bb

index efb27ae4e31e0d8a527c76cbed391431d7b93fa0..91d68848c70e523ac7dd17694d8b12564f40d3eb 100644 (file)
@@ -6,23 +6,23 @@ Subject: [PATCH] Fix big-endian build
 Bug-report: https://unicode-org.atlassian.net/browse/ICU-20533
 Patch taken from: https://bugs.gentoo.org/682170
 
-Upstream-Status: Pending
+it is applied upstream and will be in version 67+
+
+Upstream-Status: Backport [https://github.com/unicode-org/icu/commit/4a3a457b38cd828b7b3fa4fdbc6e2504a57275e9]
 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
 ---
  data/Makefile.in | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
-diff --git a/source/data/Makefile.in b/source/data/Makefile.in
-index 778b6c7..67203e7 100644
 --- a/data/Makefile.in
 +++ b/data/Makefile.in
-@@ -148,7 +148,8 @@ ICUDATA_ARCHIVE = $(firstword $(wildcard $(srcdir)/in/$(ICUDATA_BASENAME_VERSION
- # and convert it to the current type.
- ifneq ($(ICUDATA_ARCHIVE),)
- ICUDATA_SOURCE_ARCHIVE = $(OUTDIR)/$(ICUDATA_PLATFORM_NAME).dat
--$(ICUDATA_SOURCE_ARCHIVE): $(ICUDATA_ARCHIVE) $(OUTDIR)
-+$(ICUDATA_SOURCE_ARCHIVE): $(ICUDATA_ARCHIVE)
-+      $(MKINSTALLDIRS) $(OUTDIR)
-       $(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(ICUDATA_ARCHIVE) $(ICUDATA_SOURCE_ARCHIVE)
- endif
- else
+@@ -148,7 +148,8 @@ ICUDATA_ARCHIVE = $(firstword $(wildcard
+ # and convert it to the current type.\r
+ ifneq ($(ICUDATA_ARCHIVE),)\r
+ ICUDATA_SOURCE_ARCHIVE = $(OUTDIR)/$(ICUDATA_PLATFORM_NAME).dat\r
+-$(ICUDATA_SOURCE_ARCHIVE): $(ICUDATA_ARCHIVE) $(OUTDIR)\r
++$(ICUDATA_SOURCE_ARCHIVE): $(ICUDATA_ARCHIVE)\r
++      $(MKINSTALLDIRS) $(OUTDIR)\r
+       $(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(ICUDATA_ARCHIVE) $(ICUDATA_SOURCE_ARCHIVE)\r
+ endif\r
+ else\r
diff --git a/meta/recipes-support/icu/icu/filter.json b/meta/recipes-support/icu/icu/filter.json
new file mode 100644 (file)
index 0000000..2c63c08
--- /dev/null
@@ -0,0 +1,2 @@
+{
+}
index 5018464c14e557f8edc3c5fd7de1a2bd76793f74..0d26f52f20bb845c38d6094fd7172a126e07c139 100644 (file)
@@ -18,18 +18,47 @@ ARM_INSTRUCTION_SET_armv4 = "arm"
 ARM_INSTRUCTION_SET_armv5 = "arm"
 
 BASE_SRC_URI = "https://github.com/unicode-org/icu/releases/download/release-${ICU_FOLDER}/icu4c-${ICU_PV}-src.tgz"
-SRC_URI = "${BASE_SRC_URI} \
+DATA_SRC_URI = "https://github.com/unicode-org/icu/releases/download/release-${ICU_FOLDER}/icu4c-${ICU_PV}-data.zip"
+SRC_URI = "${BASE_SRC_URI};name=code \
+           ${DATA_SRC_URI};name=data \
+           file://filter.json \
            file://icu-pkgdata-large-cmd.patch \
            file://fix-install-manx.patch \
-           file://0001-Fix-big-endian-build.patch \
+           file://0001-Fix-big-endian-build.patch;apply=no \
            file://0001-icu-Added-armeb-support.patch \
            "
 
 SRC_URI_append_class-target = "\
            file://0001-Disable-LDFLAGSICUDT-for-Linux.patch \
           "
-SRC_URI[md5sum] = "b33dc6766711517c98d318447e5110f8"
-SRC_URI[sha256sum] = "52a3f2209ab95559c1cf0a14f24338001f389615bf00e2585ef3dbc43ecf0a2e"
+SRC_URI[code.sha256sum] = "52a3f2209ab95559c1cf0a14f24338001f389615bf00e2585ef3dbc43ecf0a2e"
+SRC_URI[data.sha256sum] = "8be647f738891d2beb79d48f99077b3499948430eae6f1be112553b15ab0243e"
 
 UPSTREAM_CHECK_REGEX = "icu4c-(?P<pver>\d+(_\d+)+)-src"
 UPSTREAM_CHECK_URI = "https://github.com/unicode-org/icu/releases"
+
+do_make_icudata_class-target () {
+    cd ${S}
+    rm -rf data
+    cp -a ${WORKDIR}/data .
+    patch -p1 < ${WORKDIR}/0001-Fix-big-endian-build.patch
+    AR='${BUILD_AR}' \
+    CC='${BUILD_CC}' \
+    CPP='${BUILD_CPP}' \
+    CXX='${BUILD_CXX}' \
+    RANLIB='${BUILD_RANLIB}' \
+    CFLAGS='${BUILD_CFLAGS}' \
+    CPPFLAGS='${BUILD_CPPFLAGS}' \
+    CXXFLAGS='${BUILD_CXXFLAGS}' \
+    LDFLAGS='${BUILD_LDFLAGS}' \
+    ICU_DATA_FILTER_FILE=${WORKDIR}/filter.json \
+    ./runConfigureICU Linux --with-data-packaging=archive
+    oe_runmake ${PARALLEL_MAKE}
+    install -Dm644 ${S}/data/out/icudt${ICU_MAJOR_VER}l.dat ${S}/data/in/icudt${ICU_MAJOR_VER}l.dat
+}
+
+do_make_icudata() {
+    :
+}
+
+addtask make_icudata before do_configure after do_patch