Skip to content

Commit

Permalink
Build icu4c using meson on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Nov 29, 2023
1 parent 08f7f23 commit 2e4193e
Showing 1 changed file with 53 additions and 38 deletions.
91 changes: 53 additions & 38 deletions kiwixbuild/dependencies/icu4c.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from .base import (
Dependency,
ReleaseDownload,
MakeBuilder
MakeBuilder, MesonBuilder
)

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

class Icu(Dependency):
name = "icu4c"
Expand All @@ -19,9 +20,12 @@ class Source(ReleaseDownload):
archive_data = Remotefile('icu4c-73_2-data.zip',
'ca1ee076163b438461e484421a7679fc33a64cd0a54f9d4b401893fa1eb42701',
'https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-data.zip')
meson_patch = Remotefile('icu_73.2-2_patch.zip',
'',
'https://wrapdb.mesonbuild.com/v2/icu_73.2-2/get_patch')


archives = [archive_src, archive_data]
archives = [archive_src, archive_data, meson_patch]

def _extract(self, context):
context.try_skip(self.extract_path)
Expand All @@ -39,6 +43,12 @@ def _extract(self, context):
topdir='data',
name='data'
)
extract_archive(
pj(neutralEnv('archive_dir'), self.meson_patch.name),
neutralEnv('source_dir'),
topdir='icu',
name= self.source_dir
)

patches = [
"icu4c_fix_static_lib_name_mingw.patch",
Expand All @@ -50,44 +60,49 @@ def _extract(self, context):
"icu4c_wasm.patch"
]

if platform.system() == 'Windows':
class Builder(MesonBuilder):
def set_env(self, env):
env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json")

class Builder(MakeBuilder):
subsource_dir = "source"
make_install_targets = ["install"]
else:
class Builder(MakeBuilder):
subsource_dir = "source"
make_install_targets = ["install"]

@classmethod
def get_dependencies(cls, platformInfo, allDeps):
plt = 'native_static' if platformInfo.static else 'native_dyn'
return [(plt, 'icu4c')]
@classmethod
def get_dependencies(cls, platformInfo, allDeps):
plt = 'native_static' if platformInfo.static else 'native_dyn'
return [(plt, 'icu4c')]

@property
def configure_options(self):
yield "--disable-samples"
yield "--disable-tests"
yield "--disable-extras"
yield "--disable-dyload"
yield "--enable-rpath"
yield "--disable-icuio"
yield "--disable-layoutex"
platformInfo = self.buildEnv.platformInfo
if platformInfo.build != 'native':
icu_native_builder = get_target_step(
'icu4c',
'native_static' if platformInfo.static else 'native_dyn')
yield f"--with-cross-build={icu_native_builder.build_path}"
yield "--disable-tools"
if platformInfo.build in ('android', 'wasm'):
yield "--with-data-packaging=archive"
@property
def configure_options(self):
yield "--disable-samples"
yield "--disable-tests"
yield "--disable-extras"
yield "--disable-dyload"
yield "--enable-rpath"
yield "--disable-icuio"
yield "--disable-layoutex"
platformInfo = self.buildEnv.platformInfo
if platformInfo.build != 'native':
icu_native_builder = get_target_step(
'icu4c',
'native_static' if platformInfo.static else 'native_dyn')
yield f"--with-cross-build={icu_native_builder.build_path}"
yield "--disable-tools"
if platformInfo.build in ('android', 'wasm'):
yield "--with-data-packaging=archive"

def set_env(self, env):
env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json")
def set_env(self, env):
env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json")

def _post_configure_script(self, context):
if self.buildEnv.platformInfo.build != "wasm":
context.skip()
context.try_skip(self.build_path)
for line in fileinput.input(pj(self.build_path, 'Makefile'), inplace=True):
if line == "#DATASUBDIR = data\n":
print("DATASUBDIR = data")
else:
print(line, end="")
def _post_configure_script(self, context):
if self.buildEnv.platformInfo.build != "wasm":
context.skip()
context.try_skip(self.build_path)
for line in fileinput.input(pj(self.build_path, 'Makefile'), inplace=True):
if line == "#DATASUBDIR = data\n":
print("DATASUBDIR = data")
else:
print(line, end="")

0 comments on commit 2e4193e

Please sign in to comment.