diff --git a/.github/scripts/common.py b/.github/scripts/common.py index 85d96bd..7024332 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -161,6 +161,7 @@ def run_kiwix_build( command.append("--hide-progress") command.append("--fast-clone") command.append("--assume-packages-installed") + command.append("--use-target-arch-name") command.extend(["--config", config]) if build_deps_only: command.append("--build-deps-only") diff --git a/kiwixbuild/__init__.py b/kiwixbuild/__init__.py index 33f2926..5b1b878 100644 --- a/kiwixbuild/__init__.py +++ b/kiwixbuild/__init__.py @@ -125,6 +125,18 @@ def parse_args(): "to develop with the cloned sources." ), ) + subgroup.add_argument( + "--use-target-arch-name", + action="store_true", + help=( + "Name the build directory using the arch name instead of the config name.\n" + "Different configs may create binary for the same arch so this option is " + "not recommended when working with several config on the same computer.\n" + "However, when generating dependencies for other it is better to have a " + "directory named using the target instead of the used config.\n" + "Intended to be used in CI only." + ), + ) options = parser.parse_args() if not options.android_arch: diff --git a/kiwixbuild/buildenv.py b/kiwixbuild/buildenv.py index 37fe7fc..50552b2 100644 --- a/kiwixbuild/buildenv.py +++ b/kiwixbuild/buildenv.py @@ -76,9 +76,12 @@ class NeutralEnv: class BuildEnv: def __init__(self, configInfo): - build_dir = "BUILD_{}".format(configInfo.name) self.configInfo = configInfo self.base_build_dir = pj(option("working_dir"), option("build_dir")) + build_dir = ( + configInfo.arch_name if option("use_target_arch_name") else configInfo.name + ) + build_dir = f"BUILD_{build_dir}" self.build_dir = pj(self.base_build_dir, build_dir) self.install_dir = pj(self.build_dir, "INSTALL") self.toolchain_dir = pj(self.build_dir, "TOOLCHAINS") diff --git a/kiwixbuild/configs/android.py b/kiwixbuild/configs/android.py index 51d6d91..9374944 100644 --- a/kiwixbuild/configs/android.py +++ b/kiwixbuild/configs/android.py @@ -147,6 +147,10 @@ class Android(MetaConfigInfo): name = "android" compatible_hosts = ["fedora", "debian"] + @property + def arch_name(self): + return "multi-linux-android" + @property def subConfigNames(self): return ["android_{}".format(arch) for arch in option("android_arch")] diff --git a/kiwixbuild/configs/base.py b/kiwixbuild/configs/base.py index 43798f2..883f1f7 100644 --- a/kiwixbuild/configs/base.py +++ b/kiwixbuild/configs/base.py @@ -27,6 +27,10 @@ class ConfigInfo(metaclass=_MetaConfig): mixed = False libdir = None + @property + def arch_name(self): + return self.arch_full + @classmethod def get_config(cls, name, targets=None): if name not in cls.all_running_configs: diff --git a/kiwixbuild/configs/flatpak.py b/kiwixbuild/configs/flatpak.py index a49acdd..f481a5d 100644 --- a/kiwixbuild/configs/flatpak.py +++ b/kiwixbuild/configs/flatpak.py @@ -4,6 +4,7 @@ from kiwixbuild._global import option, neutralEnv class FlatpakConfigInfo(ConfigInfo): name = "flatpak" + arch_name = "flatpak" build = "flatpak" static = "" toolchain_names = ["org.kde", "io.qt.qtwebengine"] diff --git a/kiwixbuild/configs/ios.py b/kiwixbuild/configs/ios.py index bce93a3..62a9c1f 100644 --- a/kiwixbuild/configs/ios.py +++ b/kiwixbuild/configs/ios.py @@ -24,6 +24,10 @@ class AppleConfigInfo(ConfigInfo): super().__init__(*args, **kwargs) self._root_path = None + @property + def arch_name(self): + return self.target + @property def root_path(self): if self._root_path is None: @@ -209,6 +213,10 @@ class IOS(MetaConfigInfo): name = "iOS_multi" compatible_hosts = ["Darwin"] + @property + def arch_name(self): + return self.name + @property def subConfigNames(self): return ["iOS_{}".format(arch) for arch in option("ios_arch")] @@ -225,6 +233,10 @@ class AppleStaticAll(MetaConfigInfo): name = "apple_all_static" compatible_hosts = ["Darwin"] + @property + def arch_name(self): + return self.name + @property def subConfigNames(self): return AppleXCFramework.subConfigNames diff --git a/kiwixbuild/configs/native.py b/kiwixbuild/configs/native.py index 6bf3e36..f8ab8ef 100644 --- a/kiwixbuild/configs/native.py +++ b/kiwixbuild/configs/native.py @@ -3,6 +3,9 @@ from .base import ConfigInfo, MixedMixin from kiwixbuild.utils import pj from kiwixbuild._global import option, neutralEnv from kiwixbuild.configs.ios import MIN_MACOS_VERSION +import sysconfig +import platform +import sys class NativeConfigInfo(ConfigInfo): @@ -16,6 +19,12 @@ class NativeConfigInfo(ConfigInfo): env["CFLAGS"] += f"-mmacosx-version-min={MIN_MACOS_VERSION}" return env + @property + def arch_name(self): + if sys.platform == "darwin": + return f"{platform.machine()}-apple-darwin" + return sysconfig.get_platform() + class NativeDyn(NativeConfigInfo): name = "native_dyn" diff --git a/kiwixbuild/configs/neutral.py b/kiwixbuild/configs/neutral.py index f5ae53e..f237c48 100644 --- a/kiwixbuild/configs/neutral.py +++ b/kiwixbuild/configs/neutral.py @@ -3,6 +3,7 @@ from .base import ConfigInfo class NeutralConfigInfo(ConfigInfo): name = "neutral" + arch_name = "neutral" static = "" compatible_hosts = ["fedora", "debian", "Darwin"]