libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

reference_zip.sh (1766B)


      1 #!/usr/bin/env bash
      2 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
      3 #
      4 # Use of this source code is governed by a BSD-style
      5 # license that can be found in the LICENSE file.
      6 
      7 # Tool to create the reference software .zip package with its required
      8 # dependencies bundled.
      9 
     10 set -eu
     11 
     12 MYDIR=$(dirname $(realpath "$0"))
     13 
     14 # Temporary files cleanup hooks.
     15 CLEANUP_FILES=()
     16 cleanup() {
     17   if [[ ${#CLEANUP_FILES[@]} -ne 0 ]]; then
     18     rm -fr "${CLEANUP_FILES[@]}"
     19   fi
     20 }
     21 trap 'retcode=$?; { set +x; } 2>/dev/null; cleanup' INT TERM EXIT
     22 
     23 
     24 main() {
     25   # Run from the repo's top level directory.
     26   cd "${MYDIR[@]}/.."
     27 
     28   local deps=(
     29     third_party/brotli
     30     third_party/highway
     31     third_party/skcms
     32   )
     33 
     34   local ref_files=($(git ls-files))
     35   for dep in "${deps[@]}"; do
     36     local dep_files=($(git -C "${dep}" ls-files))
     37     for dep_file in "${dep_files[@]}"; do
     38       ref_files+=("${dep}/${dep_file}")
     39     done
     40   done
     41 
     42   echo "Packaging ${#ref_files[@]} files..." >&2
     43   local dest_zip="reference_package.zip"
     44   rm -f "${dest_zip}"
     45   printf '%s\n' "${ref_files[@]}" | zip -q -@ "${dest_zip}"
     46 
     47   if [[ "${1:-}" == "test" ]]; then
     48     echo "Testing on docker..." >&2
     49     set -x
     50     sudo docker run --rm -v "$(realpath ${dest_zip}):/home/pkg.zip:ro" \
     51       ubuntu:20.04 <<EOF
     52 set -eux
     53 
     54 apt update
     55 DEBIAN_FRONTEND=noninteractive apt install -y build-essential zip cmake
     56 
     57 cd /home/
     58 unzip -q pkg.zip
     59 mkdir build
     60 cd build
     61 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJPEGXL_ENABLE_SJPEG=OFF ..
     62 cmake --build . -- -j\$(nproc)
     63 
     64 tools/djxl ../testdata/jxl/blending/cropped_traffic_light.jxl test.png
     65 tools/cjxl ../testdata/jxl/flower/flower.png.im_q85_444.jpg test.jxl
     66 tools/djxl test.jxl test.jpg
     67 EOF
     68     set +x
     69   fi
     70   echo "${dest_zip} ready."
     71 }
     72 
     73 main "$@"