Move the release platform name in the build definition.

Having the name of the archive define in common is splitting definition
in different files.

The purpose of build_definition is to centralize definition, so move them
there.
This commit is contained in:
Matthieu Gautier 2023-07-26 15:28:50 +02:00
parent 7e9a145bc5
commit 46c663db09
2 changed files with 60 additions and 69 deletions

View File

@ -15,48 +15,49 @@ import csv, io, re
# 'D' letter means we trigger the docker forkflow to build the docker image. # 'D' letter means we trigger the docker forkflow to build the docker image.
# If a cell contains several letters, all are done. # If a cell contains several letters, all are done.
BUILD_DEF = """ BUILD_DEF = """
| OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop | | OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop | platform_name |
============================================================================================== =====================================================================================================================
# Bionic is a special case as we need to compile libzim on old arch for python # Bionic is a special case as we need to compile libzim on old arch for python
| bionic | | BP | | | | | | bionic | native_mixed | BP | | | | | linux-x86_64-bionic |
---------------------------------------------------------------------------------------------- | bionic | aarch64_mixed | BP | | | | | linux-aarch64-bionic |
--------------------------------------------------------------------------------------------------------------------
# Osx builds, build binaries on native_dyn and native_static. On anyother things, build only the libraries # Osx builds, build binaries on native_dyn and native_static. On anyother things, build only the libraries
| macos | native_dyn | d | d | dB | B | | | macos | native_dyn | d | d | dB | B | | |
| macos | native_static | | | BP | BP | | | macos | native_static | | | BP | BP | | macos-x86_64 |
| macos | native_mixed | BP | BP | | | | | macos | native_mixed | BP | BP | | | | macos-x86_64 |
| macos | iOS_arm64 | dB | B | | | | | macos | iOS_arm64 | dB | B | | | | |
| macos | iOS_x86_64 | dB | B | | | | | macos | iOS_x86_64 | dB | B | | | | |
| macos | iOS_Mac_ABI | B | B | | | | | macos | iOS_Mac_ABI | B | B | | | | |
| macos | macOS_arm64_static | | | | | | | macos | macOS_arm64_static | | | | | | |
| macos | macOS_arm64_mixed | BP | BP | | | | | macos | macOS_arm64_mixed | BP | BP | | | | macos-arm64 |
| macos | macOS_x86_64 | B | B | | | | | macos | macOS_x86_64 | B | B | | | | |
---------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------
| | flatpak | | | | | BP | | | flatpak | | | | | BP | |
| | native_static | d | d | dBPSD | dBPSD | | | | native_static | d | d | dBPSD | dBPSD | | linux-x86_64 |
| | native_dyn | d | d | dB | dB | BPS | | | native_dyn | d | d | dB | dB | BPS | |
| | native_mixed | BPS | BPS | | | | | | native_mixed | BPS | BPS | | | | linux-x86_64 |
# libzim CI is building alpine_dyn but not us # libzim CI is building alpine_dyn but not us
| | android_arm | dBP | dBP | | | | | | android_arm | dBP | dBP | | | | android-arm |
| | android_arm64 | dBP | dBP | | | | | | android_arm64 | dBP | dBP | | | | android-arm64 |
| | android_x86 | BP | BP | | | | | | android_x86 | BP | BP | | | | android-x86 |
| | android_x86_64 | BP | BP | | | | | | android_x86_64 | BP | BP | | | | android-x86_64 |
| | armv6_static | | | BP | BP | | | | armv6_static | | | BP | BP | | linux-armv6 |
| | armv6_dyn | | | B | B | | | | armv6_dyn | | | B | B | | |
| | armv6_mixed | BP | | | | | | | armv6_mixed | BP | | | | | linux-armv6 |
| | armv8_static | | | BP | BP | | | | armv8_static | | | BP | BP | | linux-armv8 |
| | armv8_dyn | | | B | B | | | | armv8_dyn | | | B | B | | |
| | armv8_mixed | BP | | | | | | | armv8_mixed | BP | | | | | linux-armv8 |
| | aarch64_static | | | BP | BP | | | | aarch64_static | | | BP | BP | | linux-aarch64 |
| | aarch64_dyn | d | | B | B | | | | aarch64_dyn | d | | B | B | | |
| | aarch64_mixed | BP | | | | | | | aarch64_mixed | BP | | | | | linux-aarch64 |
| | aarch64_musl_static| | | BP | BP | | | | aarch64_musl_static| | | BP | BP | | linux-aarch64-musl |
| | aarch64_musl_dyn | d | | B | B | | | | aarch64_musl_dyn | d | | B | B | | |
| | aarch64_musl_mixed | BP | | | | | | | aarch64_musl_mixed | BP | | | | | linux-aarch64-musl |
| | win32_static | d | dB | dBP | dBP | | | | win32_static | d | dB | dBP | dBP | | win-i686 |
| | win32_dyn | d | dB | dB | dB | | | | win32_dyn | d | dB | dB | dB | | |
| | i586_static | | | BP | BP | | | | i586_static | | | BP | BP | | linux-i586 |
| | i586_dyn | | | B | B | | | | i586_dyn | | | B | B | | |
| | wasm | dBP | | | | | | | wasm | dBP | | | | | wasm-emscripten |
""" """
@ -128,3 +129,16 @@ def select_build_targets(criteria):
return build_order return build_order
raise "No definition match with current context." raise "No definition match with current context."
def get_platform_name():
from common import PLATFORM_TARGET, OS_NAME
context = Context(PLATFORM_TARGET=PLATFORM_TARGET, OS_NAME=OS_NAME)
reader = csv.DictReader(strip_array(BUILD_DEF), dialect=TableDialect())
for row in reader:
if context.match(row):
name = row["platform_name"]
return name or None
raise "No definition match with current context."

