Package Details: libpdfium-nojs 6778.r0.7a8409531f-1

Git Clone URL: https://aur.archlinux.org/libpdfium-nojs.git (read-only, click to copy)
Package Base: libpdfium-nojs
Description: Open-source PDF rendering engine.
Upstream URL: https://pdfium.googlesource.com/pdfium/
Keywords: pdf pdfium
Licenses: BSD
Conflicts: libpdfium-bin
Provides: libpdfium
Submitter: selmf
Maintainer: selmf
Last Packager: selmf
Votes: 23
Popularity: 0.87
First Submitted: 2017-07-30 18:14 (UTC)
Last Updated: 2024-11-19 08:21 (UTC)

Pinned Comments

selmf commented on 2021-05-24 11:20 (UTC)

Important: This package depends on libicuuc and needs to be rebuild if the icu package is updated on your system!

Latest Comments

« First ‹ Previous 1 2 3 4 5 6 7 .. 12 Next › Last »

jghodd commented on 2022-12-03 19:08 (UTC)

@selmf - gotcha. when copying and pasting the pkgbuild earlier, i saw the partition_alloc flag was set to false and the thought did occur to me that with the flag being false, there was no need to bring in the source. but, i went with what i saw as an attempt to hook in the partition_alloc source, perhaps for later inclusion of partalloc vs malloc. in any case, your new push works out of the box, so all's good.

selmf commented on 2022-12-03 17:05 (UTC)

@jghodd Thanks for testing. My first attempt to fix this had some leftover artifacts from my attempts to make partition_alloc work, which I did not notice because I forgot to test with a clean build.

Revision two, which I pushed yesterday, does not need any references to partition_alloc because it is disabled via the build system. I did test this on a clean build, so it should work.

jghodd commented on 2022-12-03 16:50 (UTC)

@michaldybczak & @selmf - here's the PKGBUILD.


# Maintainer: Felix Kauselmann <licorn@gmail.com>

pkgname=libpdfium-nojs
pkgver=5359.r0.9d2c662f55
pkgrel=2
pkgdesc="Open-source PDF rendering engine."
arch=('x86_64')
url="https://pdfium.googlesource.com/pdfium/"
license=('BSD')
depends=('freetype2' 'lcms2' 'libjpeg' 'openjpeg2' 'icu')
conflicts=('libpdfium-bin')
provides=('libpdfium')
makedepends=('git' 'python' 'gn' 'ninja')

source=("git+https://pdfium.googlesource.com/pdfium"
    "git+https://chromium.googlesource.com/chromium/src/build.git"
    "git+https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git"
    "git+https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp"
    "libpdfium.pc"
    )

md5sums=('SKIP'
         'SKIP'
         'SKIP'
         'SKIP'
         'feb270967925a0844b1b9a9e15288eb3')

pkgver() {

  cd $srcdir/pdfium

  # Version = branch name/number + number of commits since branch creation
  # + short head
  printf  "%s.r%s.%s" $(git rev-parse --abbrev-ref HEAD | cut -d '/' -f2)\
   $(git rev-list --count main..) $(git rev-parse --short HEAD)

}

prepare() {

  cd "$srcdir/pdfium"

  ln -sf $srcdir/build build
  ln -sf $srcdir/abseil-cpp third_party/abseil-cpp

  mkdir -p $srcdir/pdfium/base/allocator
  ln -sf $srcdir/partition_allocator base/allocator/partition_allocator

  # Pdfium is developed alongside Chromium and does not provide releases
  # Upstream recommends using Chromium's dev channels instead

  # Extract pdfium branch name used in stable channel from omahaproxy and do
  # a checkout
  git checkout "chromium/$(curl https://omahaproxy.appspot.com/linux?channel=stable | cut -d'.' -f 3)"

  # git checkout "chromium/$(curl https://omahaproxy.appspot.com/linux?channel=beta | cut -d'.' -f 3)"
  # git checkout "chromium/$(curl https://omahaproxy.appspot.com/linux?channel=dev | cut -d'.' -f 3)"

  # Extract build repo revision needed from DEPS file and do a checkout
  cd "$srcdir/pdfium/build"
  git checkout $(awk '/build_revision/ {print substr($2,2,40)}' $srcdir/pdfium/DEPS) -q

  # Extract abseil-cpp repo revision needed from DEPS file and do a checkout
  cd "$srcdir/pdfium/third_party/abseil-cpp"
  git checkout $(awk '/abseil_revision/ {print substr($2,2,40)}' $srcdir/pdfium/DEPS) -q

  # Patch abseil build to be static
  sed -i 's/component(/static_library(/' BUILD.gn
  sed -i 's/is_component_build(/false/' BUILD.gn

  cd "$srcdir/pdfium/base/allocator/partition_allocator"
  git checkout $(awk '/partition_allocator_revision/ {print substr($2,2,40)}' $srcdir/pdfium/DEPS) -q

  # Use system provided icu library (unbundling)
  mkdir -p "$srcdir/pdfium/third_party/icu"
  ln -sf "$srcdir/build/linux/unbundle/icu.gn" "$srcdir/pdfium/third_party/icu/BUILD.gn"

  # Download and decode shim header script needed to unbundle icu (gittiles is weird)
  mkdir -p "$srcdir/pdfium/tools/generate_shim_headers/"
  echo "Downloading generate_shim_headers script from Chromium."
  curl https://chromium.googlesource.com/chromium/src/+/main/tools/generate_shim_headers/generate_shim_headers.py?format=TEXT \
    | base64 --decode > "$srcdir/pdfium/tools/generate_shim_headers/generate_shim_headers.py"
  echo "Done."

  # Create fake gclient_args.gni file to satisfy include list for build/config/compiler/compiler.gni
  touch "$srcdir/build/config/gclient_args.gni"

  # Exclude test fonts from build
  cd "$srcdir/pdfium/testing/"
  sed -i '/"\/\/third_party\/test_fonts",/s/^/#/g' BUILD.gn

} 

