From e7250fea9fc4a8828a4cdb196f39f286df3204a3 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Tue, 9 May 2023 23:56:27 +0000 Subject: [PATCH] [libzim]add package (#30758) * libzim: add package update libzim versions libzim:meson ignore xapian * Update ports/libzim/vcpkg.json Co-authored-by: Mengna Li <95600143+Adela0814@users.noreply.github.com> * Update ports/libzim/portfile.cmake Co-authored-by: Mengna Li <95600143+Adela0814@users.noreply.github.com> * support both static and dynamic library * modify according to review Update ports/libzim/portfile.cmake Co-authored-by: Mengna Li <95600143+Adela0814@users.noreply.github.com> add version * only enable release library * make xapian does not support on windows * disable android platform --------- Co-authored-by: Mengna Li <95600143+Adela0814@users.noreply.github.com> --- ports/libzim/0001-build-share-library.patch | 26 +++++++++++++++ ports/libzim/portfile.cmake | 37 +++++++++++++++++++++ ports/libzim/vcpkg.json | 26 +++++++++++++++ versions/baseline.json | 4 +++ versions/l-/libzim.json | 9 +++++ 5 files changed, 102 insertions(+) create mode 100644 ports/libzim/0001-build-share-library.patch create mode 100644 ports/libzim/portfile.cmake create mode 100644 ports/libzim/vcpkg.json create mode 100644 versions/l-/libzim.json diff --git a/ports/libzim/0001-build-share-library.patch b/ports/libzim/0001-build-share-library.patch new file mode 100644 index 0000000000..b25326b971 --- /dev/null +++ b/ports/libzim/0001-build-share-library.patch @@ -0,0 +1,26 @@ +diff --git a/meson.build b/meson.build +index 6862f75..d887f9a 100644 +--- a/meson.build ++++ b/meson.build +@@ -37,8 +37,6 @@ static_linkage = static_linkage or get_option('default_library')=='static' + lzma_dep = dependency('liblzma', static:static_linkage) + if static_linkage + add_project_arguments('-DLZMA_API_STATIC', language: 'cpp') +-else +- private_conf.set('LIBZIM_EXPORT_DLL', true) + endif + + zstd_dep = dependency('libzstd', static:static_linkage) +@@ -59,6 +57,9 @@ pkg_requires = ['liblzma', 'libzstd'] + if build_machine.system() == 'windows' + extra_link_args = ['-lRpcrt4', '-lWs2_32', '-lwinmm', '-licuuc', '-licuin'] + extra_cpp_args = ['-DSORTPP_PASS'] ++ if not static_linkage ++ extra_cpp_args += ['-DLIBZIM_EXPORT_DLL'] ++ endif + else + extra_link_args = [] + extra_cpp_args = [] +-- +2.37.3.windows.1 + diff --git a/ports/libzim/portfile.cmake b/ports/libzim/portfile.cmake new file mode 100644 index 0000000000..83bfd7fc3b --- /dev/null +++ b/ports/libzim/portfile.cmake @@ -0,0 +1,37 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO openzim/libzim + REF ${VERSION} + SHA512 4554a9237f5167f6f94aad76ef0e847e949c47c6ee2a89bbd6e587da3b3a3e2d0a8b2d03f7a0fbde0e0dc96fb61bf8c115b3ef3cbd7eff5e880f152bee9b29f0 + HEAD_REF main + PATCHES + 0001-build-share-library.patch +) + +set(EXTRA_OPTIONS "") + +if(NOT "xapian" IN_LIST FEATURES) + list(APPEND EXTRA_OPTIONS "-Dwith_xapian=false") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND EXTRA_OPTIONS "-Dstatic-linkage=false") +else() + list(APPEND EXTRA_OPTIONS "-Dstatic-linkage=true") +endif() + +vcpkg_configure_meson( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -Dexamples=false + ${EXTRA_OPTIONS} +) + +vcpkg_install_meson(ADD_BIN_TO_PATH) + +vcpkg_copy_pdbs() + +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/ports/libzim/vcpkg.json b/ports/libzim/vcpkg.json new file mode 100644 index 0000000000..c949aaf4fd --- /dev/null +++ b/ports/libzim/vcpkg.json @@ -0,0 +1,26 @@ +{ + "name": "libzim", + "version": "8.2.0", + "description": "The Libzim is the reference implementation for the ZIM file format. It's a software library to read and write ZIM files on many systems and architectures. More information about the ZIM format and the openZIM project at https://openzim.org/.", + "homepage": "https://github.com/openzim/libzim", + "license": "GPL-2.0-or-later", + "supports": "!android", + "dependencies": [ + "icu", + "liblzma", + { + "name": "vcpkg-tool-meson", + "host": true + }, + "zstd" + ], + "features": { + "xapian": { + "description": "Enable xapian support", + "supports": "!(windows & !mingw)", + "dependencies": [ + "xapian" + ] + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index 7827520e46..736c570b80 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4836,6 +4836,10 @@ "baseline": "0.4.41", "port-version": 0 }, + "libzim": { + "baseline": "8.2.0", + "port-version": 0 + }, "libzip": { "baseline": "1.9.2", "port-version": 1 diff --git a/versions/l-/libzim.json b/versions/l-/libzim.json new file mode 100644 index 0000000000..a0f5cc6ba6 --- /dev/null +++ b/versions/l-/libzim.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "93b2790850e120148daf03563e24e6ed3ee9e02e", + "version": "8.2.0", + "port-version": 0 + } + ] +}