Building PDFium inside a Ubuntu:latest Docker container

1,757 views
Skip to first unread message

Alexander Reen

unread,
Oct 31, 2016, 6:04:38 AM10/31/16
to pdfium
Heyya,

I'm trying to build PDFium inside a Ubuntu:latest docker container through a Docker File. As of now I got the following going:

# Install PDFium
ENV PATH /depot_tools:"$PATH"
RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git; \
    gclient sync; \
    cd pdfium; \
    gn gen codeBuild

This results into the following error:

________ running '/usr/bin/python pdfium/build/vs_toolchain.py update' in '/'

________ running '/usr/bin/python pdfium/third_party/instrumented_libraries/scripts/download_binaries.py' in '/'
ERROR at //build/config/sysroot.gni:87:5: Assertion failed.
    assert(
    ^-----
Missing sysroot (//build/linux/debian_wheezy_amd64-sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
See //build/config/sysroot.gni:88:9:
        exec_script("//build/dir_exists.py",
        ^-----------------------------------
This is where it was set.
See //build/toolchain/linux/BUILD.gn:5:1: whence it was imported.
import("//build/config/sysroot.gni")
^----------------------------------
See //BUILD.gn:63:1: which caused the file to be included.
static_library("pdfium") {
^-------------------------
The command '/bin/sh -c gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git;     gclient sync;     cd pdfium;     gn gen codeBuild' returned a no
n-zero code: 1

I follow this up by adding build/linux/sysroot_scripts/install-sysroot.py --arch=amd64 to the Dockerfile run command:

# Install PDFium
ENV PATH /depot_tools:"$PATH"
RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git; \
    gclient sync; \
    cd pdfium; \
    build/linux/sysroot_scripts/install-sysroot.py --arch=amd64; \
    gn gen codeBuild

It follows up with the following output and error:

________ running '/usr/bin/python pdfium/third_party/instrumented_libraries/scripts/download_binaries.py' in '/'
Installing Debian Wheezy amd64 root image: /pdfium/build/linux/debian_wheezy_amd64-sysroot
Traceback (most recent call last):
  File "build/linux/sysroot_scripts/install-sysroot.py", line 256, in <module>
    sys.exit(main(sys.argv[1:]))
  File "build/linux/sysroot_scripts/install-sysroot.py", line 190, in main
    InstallDefaultSysrootForArch(options.arch)
  File "build/linux/sysroot_scripts/install-sysroot.py", line 196, in InstallDefaultSysrootForArch
    InstallSysroot('Wheezy', 'amd64')
  File "build/linux/sysroot_scripts/install-sysroot.py", line 242, in InstallSysroot
    ['curl', '--fail', '--retry', '3', '-L', url, '-o', tarball])
  File "/usr/lib/python2.7/subprocess.py", line 536, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
ERROR at //build/config/linux/pkg_config.gni:85:17: Script returned non-zero exit code.
    pkgresult = exec_script(pkg_config_script, args, "value")
                ^----------
Current dir: /pdfium/codeBuild/
Command: python -- /pdfium/build/config/linux/pkg-config.py -s /pdfium/build/linux/debian_wheezy_amd64-sysroot -a x64 glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0
Returned 1.
stderr:

raceback (most recent call last):
  File "/pdfium/build/config/linux/pkg-config.py", line 219, in <module>
    sys.exit(main())
  File "/pdfium/build/config/linux/pkg-config.py", line 138, in main
    prefix = GetPkgConfigPrefixToStrip(args)
  File "/pdfium/build/config/linux/pkg-config.py", line 80, in GetPkgConfigPrefixToStrip
    env=os.environ)
  File "/usr/lib/python2.7/subprocess.py", line 567, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

See //build/config/linux/BUILD.gn:90:3: whence it was called.
  pkg_config("glib") {
  ^-------------------
See //build/config/compiler/BUILD.gn:147:18: which caused the file to be included.
    configs += [ "//build/config/linux:compiler" ]
                 ^------------------------------
The command '/bin/sh -c gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git;     gclient sync;     cd pdfium;     build/linux/sysroot_scripts/ins
tall-sysroot.py --arch=amd64;     gn gen codeBuild' returned a non-zero code: 1


Not sure what's going wrong. Any thoughts? 





Alexander Reen

unread,
Oct 31, 2016, 10:29:14 AM10/31/16
to pdfium
Found out the issue. Was missing glib included in libgtk2.0-dev. For anyone trying to get PDFium into a Docker container based on Ubuntu, here is the code:

FROM ubuntu:latest

RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y git g++ curl libfreetype6 libgtk2.0-dev


ENV PATH /depot_tools:"$PATH"
RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git; \
    gclient sync

RUN cd pdfium; \
    build/linux/sysroot_scripts/install-sysroot.py --arch=amd64; \
    gn gen codeBuild; \
    ninja -C codeBuild


Lei Zhang

unread,
Oct 31, 2016, 2:10:06 PM10/31/16
to Alexander Reen, pdfium
You don't have to run build/linux/sysroot_scripts/install-sysroot.py.
You can just set use_sysroot = false, as recommended in README.md.
> --
> You received this message because you are subscribed to the Google Groups
> "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pdfium+un...@googlegroups.com.
> To post to this group, send email to pdf...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pdfium/2f0d2a45-4d28-4a47-acb1-0be30dd632d3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Alexander Reen

unread,
Oct 31, 2016, 2:49:28 PM10/31/16
to pdfium, alexan...@gmail.com
Ahh forgot the container is ofcourse Linux and thus build configs have to be different.

Can I pass such parameters through gn args in the way the docs state for listing as an example? I prefer not to manually use the editor due the automation of docker build.

gn args --args='use_sysroot="false" pdf_is_standalone ="true"'





Op maandag 31 oktober 2016 19:10:06 UTC+1 schreef Lei Zhang:

Lei Zhang

unread,
Oct 31, 2016, 2:54:41 PM10/31/16
to Alexander Reen, pdfium
Yes, you can do this from the command line without an editor. PDFium
has build bots that require automation as well.

gn gen out/foo --args='use_sysroot=false pdf_is_standalone=true'

On Mon, Oct 31, 2016 at 11:43 AM, Alexander Reen
<alexan...@gmail.com> wrote:
> Ahh forgot the container is ofcourse Linux and thus build configs have to be
> different.
>
> Can I pass such parameters through gn args in the way the docs state for
> listing as an example? I prefer not to manually use the editor due the
> automation of docker build.
>
> gn args --args="use_sysroot = false""pdf_is_standalone = true"
>
>
>
>
>
>
>
>
>
> Mostly so I can automate the build process
>
> Op maandag 31 oktober 2016 19:10:06 UTC+1 schreef Lei Zhang:
>>
> https://groups.google.com/d/msgid/pdfium/977bbbeb-a28f-4dec-adc4-b8e3d862b504%40googlegroups.com.

Alexander Reen

unread,
Nov 1, 2016, 5:39:16 AM11/1/16
to pdfium, alexan...@gmail.com
Thanks for the help!

Parameters seem to work, yet pdf_is_standalone=true doesn't seem to work.

gn gen codeBuild --args='use_sysroot=false pdf_is_standalone=true'; \
    ninja -C codeBuild

This works but it still builds everything included unit tests.

The suggested way to get Pdfium_test by doing:

gn gen codeBuild --args='use_sysroot=false pdf_is_standalone=true'; \
    ninja -C codeBuild/pdfium_test

results in ninja stating pdfium_test dir doesn't exist. Even by a mkdir command to create that folder results in the same error.


Op maandag 31 oktober 2016 19:54:41 UTC+1 schreef Lei Zhang:

Dan Sinclair

unread,
Nov 1, 2016, 11:29:56 AM11/1/16
to Alexander Reen, pdfium
The command you want is:

  ninja -C codeBuild pdfium_test

dan

Lei Zhang

unread,
Nov 1, 2016, 4:47:32 PM11/1/16
to Dan Sinclair, Alexander Reen, pdfium
And preferably out/codebuild rather than codeBuild, if you want to run
unit tests for example. Our test runner code just assumes the base
directory is 2 levels up and does not try that hard to guess where it
is.
> https://groups.google.com/d/msgid/pdfium/CAMYH%3DOimsazPzHmQqFcXR05d530nUw1KoKNydg2p0yWABMmdSg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages