From afda1f6673795544246a5327c2ea0218aa9f4a08 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 2 Apr 2024 16:27:19 +0200 Subject: [PATCH] =?UTF-8?q?Make=20CI=C2=A0common=20script=20use=20the=20co?= =?UTF-8?q?rrect=20build=20dir.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add an option to kiwix-build to get it. --- .github/scripts/common.py | 34 ++++++++++++++++++++++------------ kiwixbuild/__init__.py | 8 +++++++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.github/scripts/common.py b/.github/scripts/common.py index 7024332..cb668ef 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -20,11 +20,23 @@ from kiwixbuild.versions import ( ) +def get_build_dir(config) -> Path: + command = ["kiwix-build"] + command.extend(["--config", config]) + command.append("--get-build-dir") + command.append("--use-target-arch-name") + return Path( + subprocess.run(command, cwd=str(HOME), check=True, stdout=subprocess.PIPE) + .stdout[:-1] + .decode("utf8") + ) + + COMPILE_CONFIG = _environ["COMPILE_CONFIG"] OS_NAME = _environ["OS_NAME"] HOME = Path(os.path.expanduser("~")) -BASE_DIR = HOME / "BUILD_{}".format(COMPILE_CONFIG) +BASE_DIR = get_build_dir(COMPILE_CONFIG) SOURCE_DIR = HOME / "SOURCE" ARCHIVE_DIR = HOME / "ARCHIVE" TOOLCHAIN_DIR = BASE_DIR / "TOOLCHAINS" @@ -283,19 +295,17 @@ def make_deps_archive(target=None, name=None, full=False): files_to_archive += HOME.glob("BUILD_*/LOGS") if COMPILE_CONFIG == "apple_all_static": for subconfig in AppleXCFramework.subConfigNames: - base_dir = HOME / "BUILD_{}".format(subconfig) + base_dir = get_build_dir(subconfig) files_to_archive += filter_install_dir(base_dir / "INSTALL") if (base_dir / "meson_cross_file.txt").exists(): files_to_archive.append(base_dir / "meson_cross_file.txt") if COMPILE_CONFIG.endswith("_mixed"): static_config = COMPILE_CONFIG.replace("_mixed", "_static") - files_to_archive += filter_install_dir( - HOME / ("BUILD_" + static_config) / "INSTALL" - ) + files_to_archive += filter_install_dir(get_build_dir(static_config) / "INSTALL") if COMPILE_CONFIG.startswith("android_"): files_to_archive += filter_install_dir(HOME / "BUILD_neutral" / "INSTALL") - base_dir = HOME / "BUILD_{}".format(COMPILE_CONFIG) + base_dir = get_build_dir(COMPILE_CONFIG) if (base_dir / "meson_cross_file.txt").exists(): files_to_archive.append(base_dir / "meson_cross_file.txt") # Copy any toolchain @@ -315,13 +325,13 @@ def make_deps_archive(target=None, name=None, full=False): # Add also static build for mixed target if COMPILE_CONFIG.endswith("_mixed"): static_config = COMPILE_CONFIG.replace("_mixed", "_static") - files_to_archive += (HOME / ("BUILD_" + static_config)).glob("*/.*_ok") + files_to_archive += get_build_dir(static_config).glob("*/.*_ok") # Native dyn and static is needed for potential cross compilation that use native tools (icu) - files_to_archive += (HOME / "BUILD_native_dyn").glob("*/.*_ok") - files_to_archive += (HOME / "BUILD_native_static").glob("*/.*_ok") - files_to_archive += HOME.glob("BUILD_android*/**/.*_ok") - files_to_archive += HOME.glob("BUILD_macOS*/**/.*_ok") - files_to_archive += HOME.glob("BUILD_iOS*/**/.*_ok") + files_to_archive += get_build_dir("native_dyn").glob("*/.*_ok") + files_to_archive += get_build_dir("native_static").glob("*/.*_ok") + files_to_archive += HOME.glob("BUILD_*android*/**/.*_ok") + files_to_archive += HOME.glob("BUILD_*apple-macos*/**/.*_ok") + files_to_archive += HOME.glob("BUILD_*apple-ios*/**/.*_ok") files_to_archive += SOURCE_DIR.glob("*/.*_ok") files_to_archive += SOURCE_DIR.glob("zim-testing-suite-*/*") diff --git a/kiwixbuild/__init__.py b/kiwixbuild/__init__.py index 5b1b878..8e5f645 100644 --- a/kiwixbuild/__init__.py +++ b/kiwixbuild/__init__.py @@ -137,6 +137,9 @@ def parse_args(): "Intended to be used in CI only." ), ) + subgroup.add_argument( + "--get-build-dir", action="store_true", help="Print the output directory." + ) options = parser.parse_args() if not options.android_arch: @@ -157,4 +160,7 @@ def main(): builder = FlatpakBuilder() else: builder = Builder() - builder.run() + if options.get_build_dir: + print(ConfigInfo.get_config(options.config).buildEnv.build_dir) + else: + builder.run()