Skip to content

Commit

Permalink
Use custom data.
Browse files Browse the repository at this point in the history
ICU is used to:
- List locales (`locales_tree`)
- Get information about those locales in different languages (`lang_tree`)
- Remove accents (`translit`)

Tracing ICU without custom data, we also load `likelySubtags` and
`metadata`. Not sure why and what happen when missing but let's be
conservatives and include them.
  • Loading branch information
mgautierfr committed Oct 31, 2023
1 parent 6126163 commit d056a91
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
32 changes: 30 additions & 2 deletions kiwixbuild/dependencies/icu4c.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
MakeBuilder
)

from kiwixbuild.utils import SkipCommand, Remotefile
from kiwixbuild._global import get_target_step
from kiwixbuild.utils import pj, SkipCommand, Remotefile, extract_archive
from kiwixbuild._global import get_target_step, neutralEnv
import os, shutil

class Icu(Dependency):
name = "icu4c"
Expand All @@ -14,6 +15,30 @@ class Source(ReleaseDownload):
archive = Remotefile('icu4c-71_1-src.tgz',
'67a7e6e51f61faf1306b6935333e13b2c48abd8da6d2f46ce6adca24b1e21ebf',
'https://github.com/unicode-org/icu/releases/download/release-71-1/icu4c-71_1-src.tgz')
archive_data = Remotefile('icu4c-71_1-data.zip',
'e3882b4fece6e5e039f22c3189b7ba224180fd26fdbfa9db284617455b93e804',
'https://github.com/unicode-org/icu/releases/download/release-71-1/icu4c-71_1-data.zip')


archives = [archive_src, archive_data]

def _extract(self, context):
context.try_skip(self.extract_path)
if os.path.exists(self.extract_path):
shutil.rmtree(self.extract_path)
extract_archive(
pj(neutralEnv('archive_dir'), self.archive_src.name),
neutralEnv('source_dir'),
topdir=None,
name=self.source_dir)
shutil.rmtree(pj(neutralEnv('source_dir'), self.source_dir, 'source', 'data'))
extract_archive(
pj(neutralEnv('archive_dir'), self.archive_data.name),
pj(neutralEnv('source_dir'), self.source_dir, 'source'),
topdir='data',
name='data'
)

patches = [
# "icu4c_fix_static_lib_name_mingw.patch",
# "icu4c_android_elf64_st_info.patch",
Expand Down Expand Up @@ -49,3 +74,6 @@ def configure_option(self):
if platformInfo.build in ('android', 'wasm'):
options += " --with-data-packaging=archive"
return options

def set_env(self, env):
env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json")
14 changes: 14 additions & 0 deletions kiwixbuild/dependencies/icu4c_data_filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"strategy": "additive",
"featureFilters": {
"lang_tree": "include",
"locales_tree": "include",
"translit": "include",
"misc": {
"includelist": [
"likelySubtags",
"metadata"
]
}
}
}

0 comments on commit d056a91

Please sign in to comment.