View File

@ -10,12 +10,16 @@ import shutil
import requests import requests
from build_definition import get_platform_name
from kiwixbuild.versions import ( from kiwixbuild.versions import (
main_project_versions, main_project_versions,
release_versions, release_versions,
base_deps_versions, base_deps_versions,
) )
PLATFORM_TARGET = _environ["PLATFORM_TARGET"] PLATFORM_TARGET = _environ["PLATFORM_TARGET"]
OS_NAME = _environ["OS_NAME"] OS_NAME = _environ["OS_NAME"]
HOME = Path(os.path.expanduser("~")) HOME = Path(os.path.expanduser("~"))
@ -36,31 +40,6 @@ if not MAKE_RELEASE and _ref != "main":
else: else:
DEV_BRANCH = None DEV_BRANCH = None
RELEASE_OS_NAME = "macos" if OS_NAME == "macos" else "linux"
EXTRA_NAME = "-bionic" if OS_NAME == "bionic" else ""
PLATFORM_TO_RELEASE = {
"native_mixed": "{os}-x86_64{extra}".format(os=RELEASE_OS_NAME, extra=EXTRA_NAME),
"native_static": "{os}-x86_64".format(os=RELEASE_OS_NAME),
"win32_static": "win-i686",
"armv6_static": "{os}-armv6".format(os=RELEASE_OS_NAME),
"armv6_mixed": "{os}-armv6".format(os=RELEASE_OS_NAME),
"armv8_static": "{os}-armv8".format(os=RELEASE_OS_NAME),
"armv8_mixed": "{os}-armv8".format(os=RELEASE_OS_NAME),
"aarch64_static": "{os}-aarch64".format(os=RELEASE_OS_NAME),
"aarch64_mixed": "{os}-aarch64{extra}".format(os=RELEASE_OS_NAME, extra=EXTRA_NAME),
"aarch64_musl_static": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME),
"aarch64_musl_mixed": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME),
"i586_static": "{os}-i586".format(os=RELEASE_OS_NAME),
"macOS_arm64_static": "{os}-arm64".format(os=RELEASE_OS_NAME),
"macOS_arm64_mixed": "{os}-arm64".format(os=RELEASE_OS_NAME),
"android_arm": "android-arm",
"android_arm64": "android-arm64",
"android_x86": "android-x86",
"android_x86_64": "android-x86_64",
"wasm": "wasm-emscripten",
}
FLATPAK_HTTP_GIT_REMOTE = "https://github.com/flathub/org.kiwix.desktop.git" FLATPAK_HTTP_GIT_REMOTE = "https://github.com/flathub/org.kiwix.desktop.git"
FLATPAK_GIT_REMOTE = "git@github.com:flathub/org.kiwix.desktop.git" FLATPAK_GIT_REMOTE = "git@github.com:flathub/org.kiwix.desktop.git"
@ -351,10 +330,8 @@ def get_postfix(project):
def make_archive(project, make_release): def make_archive(project, make_release):
try: platform_name = get_platform_name()
platform = PLATFORM_TO_RELEASE[PLATFORM_TARGET] if not platform_name:
except KeyError:
# We don't know how to name the release.
return None return None
try: try:
@ -368,12 +345,12 @@ def make_archive(project, make_release):
else: else:
postfix = DATE postfix = DATE
archive_name = "{}_{}-{}".format(project, platform, postfix) archive_name = "{}_{}-{}".format(project, platform_name, postfix)
files_to_archive = [] files_to_archive = []
for export_file in export_files: for export_file in export_files:
files_to_archive.extend(base_dir.glob(export_file)) files_to_archive.extend(base_dir.glob(export_file))
if platform == "win-i686": if platform_name == "win-i686":
open_archive = lambda a: zipfile.ZipFile( open_archive = lambda a: zipfile.ZipFile(
str(a), "w", compression=zipfile.ZIP_DEFLATED str(a), "w", compression=zipfile.ZIP_DEFLATED
) )