From 676099fcc9803580845808fcf57d8ae0d74a7c34 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 30 Apr 2024 10:18:07 +0200 Subject: [PATCH] Introduce winbash config and build xapian using it. --- kiwixbuild/configs/__init__.py | 14 ++++++++++++- kiwixbuild/configs/winbash.py | 34 +++++++++++++++++++++++++++++++ kiwixbuild/dependencies/libzim.py | 7 ++++++- kiwixbuild/dependencies/xapian.py | 26 ++++++++++++++++------- 4 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 kiwixbuild/configs/winbash.py diff --git a/kiwixbuild/configs/__init__.py b/kiwixbuild/configs/__init__.py index e82de4d..a9ba045 100644 --- a/kiwixbuild/configs/__init__.py +++ b/kiwixbuild/configs/__init__.py @@ -1,3 +1,15 @@ from .base import * -from . import android, armhf, musl, flatpak, i586, ios, native, neutral, win32, wasm +from . import ( + android, + armhf, + musl, + flatpak, + i586, + ios, + native, + neutral, + win32, + wasm, + winbash, +) diff --git a/kiwixbuild/configs/winbash.py b/kiwixbuild/configs/winbash.py new file mode 100644 index 0000000..20435b5 --- /dev/null +++ b/kiwixbuild/configs/winbash.py @@ -0,0 +1,34 @@ +from .base import ConfigInfo +import sysconfig + +from kiwixbuild.utils import pj +from kiwixbuild._global import get_target_step + + +class WinBashConfigInfo(ConfigInfo): + """This config is kind of internal config to compile xapian using git bash.""" + + name = "win_bash" + compatible_hosts = ["Windows"] + exe_wrapper_def = "" + + @property + def arch_name(self): + return sysconfig.get_platform() + + @property + def config_wrapper(self): + yield "C:\\Program Files\\Git\\bin\\bash.exe" + + @property + def binaries(self): + binaries = { + "CC": "cl -nologo", + "CXX": "cl -nologo", + "AR": "lib", + } + return binaries + + def set_comp_flags(self, env): + super().set_comp_flags(env) + env["CXXFLAGS"] = "-EHsc -MD " + env["CXXFLAGS"] diff --git a/kiwixbuild/dependencies/libzim.py b/kiwixbuild/dependencies/libzim.py index 3441a1c..e2731aa 100644 --- a/kiwixbuild/dependencies/libzim.py +++ b/kiwixbuild/dependencies/libzim.py @@ -23,7 +23,12 @@ class Libzim(Dependency): @classmethod def get_dependencies(cls, configInfo, allDeps): if neutralEnv("distname") == "Windows": - return ["zstd", "icu4c", "zim-testing-suite", "xapian-core"] + return [ + "zstd", + "icu4c", + "zim-testing-suite", + ("win_bash", "xapian-core"), + ] deps = ["lzma", "zstd", "xapian-core", "icu4c"] if configInfo.name not in ("flatpak", "wasm"): deps.append("zim-testing-suite") diff --git a/kiwixbuild/dependencies/xapian.py b/kiwixbuild/dependencies/xapian.py index 252d2c2..eba5271 100644 --- a/kiwixbuild/dependencies/xapian.py +++ b/kiwixbuild/dependencies/xapian.py @@ -1,6 +1,6 @@ from .base import Dependency, ReleaseDownload, MakeBuilder -from kiwixbuild.utils import Remotefile +from kiwixbuild.utils import Remotefile, pj from kiwixbuild._global import neutralEnv @@ -14,12 +14,24 @@ class Xapian(Dependency): ) class Builder(MakeBuilder): - configure_options = [ - "--disable-sse", - "--disable-backend-chert", - "--disable-backend-remote", - "--disable-documentation", - ] + @property + def configure_options(self): + if neutralEnv("distname") == "Windows": + compile_script = pj(self.source_path, "compile") + return [ + 'CC="cl -nologo"', + 'CXX=f"{compile_script} cl -nologo"', + "CXXFLAGS=-EHsc", + "AR=lib", + ] + else: + return [ + "--disable-sse", + "--disable-backend-chert", + "--disable-backend-remote", + "--disable-documentation", + ] + configure_env = { "_format_LDFLAGS": "{env.LDFLAGS} -L{buildEnv.install_dir}/{buildEnv.libprefix}", "_format_CXXFLAGS": "{env.CXXFLAGS} -O3 -I{buildEnv.install_dir}/include",