From 8478d65c90c19276f1ebd83d144fb5f21be43ea3 Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Fri, 5 Jun 2020 14:20:50 +0000 Subject: [PATCH] enable compilation of native_mixed on macos Issue #349 requires a native_mixed for macOS. native_mixed is working for libzim so we whitelist it. On the release CI, we fix the macos dylib rpath so it doesn't include the full build-install step path which is probematic for a distributed file. We build native_mixed for OSX in both CI and release mode --- .github/scripts/build_release_nightly.py | 5 ++++- .github/scripts/common.py | 26 ++++++++++++++++++++---- .github/workflows/ci.yml | 1 + .github/workflows/releaseNigthly.yml | 1 + kiwixbuild/platforms/native.py | 2 +- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/scripts/build_release_nightly.py b/.github/scripts/build_release_nightly.py index 3dab6e8..15c863b 100755 --- a/.github/scripts/build_release_nightly.py +++ b/.github/scripts/build_release_nightly.py @@ -13,6 +13,7 @@ from common import ( create_desktop_image, update_flathub_git, upload_archive, + fix_macos_rpath, BASE_DIR, TMP_DIR, HOME, @@ -35,7 +36,7 @@ elif PLATFORM_TARGET.startswith("iOS"): TARGETS = ("libzim", "kiwix-lib") elif PLATFORM_TARGET.startswith("native_"): if OS_NAME == "osx": - TARGETS = ("libzim", "zimwriterfs", "zim-tools", "kiwix-lib") + TARGETS = ("libzim", ) if PLATFORM_TARGET == "native_mixed" else ("libzim", "zimwriterfs", "zim-tools", "kiwix-lib") else: if DESKTOP: TARGETS = ("kiwix-desktop",) @@ -59,6 +60,8 @@ for target in TARGETS: if target == "kiwix-desktop": archive = create_desktop_image(make_release=RELEASE) else: + if PLATFORM_TARGET == "native_mixed" and OS_NAME == "osx": + fix_macos_rpath(target) archive = make_archive(target, make_release=RELEASE) if archive: upload_archive(archive, target, make_release=RELEASE) diff --git a/.github/scripts/common.py b/.github/scripts/common.py index f8fe3e8..f83de8d 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -36,12 +36,14 @@ KIWIX_DESKTOP_ONLY = False _ref = _environ.get("GITHUB_REF", "").split("/")[-1] MAKE_RELEASE = re.fullmatch(r"r_[0-9]+", _ref) is not None +RELEASE_OS_NAME = "macos" if OS_NAME == "osx" else "linux" + PLATFORM_TO_RELEASE = { - "native_mixed": "linux-x86_64", - "native_static": "linux-x86_64", + "native_mixed": "{os}-x86_64".format(os=RELEASE_OS_NAME), + "native_static": "{os}-x86_64".format(os=RELEASE_OS_NAME), "win32_static": "win-i686", - "armhf_static": "linux-armhf", - "i586_static": "linux-i586", + "armhf_static": "{os}-armhf".format(os=RELEASE_OS_NAME), + "i586_static": "{os}-i586".format(os=RELEASE_OS_NAME), } FLATPAK_HTTP_GIT_REMOTE = "https://github.com/flathub/org.kiwix.desktop.git" @@ -81,6 +83,10 @@ EXPORT_FILES = { "lib/x86_64-linux-gnu/libzim.so.{}".format( main_project_versions["libzim"][0] ), + "lib/libzim.{}.dylib".format( + main_project_versions["libzim"][0] + ), + "lib/libzim.dylib", "include/zim/**/*.h", ), ), @@ -369,3 +375,15 @@ def update_flathub_git(): "SSH_KEY" ) call(command) + + +def fix_macos_rpath(project): + + base_dir, export_files = EXPORT_FILES[project] + for file in filter(lambda f: f.endswith(".dylib"), export_files): + lib = base_dir / file + if lib.is_symlink(): + continue + command = ["install_name_tool", "-id", lib.name, str(lib)] + print_message("call {}", " ".join(command)) + subprocess.check_call(command, env=os.environ) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54b7485..1dd260d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,6 +110,7 @@ jobs: matrix: target: - native_dyn + - native_mixed - iOS_arm64 - iOS_x86_64 runs-on: macos-latest diff --git a/.github/workflows/releaseNigthly.yml b/.github/workflows/releaseNigthly.yml index bfab9d1..6af9a2d 100644 --- a/.github/workflows/releaseNigthly.yml +++ b/.github/workflows/releaseNigthly.yml @@ -124,6 +124,7 @@ jobs: matrix: target: - native_dyn + - native_mixed runs-on: macos-latest env: SSH_KEY: /tmp/id_rsa diff --git a/kiwixbuild/platforms/native.py b/kiwixbuild/platforms/native.py index 539b9dd..4791115 100644 --- a/kiwixbuild/platforms/native.py +++ b/kiwixbuild/platforms/native.py @@ -21,7 +21,7 @@ class NativeStatic(NativePlatformInfo): class NativeMixed(NativePlatformInfo): name = 'native_mixed' static = False - compatible_hosts = ['fedora', 'debian'] + compatible_hosts = ['fedora', 'debian', 'Darwin'] def add_targets(self, targetName, targets): print(targetName)