distributable:
  url: https://github.com/libjxl/libjxl/archive/v{{version}}.tar.gz
  strip-components: 1

versions:
  github: libjxl/libjxl

dependencies:
  github.com/google/brotli: ^1
  littlecms.com: ^2.13
  google.com/highway: ^1
  google.com/webp: ^1
  giflib.sourceforge.io: ^5
  openexr.com: ^3

provides:
  - bin/cjpeg_hdr
  - bin/cjxl
  - bin/djxl
  - bin/jxlinfo

build:
  dependencies:
    freedesktop.org/pkg-config: ^0.29
    cmake.org: ^3
    gnu.org/coreutils: '*' # deps.sh needs “realpath”
  working-directory: build
  script: |
    GIT_DIR=$PWD ../deps.sh  # †
    find ../third_party -not -name sjpeg -mindepth 1 -maxdepth 1 -type d | xargs rm -rf  # ‡

    cmake .. $ARGS
    make --jobs {{ hw.concurrency }} install
  env:
    # add any environment variables here
    ARGS:
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX={{prefix}}
      - -DBUILD_TESTING=OFF
      - -DJPEGXL_ENABLE_SKCMS=OFF
      - -DJPEGXL_ENABLE_BENCHMARK=OFF
      - -DJPEGXL_VERSION={{version}}

# † we set GIT_DIR because the script assumes git if it finds git rev-parse
# works, which it does for us because we have a git checkout both locally and
# in CI/CD

# ‡ we don’t want anything but sjpeg which is a super rare dep only used by
# this package

test:
  script: |
    cjxl fixture.jpeg out.jxl

    cc fixture1.c -ljxl
    ./a.out

    cc fixture2.c -ljxl_threads
    ./a.out
