|
| 1 | +# Template file for 'libpdfium' |
| 2 | +# Updating libpdfium might break ABI, so make sure all dependents get rebuilt (e.g. pypdfium2) |
| 3 | +pkgname=libpdfium |
| 4 | +version=7659 |
| 5 | +revision=1 |
| 6 | +_commit_pdfium="1c78362d2fd58803037befd37e5649fef3b3dcdc" |
| 7 | +_commit_build="967506e40f93df1d46f0ded7c12c0cd7a58f01f7" |
| 8 | +_commit_buildtools="6a18683f555b4ac8b05ac8395c29c84483ac9588" |
| 9 | +_release_fast_float="8.2.2" |
| 10 | +hostmakedepends="python3 ninja gn pkg-config tar" |
| 11 | +makedepends="libjpeg-turbo-devel icu-devel libopenjpeg2-devel freetype-devel |
| 12 | + glib-devel abseil-cpp-devel lcms2-devel libpng-devel zlib-devel" |
| 13 | +short_desc="Google PDF rendering library" |
| 14 | +maintainer="Mateusz Sylwestrzak <slymattz@gmail.com>" |
| 15 | +license="Apache-2.0" |
| 16 | +homepage="https://pdfium.googlesource.com/pdfium" |
| 17 | +distfiles=" |
| 18 | + https://pdfium.googlesource.com/pdfium/+archive/${_commit_pdfium}.tar.gz>pdfium-${version}.tar.gz |
| 19 | + https://chromium.googlesource.com/chromium/src/build/+archive/${_commit_build}.tar.gz>build-${version}.tar.gz |
| 20 | + https://chromium.googlesource.com/chromium/src/buildtools/+archive/${_commit_buildtools}.tar.gz>buildtools-${version}.tar.gz |
| 21 | + https://github.com/fastfloat/fast_float/archive/refs/tags/v${_release_fast_float}.tar.gz>fast_float.tar.gz" |
| 22 | +checksum="@a95045e880ba851d1601030c5d3ea7bab440984dbd0532b26e66216c8d573ef2 |
| 23 | + @c0b0c894d912ec777e87b7e3184bc34d5c9125965daf662a6eaba1ca65ea0b94 |
| 24 | + @93dc381113745090ab300e90acbbc6cc6b3d055b80f6020791f78ae3042f6dbb |
| 25 | + e64b5fff88e04959154adbd5fb83331d91f2e04ac06454671cdfcbdff172b158" |
| 26 | +skip_extraction="build-${version}.tar.gz buildtools-${version}.tar.gz fast_float.tar.gz" |
| 27 | + |
| 28 | +post_extract() { |
| 29 | + mkdir -p build buildtools third_party/fast_float/src \ |
| 30 | + third_party/icu third_party/abseil-cpp |
| 31 | + |
| 32 | + local _dist="${XBPS_SRCDISTDIR}/${pkgname}-${version}" |
| 33 | + tar -xf "${_dist}/build-${version}.tar.gz" -C build |
| 34 | + tar -xf "${_dist}/buildtools-${version}.tar.gz" -C buildtools |
| 35 | + tar -xf "${_dist}/fast_float.tar.gz" -C third_party/fast_float/src --strip-components=1 |
| 36 | + |
| 37 | + # Mock testing targets to satisfy internal dependencies |
| 38 | + rm -f testing/BUILD.gn |
| 39 | + for g in pdfium_test path_service embedder_test_support unit_test_support test_support pixel_diff_utils; do |
| 40 | + echo "group(\"$g\") {}" >> testing/BUILD.gn |
| 41 | + done |
| 42 | + |
| 43 | + cat > build/config/gclient_args.gni <<-EOF |
| 44 | + checkout_google_benchmark = false |
| 45 | + checkout_nacl = false |
| 46 | + EOF |
| 47 | + |
| 48 | + cat > build_overrides/build.gni <<-EOF |
| 49 | + build_with_chromium = false |
| 50 | + use_system_libcxx = true |
| 51 | + EOF |
| 52 | + |
| 53 | + # System shim for ICU |
| 54 | + cat > third_party/icu/BUILD.gn <<-EOF |
| 55 | + import("//build/config/linux/pkg_config.gni") |
| 56 | + pkg_config("icu_config") { packages = [ "icu-uc", "icu-i18n" ] } |
| 57 | + group("icuuc") { public_configs = [ ":icu_config" ] } |
| 58 | + group("icui18n") { public_configs = [ ":icu_config" ] } |
| 59 | +EOF |
| 60 | + |
| 61 | + # System shim for Abseil |
| 62 | + cat > third_party/abseil-cpp/BUILD.gn <<-EOF |
| 63 | + import("//build/config/linux/pkg_config.gni") |
| 64 | + pkg_config("absl_config") { |
| 65 | + packages = [ |
| 66 | + "absl_base", "absl_int128", "absl_strings", "absl_hash", |
| 67 | + "absl_synchronization", "absl_raw_hash_set", |
| 68 | + "absl_low_level_hash", "absl_raw_logging_internal" |
| 69 | + ] |
| 70 | + } |
| 71 | + group("absl") { public_configs = [ ":absl_config" ] } |
| 72 | +EOF |
| 73 | +} |
| 74 | + |
| 75 | +post_patch() { |
| 76 | + # Transform internal paths to system-wide include style |
| 77 | + find core -type f \( -name "*.cpp" -o -name "*.h" \) -exec sed -i \ |
| 78 | + -e 's|#include "third_party/abseil-cpp/\(.*\)"|#include <\1>|g' \ |
| 79 | + -e 's|#include "third_party/icu/source/common/\(.*\)"|#include <\1>|g' \ |
| 80 | + -e 's|#include "third_party/icu/source/i18n/\(.*\)"|#include <\1>|g' {} + |
| 81 | + |
| 82 | + # Strip ARM64-specific strictness that breaks build for this arch |
| 83 | + vsed -i build/config/compiler/BUILD.gn \ |
| 84 | + -e 's/-Wl,--fatal-warnings/-Wl,--no-fatal-warnings/g' |
| 85 | + |
| 86 | + # Map build-system toolchain to XBPS environment |
| 87 | + vsed -i build/toolchain/linux/BUILD.gn \ |
| 88 | + -e '/toolprefix =/d' \ |
| 89 | + -e "s|cc = \".*gcc\"|cc = \"${CC}\"|g" \ |
| 90 | + -e "s|cxx = \".*g++\"|cxx = \"${CXX}\"|g" \ |
| 91 | + -e "s|ar = \".*ar\"|ar = \"${AR}\"|g" \ |
| 92 | + -e "s|nm = \".*nm\"|nm = \"${NM}\"|g" \ |
| 93 | + -e "s|readelf = \".*readelf\"|readelf = \"${READELF}\"|g" |
| 94 | + |
| 95 | + vsed -i build/config/compiler/BUILD.gn \ |
| 96 | + -e '1i declare_args() { extra_cflags="" extra_cppflags="" extra_ldflags="" }' |
| 97 | +} |
| 98 | + |
| 99 | +do_configure() { |
| 100 | + case "$XBPS_TARGET_MACHINE" in |
| 101 | + aarch64*) _cpu=arm64 ;; |
| 102 | + arm*) _cpu=arm ;; |
| 103 | + mips64*) _cpu=mips64 ;; |
| 104 | + mips*) _cpu=mips ;; |
| 105 | + ppc*) _cpu=ppc ;; |
| 106 | + i686*) _cpu=x86 ;; |
| 107 | + x86_64*) _cpu=x64 ;; |
| 108 | + esac |
| 109 | + |
| 110 | + # Enforce global flags for all arches |
| 111 | + local _extra_cflags="${CFLAGS} -Wno-free-nonheap-object" |
| 112 | + local _extra_cppflags="${CXXFLAGS} -Wno-free-nonheap-object" |
| 113 | + local _extra_ldflags="${LDFLAGS} -Wl,-soname,libpdfium.so.${version} -Wl,--no-fatal-warnings" |
| 114 | + |
| 115 | + gn gen out/Release --args=" |
| 116 | + target_cpu=\"${_cpu}\" is_debug=false is_component_build=true |
| 117 | + pdf_is_standalone=true pdf_enable_v8=false pdf_enable_xfa=false pdf_use_skia=false |
| 118 | + use_custom_libcxx=false use_sysroot=false |
| 119 | + is_clang=false treat_warnings_as_errors=false symbol_level=0 |
| 120 | + use_system_zlib=true |
| 121 | + use_system_libpng=true |
| 122 | + use_system_libjpeg=true |
| 123 | + use_system_libopenjpeg2=true |
| 124 | + use_system_lcms2=true |
| 125 | + use_system_freetype=true |
| 126 | + pdf_bundle_freetype=false |
| 127 | + extra_cflags=\"${_extra_cflags}\" |
| 128 | + extra_cppflags=\"${_extra_cppflags}\" |
| 129 | + extra_ldflags=\"${_extra_ldflags}\"" |
| 130 | +} |
| 131 | + |
| 132 | +do_build() { |
| 133 | + ninja -C out/Release pdfium |
| 134 | +} |
| 135 | + |
| 136 | +do_install() { |
| 137 | + vinstall out/Release/libpdfium.so 755 usr/lib libpdfium.so.${version} |
| 138 | + ln -sf libpdfium.so.${version} ${DESTDIR}/usr/lib/libpdfium.so |
| 139 | + vmkdir usr/include/pdfium |
| 140 | + vcopy "public/*.h" usr/include/pdfium |
| 141 | + |
| 142 | + vmkdir usr/lib/pkgconfig |
| 143 | + cat > "${DESTDIR}/usr/lib/pkgconfig/pdfium.pc" <<-EOF |
| 144 | + prefix=/usr |
| 145 | + exec_prefix=\${prefix} |
| 146 | + libdir=\${exec_prefix}/lib |
| 147 | + includedir=\${prefix}/include/pdfium |
| 148 | + Name: pdfium |
| 149 | + Description: Google PDFium rendering library |
| 150 | + Version: ${version} |
| 151 | + Libs: -L\${libdir} -lpdfium |
| 152 | + Cflags: -I\${includedir} |
| 153 | +EOF |
| 154 | +} |
| 155 | + |
| 156 | +libpdfium-devel_package() { |
| 157 | + short_desc+=" - development files" |
| 158 | + depends="${sourcepkg}>=${version}_${revision}" |
| 159 | + pkg_install() { |
| 160 | + vmove "usr/lib/*.so" |
| 161 | + vmove usr/include |
| 162 | + vmove usr/lib/pkgconfig |
| 163 | + } |
| 164 | +} |
0 commit comments