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
This commit is contained in:
renaud gaudin 2020-06-05 14:20:50 +00:00
parent 077a410086
commit 8478d65c90
5 changed files with 29 additions and 6 deletions

View File

@ -13,6 +13,7 @@ from common import (
create_desktop_image, create_desktop_image,
update_flathub_git, update_flathub_git,
upload_archive, upload_archive,
fix_macos_rpath,
BASE_DIR, BASE_DIR,
TMP_DIR, TMP_DIR,
HOME, HOME,
@ -35,7 +36,7 @@ elif PLATFORM_TARGET.startswith("iOS"):
TARGETS = ("libzim", "kiwix-lib") TARGETS = ("libzim", "kiwix-lib")
elif PLATFORM_TARGET.startswith("native_"): elif PLATFORM_TARGET.startswith("native_"):
if OS_NAME == "osx": 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: else:
if DESKTOP: if DESKTOP:
TARGETS = ("kiwix-desktop",) TARGETS = ("kiwix-desktop",)
@ -59,6 +60,8 @@ for target in TARGETS:
if target == "kiwix-desktop": if target == "kiwix-desktop":
archive = create_desktop_image(make_release=RELEASE) archive = create_desktop_image(make_release=RELEASE)
else: else:
if PLATFORM_TARGET == "native_mixed" and OS_NAME == "osx":
fix_macos_rpath(target)
archive = make_archive(target, make_release=RELEASE) archive = make_archive(target, make_release=RELEASE)
if archive: if archive:
upload_archive(archive, target, make_release=RELEASE) upload_archive(archive, target, make_release=RELEASE)

View File

@ -36,12 +36,14 @@ KIWIX_DESKTOP_ONLY = False
_ref = _environ.get("GITHUB_REF", "").split("/")[-1] _ref = _environ.get("GITHUB_REF", "").split("/")[-1]
MAKE_RELEASE = re.fullmatch(r"r_[0-9]+", _ref) is not None 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 = { PLATFORM_TO_RELEASE = {
"native_mixed": "linux-x86_64", "native_mixed": "{os}-x86_64".format(os=RELEASE_OS_NAME),
"native_static": "linux-x86_64", "native_static": "{os}-x86_64".format(os=RELEASE_OS_NAME),
"win32_static": "win-i686", "win32_static": "win-i686",
"armhf_static": "linux-armhf", "armhf_static": "{os}-armhf".format(os=RELEASE_OS_NAME),
"i586_static": "linux-i586", "i586_static": "{os}-i586".format(os=RELEASE_OS_NAME),
} }
FLATPAK_HTTP_GIT_REMOTE = "https://github.com/flathub/org.kiwix.desktop.git" 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( "lib/x86_64-linux-gnu/libzim.so.{}".format(
main_project_versions["libzim"][0] main_project_versions["libzim"][0]
), ),
"lib/libzim.{}.dylib".format(
main_project_versions["libzim"][0]
),
"lib/libzim.dylib",
"include/zim/**/*.h", "include/zim/**/*.h",
), ),
), ),
@ -369,3 +375,15 @@ def update_flathub_git():
"SSH_KEY" "SSH_KEY"
) )
call(command) 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)

View File

@ -110,6 +110,7 @@ jobs:
matrix: matrix:
target: target:
- native_dyn - native_dyn
- native_mixed
- iOS_arm64 - iOS_arm64
- iOS_x86_64 - iOS_x86_64
runs-on: macos-latest runs-on: macos-latest

View File

@ -124,6 +124,7 @@ jobs:
matrix: matrix:
target: target:
- native_dyn - native_dyn
- native_mixed
runs-on: macos-latest runs-on: macos-latest
env: env:
SSH_KEY: /tmp/id_rsa SSH_KEY: /tmp/id_rsa

View File

@ -21,7 +21,7 @@ class NativeStatic(NativePlatformInfo):
class NativeMixed(NativePlatformInfo): class NativeMixed(NativePlatformInfo):
name = 'native_mixed' name = 'native_mixed'
static = False static = False
compatible_hosts = ['fedora', 'debian'] compatible_hosts = ['fedora', 'debian', 'Darwin']
def add_targets(self, targetName, targets): def add_targets(self, targetName, targets):
print(targetName) print(targetName)