Remove cross-building libzim to win32.

Now we build libzim natively on Windows, we can remove cross-compilation
to Windows.
This commit is contained in:
Matthieu Gautier 2024-08-30 09:30:36 +02:00 committed by renaud gaudin
parent 507d05a256
commit 49b15d12b7
No known key found for this signature in database
GPG Key ID: 447475A4CFBA2E24
11 changed files with 9 additions and 177 deletions

View File

@ -61,8 +61,6 @@ BUILD_DEF = """
| | aarch64_musl_dyn | d | | B | B | | | linux-aarch64-musl-dyn | | | aarch64_musl_dyn | d | | B | B | | | linux-aarch64-musl-dyn |
| | x86-64_musl_static | | | BP | BP | | linux-x86_64-musl | | | | x86-64_musl_static | | | BP | BP | | linux-x86_64-musl | |
| | x86-64_musl_mixed | BP | | | | | linux-x86_64-musl | | | | x86-64_musl_mixed | BP | | | | | linux-x86_64-musl | |
| | win32_static | d | dB | dBP | dBP | | win-i686 |win32-static |
| | win32_dyn | d | dB | dB | dB | | |win32-dyn |
| | i586_static | | | BP | BP | | linux-i586 | | | | i586_static | | | BP | BP | | linux-i586 | |
| | i586_dyn | | | B | B | | | | | | i586_dyn | | | B | B | | | |
| | wasm | dBP | | | | | wasm-emscripten | wasm | | | wasm | dBP | | | | | wasm-emscripten | wasm |

View File

@ -49,7 +49,7 @@ if platform.system() == "Windows":
BIN_EXT = ".exe" BIN_EXT = ".exe"
else: else:
KBUILD_SOURCE_DIR = HOME / "kiwix-build" KBUILD_SOURCE_DIR = HOME / "kiwix-build"
BIN_EXT = ".exe" if COMPILE_CONFIG.startswith("win32_") else "" BIN_EXT = ""
_ref = _environ.get("GITHUB_REF", "").split("/")[-1] _ref = _environ.get("GITHUB_REF", "").split("/")[-1]

View File

@ -107,10 +107,6 @@ jobs:
image_variant: manylinux image_variant: manylinux
- config: aarch64_mixed - config: aarch64_mixed
image_variant: manylinux image_variant: manylinux
- config: win32_static
image_variant: f35
- config: win32_dyn
image_variant: f35
env: env:
HOME: /home/runner HOME: /home/runner
SSH_KEY: /tmp/id_rsa SSH_KEY: /tmp/id_rsa

View File

@ -131,8 +131,6 @@ jobs:
image_variant: manylinux image_variant: manylinux
- config: aarch64_mixed - config: aarch64_mixed
image_variant: manylinux image_variant: manylinux
- config: win32_static
image_variant: f35
env: env:
HOME: /home/runner HOME: /home/runner
SSH_KEY: /tmp/id_rsa SSH_KEY: /tmp/id_rsa

View File

@ -89,8 +89,6 @@ platforms:
- native_dyn - native_dyn
- native_mixed - native_mixed
- native_static - native_static
- win32_dyn
- win32_static
- android - android
- android_arm - android_arm
- android_arm64 - android_arm64
@ -101,11 +99,6 @@ platforms:
All `native_*` config means using the native compiler without any cross-compilation option. All `native_*` config means using the native compiler without any cross-compilation option.
Other may simply use cross-compilation or may download a specific toolchain to use. Other may simply use cross-compilation or may download a specific toolchain to use.
If you want to compile `kiwix-tools` for win32 using static linkage:
```bash
kiwix-build --config win32_dyn
```
Android Android
------- -------

View File

@ -1,3 +1,3 @@
from .base import * 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, wasm

View File

@ -1,99 +0,0 @@
import subprocess
from .base import ConfigInfo
from kiwixbuild.utils import which, pj
from kiwixbuild._global import neutralEnv
class Win32ConfigInfo(ConfigInfo):
build = "win32"
compatible_hosts = ["fedora", "debian"]
arch_full = "i686-w64-mingw32"
extra_libs = ["-lwinmm", "-lshlwapi", "-lws2_32", "-lssp"]
def get_cross_config(self):
return {
"exe_wrapper_def": self.exe_wrapper_def,
"binaries": self.binaries,
"root_path": self.root_path,
"extra_libs": self.extra_libs,
"extra_cflags": [
"-DWIN32",
*(
"-I{}".format(include_dir)
for include_dir in self.get_include_dirs()
),
],
"host_machine": {
"system": "Windows",
"lsystem": "windows",
"cpu_family": "x86",
"cpu": "i686",
"endian": "little",
"abi": "",
},
}
def finalize_setup(self):
super().finalize_setup()
self.buildEnv.cmake_crossfile = self._gen_crossfile("cmake_cross_file.txt")
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
@property
def root_path(self):
root_paths = {
"fedora": "/usr/i686-w64-mingw32/sys-root/mingw",
"debian": "/usr/i686-w64-mingw32",
}
return root_paths[neutralEnv("distname")]
@property
def binaries(self):
return {
k: which("{}-{}".format(self.arch_full, v))
for k, v in (
("CC", "gcc"),
("CXX", "g++"),
("AR", "ar"),
("STRIP", "strip"),
("WINDRES", "windres"),
("RANLIB", "ranlib"),
("PKGCONFIG", "pkg-config"),
)
}
@property
def exe_wrapper_def(self):
try:
which("wine")
except subprocess.CalledProcessError:
return ""
else:
return "exe_wrapper = 'wine'"
@property
def configure_options(self):
yield f"--host={self.arch_full}"
def set_compiler(self, env):
for k, v in self.binaries.items():
env[k] = v
def get_bin_dir(self):
return [pj(self.root_path, "bin")]
def get_env(self):
env = super().get_env()
env["PKG_CONFIG_LIBDIR"] = pj(self.root_path, "lib", "pkgconfig")
env["LIBS"] = " ".join(self.extra_libs) + " " + env["LIBS"]
return env
class Win32Dyn(Win32ConfigInfo):
name = "win32_dyn"
static = False
class Win32Static(Win32ConfigInfo):
name = "win32_static"
static = True

View File

@ -24,7 +24,7 @@ class AllBaseDependencies(Dependency):
"zim-testing-suite", "zim-testing-suite",
"icu4c", "icu4c",
"boostregex", "boostregex",
"docoptcpp" "docoptcpp",
] ]
if not configInfo.name.endswith("_dyn"): if not configInfo.name.endswith("_dyn"):
@ -50,10 +50,7 @@ class AllBaseDependencies(Dependency):
# Add specific dependencies depending of the config # Add specific dependencies depending of the config
if configInfo.build not in ("android", "iOS"): if configInfo.build not in ("android", "iOS"):
# For zimtools # For zimtools
base_deps += ["docoptcpp"] base_deps += ["docoptcpp", "libmagic", "gumbo"]
if configInfo.build != "win32":
# zimwriterfs
base_deps += ["libmagic", "gumbo"]
if ( if (
configInfo.build == "native" configInfo.build == "native"
and neutralEnv("distname") != "Darwin" and neutralEnv("distname") != "Darwin"

View File

@ -50,9 +50,6 @@ class Xapian(Dependency):
@classmethod @classmethod
def get_dependencies(cls, configInfo, allDeps): def get_dependencies(cls, configInfo, allDeps):
deps = ["zlib", "lzma"] deps = ["zlib", "lzma"]
if ( if configInfo.build == "wasm" or neutralEnv("distname") == "Darwin":
configInfo.build in ("win32", "win64", "wasm")
or neutralEnv("distname") == "Darwin"
):
return deps return deps
return deps + ["uuid"] return deps + ["uuid"]

View File

@ -14,17 +14,14 @@ class ZimTools(Dependency):
@classmethod @classmethod
def get_dependencies(cls, configInfo, allDeps): def get_dependencies(cls, configInfo, allDeps):
base_deps = ["libzim", "docoptcpp", "mustache"] base_deps = ["libzim", "docoptcpp", "mustache"]
if configInfo.build != "win32" and neutralEnv("distname") != "Windows": if neutralEnv("distname") != "Windows":
base_deps += ["libmagic", "gumbo"] base_deps += ["libmagic", "gumbo"]
return base_deps return base_deps
@property @property
def configure_options(self): def configure_options(self):
# We don't build zimwriterfs on win32, and so we don't have magic # We don't build zimwriterfs on Windows, and so we don't have magic
if ( if neutralEnv("distname") != "Windows":
self.buildEnv.configInfo.build != "win32"
and neutralEnv("distname") != "Windows"
):
yield f"-Dmagic-install-prefix={self.buildEnv.install_dir}" yield f"-Dmagic-install-prefix={self.buildEnv.install_dir}"
if self.buildEnv.configInfo.static: if self.buildEnv.configInfo.static:
yield "-Dstatic-linkage=true" yield "-Dstatic-linkage=true"

View File

@ -50,7 +50,7 @@ PACKAGE_NAME_MAPPERS = {
}, },
"fedora_native_static": { "fedora_native_static": {
"COMMON": _fedora_common + ["glibc-static", "libstdc++-static"], "COMMON": _fedora_common + ["glibc-static", "libstdc++-static"],
"lzma": ["xz-devel", "xz-static"] "lzma": ["xz-devel", "xz-static"],
# Either there is no packages, or no static or too old # Either there is no packages, or no static or too old
}, },
"fedora_i586_dyn": { "fedora_i586_dyn": {
@ -59,33 +59,6 @@ PACKAGE_NAME_MAPPERS = {
"fedora_i586_static": { "fedora_i586_static": {
"COMMON": _fedora_common + ["glibc-devel.i686"], "COMMON": _fedora_common + ["glibc-devel.i686"],
}, },
"fedora_win32_dyn": {
"COMMON": _fedora_common
+ [
"mingw32-gcc-c++",
"mingw32-bzip2",
"mingw32-win-iconv",
"mingw32-winpthreads",
"wine",
],
"zlib": ["mingw32-zlib"],
"lzma": ["mingw32-xz-libs"],
"libmicrohttpd": ["mingw32-libmicrohttpd"],
},
"fedora_win32_static": {
"COMMON": _fedora_common
+ [
"mingw32-gcc-c++",
"mingw32-bzip2-static",
"mingw32-win-iconv-static",
"mingw32-winpthreads-static",
"wine",
],
"zlib": ["mingw32-zlib-static"],
"lzma": ["mingw32-xz-libs-static"],
"libmicrohttpd": None, # ['mingw32-libmicrohttpd-static'] packaging dependecy seems buggy, and some static lib are name libfoo.dll.a and
# gcc cannot found them.
},
"fedora_armhf_static": {"COMMON": _fedora_common}, "fedora_armhf_static": {"COMMON": _fedora_common},
"fedora_armhf_dyn": {"COMMON": _fedora_common}, "fedora_armhf_dyn": {"COMMON": _fedora_common},
"fedora_android": {"COMMON": _fedora_common}, "fedora_android": {"COMMON": _fedora_common},
@ -109,24 +82,6 @@ PACKAGE_NAME_MAPPERS = {
"COMMON": _debian_common "COMMON": _debian_common
+ ["libc6-dev-i386", "lib32stdc++6", "gcc-multilib", "g++-multilib"], + ["libc6-dev-i386", "lib32stdc++6", "gcc-multilib", "g++-multilib"],
}, },
"debian_win32_dyn": {
"COMMON": _debian_common
+ [
"g++-mingw-w64-i686",
"gcc-mingw-w64-i686",
"gcc-mingw-w64-base",
"mingw-w64-tools",
],
},
"debian_win32_static": {
"COMMON": _debian_common
+ [
"g++-mingw-w64-i686",
"gcc-mingw-w64-i686",
"gcc-mingw-w64-base",
"mingw-w64-tools",
],
},
"debian_armhf_static": { "debian_armhf_static": {
"COMMON": _debian_common, "COMMON": _debian_common,
}, },