[buildout]
extends =
  ../bison/buildout.cfg
  ../pkgconfig/buildout.cfg
  ../gperf/buildout.cfg
  ../ninja/buildout.cfg
  ../freetype/buildout.cfg
  ../cmake/buildout.cfg
  ../git/buildout.cfg
  ../mpfr/buildout.cfg
  ../pkgconfig/buildout.cfg
  ../cups/buildout.cfg
  ../coreutils/buildout.cfg
  ../depot_tools/buildout.cfg
  ../findutils/buildout.cfg
  ../fontconfig/buildout.cfg
  ../gettext/buildout.cfg
  ../glib/buildout.cfg
  ../gtk-2/buildout.cfg
  ../libexpat/buildout.cfg
  ../libffi/buildout.cfg
  ../libpng/buildout.cfg
  ../libxml2/buildout.cfg
  ../mesa/buildout.cfg
  ../nspr/buildout.cfg
  ../nss/buildout.cfg
  ../pcre/buildout.cfg
  ../sqlite3/buildout.cfg
  ../xorg/buildout.cfg
  ../zlib/buildout.cfg

parts =
  chromium

[gconf]
recipe = slapos.recipe.cmmi
url = http://ftp.gnome.org/pub/gnome/sources/GConf/3.2/GConf-3.2.6.tar.xz
md5sum = 2b16996d0e4b112856ee5c59130e822c
configure-options = --disable-orbit --disable-static
environment =
  PATH=${pkgconfig:location}/bin:${intltool:location}/bin:${gettext:location}/bin:${glib:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig:${pcre:location}/lib/pkgconfig:${libxml2:location}/lib/pkgconfig:${dbus:location}/lib/pkgconfig:${dbus-glib:location}/lib/pkgconfig:$PKG_CONFIG_PATH

[chromedriver]
recipe = hexagonit.recipe.download
url = https://chromedriver.storage.googleapis.com/2.28/chromedriver_linux64.zip
md5sum = a72088c0a6b018ded2c0fff616da8f65

[chromium-download]
recipe = plone.recipe.command
# This revision is 56.0.2924.122. Because the chromedriver only support some certain
# version. Which version 56 is in the middle of 55-57.
revision = faf03429d9c3dbd483700dd42316b20776cbbd3c
path = ${buildout:parts-directory}/${:_buildout_section_name_}
command =
  set -e
  PATH=${depot_tools:location}:${git:location}/bin:$PATH
  [ -d ${:path} ] && rm -r ${:path}
  mkdir -p ${:path}
  cd ${:path}
  # Do never use `fetch` with the `--no-history` option unless you find an
  # option to fetch directly at the wanted revision. `--no-history` could
  # reduce the download size significantly but even if it retrieves enough
  # commits at the time you test this section, development continues upstream
  # and at some point the next command (gclient) would break.
  # ...
  # This command only could work in an empty dir.
  fetch --nohooks chromium
  gclient sync --revision ${:revision} --with_branch_heads
stop-on-error = true

[chromium]
recipe = slapos.recipe.cmmi
path = ${chromium-download:path}/src
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  gclient runhooks
  mkdir -p ${:location}
  echo 'use_udev = true
  is_debug = false
  enable_nacl = false' > ${:location}/args.gn
  gn gen ${:location}

# Note you can run Chromium manually by: ${:location}/chrome --headless --no-sandbox --disable-gpu
make-binary = ninja -C ${:location} chrome
environment =
  PKG_CONFIG_PATH=${freetype:location}/lib/pkgconfig:${zlib:location}/lib/pkgconfig:${libpng:location}/lib/pkgconfig:${randrproto:location}/lib/pkgconfig:$PKG_CONFIG_PATH
  PATH=${chromedriver:location}:${dbus:location}/bin:${depot_tools:location}:${pkgconfig:location}/bin:${ninja:path}/:${bison:location}/bin:${gperf:location}/bin:${xserver:location}/bin:%(PATH)s
  CPATH=${dbus:location}/include/dbus-1.0:${dbus:location}/lib/dbus-1.0/include/:${freetype:location}/include/freetype2:${libffi:location}/include:${mpfr:location}/include:${ncurses:location}/include:${openssl:location}/include:${readline:location}/include:${sqlite3:location}/include:${zlib:location}/include:${bzip2:location}/include:$CPATH
  LD_LIBRARY_PATH=${alsa:location}/lib:${gconf:location}/lib:${libXScrnSaver:location}/lib:${glib:location}/lib:${atk:location}/lib:${cairo:location}/lib:${cups:location}/lib:${dbus:location}/lib:${dbus-glib:location}/lib:${fontconfig:location}/lib/:${gdk-pixbuf:location}/lib:${gettext:location}/lib:${glib:location}/lib:${gtk-2:location}/lib:${harfbuzz:location}/lib:${libX11:location}/lib:${libXau:location}/lib:${libXcomposite:location}/lib:${libXcursor:location}/lib:${libXext:location}/lib:${libXi:location}/lib:${libXrender:location}/lib/:${libXtst:location}/lib:${libexpat:location}/lib:${libffi:location}/lib:${libpng:location}/lib:${libpng12:location}/lib:${libxcb:location}/lib:${libxml2:location}/lib:${mesa:location}/lib:${nspr:location}/lib:${nss:location}/lib:${pango:location}/lib:${pcre:location}/lib:${pixman:location}/lib:${sqlite3:location}/lib:${xdamage:location}/lib:${xfixes:location}/lib:${zlib:location}/lib:$LD_LIBRARY_PATH
