Build CoreKiwix.xcframework

CoreKiwix.xcframework is the packaging format required by Kiwix apple (macOS/iOS) reader for libkiwix.
Naming will hopefully be revisited later (libkiwix.xcframework?)

This folder is a combination of all static archive (*.a): dependencies and libkiwix itself
for all apple-supported platforms: macOS x86_64, macOS arm64, iOS arm64 and iOS x86_64.
It also includes the headers.
Note: while iOS archs are separated in the framework, the macOS archs are bundled as a fat binary.

This thus adds:

- A new `apple_all_static` target that lists mentioned sub-platforms.
- A new `AppleXCFramework` virtual dependency and builder
  -  requires `libkiwix`
  - merges the archives into one per target
  - creates the fat binary for macOS
  - creates the xcframework
- `libkiwix_xcframework-VERSION.tar.gz` because platformname is xcframework
  - it only contains the xcframework but in libkiwix_xcframework-VERSION/lib folder
    Because with this virtual target, there are no other files
  - requires a new `xcframework` platform_name in builddef
- subplatforms deps and macOS/iOS _ok files to make_deps_archive

---

https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle
This commit is contained in:
renaud gaudin
2023-11-09 14:06:51 +00:00
parent 6cfbd0c297
commit a063b91349
6 changed files with 131 additions and 0 deletions

View File

@ -30,6 +30,7 @@ BUILD_DEF = """
| macos | macOS_arm64_static | | | BP | BP | | macos-arm64 |
| macos | macOS_arm64_mixed | BP | BP | | | | macos-arm64 |
| macos | macOS_x86_64 | B | B | | | | |
| macos | apple_all_static | | BP | | | | xcframework |
----------------------------------------------------------------------------------------------
| | flatpak | | | | | BP | |
| | native_static | d | d | dBPSD | dBPSD | | linux-x86_64 |

View File

@ -12,6 +12,7 @@ import requests
from build_definition import get_platform_name
from kiwixbuild.dependencies.apple_xcframework import AppleXCFramework
from kiwixbuild.versions import (
main_project_versions,
release_versions,
@ -102,6 +103,7 @@ EXPORT_FILES = {
"libkiwix": (
INSTALL_DIR,
(
"lib/CoreKiwix.xcframework/",
"lib/*/libkiwix.so",
"lib/*/libkiwix.so.{version}".format(
version=main_project_versions["libkiwix"]
@ -279,6 +281,13 @@ def make_deps_archive(target=None, name=None, full=False):
print_message("Create archive {}.", archive_name)
files_to_archive = list(filter_install_dir(INSTALL_DIR))
files_to_archive += HOME.glob("BUILD_*/LOGS")
if PLATFORM_TARGET == "apple_all_static":
for subplatform in AppleXCFramework.subPlatformNames:
base_dir = HOME / "BUILD_{}".format(subplatform)
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 PLATFORM_TARGET.endswith("_mixed"):
static_platform = PLATFORM_TARGET.replace("_mixed", "_static")
files_to_archive += filter_install_dir(HOME / ("BUILD_" + static_platform) / "INSTALL")
@ -309,6 +318,8 @@ def make_deps_archive(target=None, name=None, full=False):
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 += SOURCE_DIR.glob("*/.*_ok")
files_to_archive += SOURCE_DIR.glob("zim-testing-suite-*/*")