# Command line tool to test QUIC protocol
# This is compiled version provided by Lucas Clemente (thanks!), which
# drastically simplifies https://www.chromium.org/quic/playing-with-quic
# approach, which requires big chunks of Chromium compilation environment
[buildout]
extends =
# running
  ../nss/buildout.cfg
  ../nspr/buildout.cfg
  ../glib/buildout.cfg
  ../pcre/buildout.cfg
  ../libffi/buildout.cfg
  ../zlib/buildout.cfg
  ../libuuid/buildout.cfg
# compilation
  ../git/buildout.cfg

parts =
  quic_client-bin

[quic_client-bin]
recipe = slapos.recipe.build
url = https://github.com/lucas-clemente/quic-clients/archive/557cb1f99f591614d474e182b50cfee9334e0ffd.zip
md5sum = e2c78f4f7fb6ed03f6eec25b5e54fed3
slapos_promise =
    file:quic_client
    file:client-linux-debug
library =
  ${nss:location}/lib
  ${nspr:location}/lib
  ${glib:location}/lib
  ${pcre:location}/lib
  ${libffi:location}/lib
  ${zlib:location}/lib
  ${libuuid:location}/lib
install =
  import glob, os, shutil
  extract_dir = self.extract(self.download(options['url'], options['md5sum']))
  os.mkdir(location)
  source_file = glob.glob(os.path.join(extract_dir, '*', 'client-linux-debug'))[0]
  shutil.copy(source_file, location)
  wrapper_path = os.path.join(location, 'quic_client')
  with open(wrapper_path, 'w') as f:
    f.write("""#!/bin/sh -e
  export LD_LIBRARY_PATH={}
  exec {}/client-linux-debug "$@"
  """.format(
    ':'.join(options['library'].split()),
    location
  ))
    os.fchmod(f.fileno(), 0o755)