build() {

  cd "$srcdir/pdfium"

  local _flags=(
      'is_clang=false'
      'use_sysroot=false'
      'is_debug=false'
      'symbol_level=0'
      'pdf_enable_v8=false'
      'pdf_enable_xfa=false'
      'treat_warnings_as_errors=false'
      'use_system_libjpeg=true'
      'use_system_zlib=true'
      'pdf_bundle_freetype=false'
      'use_system_freetype=true'
      'use_system_lcms2=true'
      'use_system_libpng=true'
      'use_custom_libcxx=false'
      'pdf_is_standalone = true'
      'use_system_libopenjpeg2 = true'
      'is_component_build = true'
      'use_gold = false' 
      'pdf_use_partition_alloc = false'
  )

  gn gen out/Release --args="${_flags[*]}"
  ninja -C out/Release pdfium

  # set pdfium version in pc file
  sed "s/@VERSION@/${pkgver}/g" -i "${srcdir}/libpdfium.pc"

}

package() {

  cd "$srcdir/pdfium"

  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -D public/*.h --target-directory="${pkgdir}/usr/include/pdfium"
  install -D public/cpp/* --target-directory="${pkgdir}/usr/include/pdfium/cpp"
  install -D docs/* --target-directory="${pkgdir}/usr/share/doc/pdfium"
  install -Dm755 out/Release/libpdfium.so --target-directory="${pkgdir}/usr/lib"
  install -Dm644 ${srcdir}/libpdfium.pc --target-directory=${pkgdir}/usr/lib/pkgconfig

}

michaldybczak commented on 2022-12-02 20:45 (UTC)

I also confirm, that the build fails now, from the same reason as my predecessors pointed out.

jghodd commented on 2022-12-01 23:46 (UTC) (edited on 2022-12-02 00:22 (UTC) by jghodd)

@selmf - thank you very much for getting that sorted out. was a bit of a disaster trying to bring in googletest - just a heads-up. everything seemed to satisfy, but ended up with circular includes.

Edit: just as a correction, i saw the circular includes when bringing in base, not googletest, however... i hate to be the bearer of bad news, but your PKGBUILD is broken. here are the corrections:


source=("git+https://pdfium.googlesource.com/pdfium"
    "git+https://chromium.googlesource.com/chromium/src/build.git"
    "git+https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git"
    "git+https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp"
    "libpdfium.pc"
    )

your new PKGBUILD is missing the reference to partition_allocator in source.


  cd "$srcdir/pdfium"

  ln -sf $srcdir/build build
  ln -sf $srcdir/abseil-cpp third_party/abseil-cpp

  mkdir -p $srcdir/pdfium/base/allocator
  cd $srcdir/pdfium/base/allocator

  ln -sf $srcdir/partition_allocator partition_allocator

the single call to symlink base/allocator/partition_allocator threw an error, as did the attempt to link to allocator/partition_allocator. the version in the code block works as expected, but i had to create the directories before linking. i may not need the "cd" line in there and the symlink could be your original single call. so perhaps:


  mkdir -p $srcdir/pdfium/base/allocator
  ln -sf $srcdir/partition_allocator base/allocator/partition_allocator

i'll give that a try...

Edit2: that did work. so the first few lines of the prepare() script should read:


  cd "$srcdir/pdfium"

  ln -sf $srcdir/build build
  ln -sf $srcdir/abseil-cpp third_party/abseil-cpp

  mkdir -p $srcdir/pdfium/base/allocator
  ln -sf $srcdir/partition_allocator base/allocator/partition_allocator

just needs the mkdir.

selmf commented on 2022-12-01 20:48 (UTC)

@jghodd Thanks for the bug report and the patch. There is an easier option. Just add

'pdf_use_partition_alloc = false'

to the local_flags array at the start of the build() function. That will have the same effect.

I would prefer to keep partition_alloc in the package as it supposedly gives better performance than malloc(), but it seems that it moved to a separate repo and now needs googletest as a build dependency.

I'd rather avoid adding googletest to the package so I need to check if I can patch it out or if the performance gain is significant enough to justify it.

jghodd commented on 2022-12-01 20:00 (UTC)

OK. started over and created a quickie patch for core/fxcrt/BUILD.gn to remove the reference to "//base/allocator/partition_allocator:partition_alloc", which was causing the problem. So, here's the simple patch:


--- BUILD.gn    2022-12-01 14:24:28.998822197 -0500
+++ BUILD.gn.bak        2022-12-01 14:29:54.729322056 -0500
@@ -134,12 +134,12 @@
     "../../third_party:pdfium_base",
     "//third_party/icu:icuuc",
   ]
-  if (pdf_use_partition_alloc) {
-    sources += [ "fx_memory_pa.cpp" ]
-    deps += [ "//base/allocator/partition_allocator:partition_alloc" ]
-  } else {
+#  if (pdf_use_partition_alloc) {
+#    sources += [ "fx_memory_pa.cpp" ]
+#    deps += [ "//base/allocator/partition_allocator:partition_alloc" ]
+#  } else {
     sources += [ "fx_memory_malloc.cpp" ]
-  }
+#  }
   if (is_posix || is_fuchsia) {
     sources += [
       "cfx_fileaccess_posix.cpp",

it's a pretty basic patch, but it worked to remove the error and complete the builld.

the changes to PKGBUILD - add to the bottom of the prepare() function:


  cd "$srcdir/pdfium/core/fxcrt"
  patch BUILD.gn < $srcdir/../BUILD.gn.patch

}

yeah, i know it's a bit on the ugly side, but it'd be easy to clean up.

jghodd commented on 2022-11-30 20:10 (UTC) (edited on 2022-12-01 00:15 (UTC) by jghodd)

getting the following build error:


==> Starting build()...
ERROR at //core/fxcrt/BUILD.gn:139:15: Unable to load "/distro/local/repository/libpdfium-nojs/src/pdfium/base/allocator/partition_allocator/BUILD.gn".
    deps += [ "//base/allocator/partition_allocator:partition_alloc" ]
              ^-----------------------------------------------------
==> ERROR: A failure occurred in build().
    Aborting...

it looks like that BUILD.gn file is missing:


ll /distro/local/repository/libpdfium-nojs/src/pdfium/base/allocator/partition_allocator/BUILD.gn
ls: cannot access '/distro/local/repository/libpdfium-nojs/src/pdfium/base/allocator/partition_allocator/BUILD.gn': No such file or directory

Edit: actually, the entire src/pdfium/base directory is missing

Edit2: error confirmed on clean build also

Edit3: fixing this error caused yet more errors. to fix this one, you have to check out https://chromium.googlesource.com/chromium/src/base, then symlink it into the source tree: ln -sf $srcdir/base base.


source=("git+https://pdfium.googlesource.com/pdfium"
    "git+https://chromium.googlesource.com/chromium/src/build.git"
    "git+https://chromium.googlesource.com/chromium/src/base"
    "git+https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp"
    "libpdfium.pc"
    )

md5sums=('SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'feb270967925a0844b1b9a9e15288eb3'
    )

pkgver() {

  cd $srcdir/pdfium

  # Version = branch name/number + number of commits since branch creation
  # + short head
  printf  "%s.r%s.%s" $(git rev-parse --abbrev-ref HEAD | cut -d '/' -f2)\
   $(git rev-list --count main..) $(git rev-parse --short HEAD)

}

prepare() {

  cd "$srcdir/pdfium"

  ln -sf $srcdir/build build
  ln -sf $srcdir/base base
  ln -sf $srcdir/abseil-cpp third_party/abseil-cpp
  ...

this fix gets you to about 57 modules out of 741.

the next error is because of more missing parts in the source tree, specifically googletest. but any attempt to fix it causes a circular include dependency - i haven;t figured out how to resolve it yet and whether or not i should be resolving this.

is there a maintainer for this project who might add something here?

wallace11 commented on 2022-11-06 23:58 (UTC)

Getting errors when running pkgver:

==> Starting pkgver()...
==> ERROR: pkgver is not allowed to contain colons, forward slashes, hyphens or whitespace.
==> ERROR: pkgver() generated an invalid version: fatal: ambiguous argument 'main..': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Patch:

diff --git a/PKGBUILD b/PKGBUILD
index 532ecc8..35d0600 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -31,7 +31,7 @@ pkgver() {
   # Version = branch name/number + number of commits since branch creation
   # + short head
   printf  "%s.r%s.%s" $(git rev-parse --abbrev-ref HEAD | cut -d '/' -f2)\
-   $(git rev-list --count main..) $(git rev-parse --short HEAD)
+   $(git rev-list --count HEAD..) $(git rev-parse --short HEAD)

 }

robson commented on 2022-07-09 19:52 (UTC)

@selmf Thanks for the correction in PKGBUILD

@michaldybczak For me, on Arch, construction is easy, and do you sometimes use Manjaro?