libjxl

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

deps.sh (2985B)


      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 # This file downloads the dependencies needed to build JPEG XL into third_party.
      8 # These dependencies are normally pulled by git.
      9 
     10 set -eu
     11 
     12 MYDIR=$(dirname $(realpath "$0"))
     13 
     14 # Git revisions we use for the given submodules. Update these whenever you
     15 # update a git submodule.
     16 TESTDATA="873045a9c42ed60721756e26e2a6b32e17415205"
     17 THIRD_PARTY_BROTLI="36533a866ed1ca4b75cf049f4521e4ec5fe24727"
     18 THIRD_PARTY_HIGHWAY="58b52a717469e62b2d9b8eaa2f5dddb44d4a4cbf"
     19 THIRD_PARTY_SKCMS="42030a771244ba67f86b1c1c76a6493f873c5f91"
     20 THIRD_PARTY_SJPEG="e5ab13008bb214deb66d5f3e17ca2f8dbff150bf"
     21 THIRD_PARTY_ZLIB="51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf" # v1.3.1
     22 THIRD_PARTY_LIBPNG="f135775ad4e5d4408d2e12ffcc71bb36e6b48551" # v1.6.40
     23 THIRD_PARTY_LIBJPEG_TURBO="8ecba3647edb6dd940463fedf38ca33a8e2a73d1" # 2.1.5.1
     24 
     25 # Download the target revision from GitHub.
     26 download_github() {
     27   local path="$1"
     28   local project="$2"
     29 
     30   local varname=`echo "$path" | tr '[:lower:]' '[:upper:]'`
     31   varname="${varname//[\/-]/_}"
     32   local sha
     33   eval "sha=\${${varname}}"
     34 
     35   local down_dir="${MYDIR}/downloads"
     36   local local_fn="${down_dir}/${sha}.tar.gz"
     37   if [[ -e "${local_fn}" && -d "${MYDIR}/${path}" ]]; then
     38     echo "${path} already up to date." >&2
     39     return 0
     40   fi
     41 
     42   local url
     43   local strip_components=0
     44   if [[ "${project:0:4}" == "http" ]]; then
     45     # "project" is a googlesource.com base url.
     46     url="${project}${sha}.tar.gz"
     47   else
     48     # GitHub files have a top-level directory
     49     strip_components=1
     50     url="https://github.com/${project}/tarball/${sha}"
     51   fi
     52 
     53   echo "Downloading ${path} version ${sha}..." >&2
     54   mkdir -p "${down_dir}"
     55   curl -L --show-error -o "${local_fn}.tmp" "${url}"
     56   mkdir -p "${MYDIR}/${path}"
     57   tar -zxf "${local_fn}.tmp" -C "${MYDIR}/${path}" \
     58     --strip-components="${strip_components}"
     59   mv "${local_fn}.tmp" "${local_fn}"
     60 }
     61 
     62 is_git_repository() {
     63     local dir="$1"
     64     local toplevel=$(git rev-parse --show-toplevel)
     65 
     66     [[ "${dir}" == "${toplevel}" ]]
     67 }
     68 
     69 
     70 main() {
     71   if is_git_repository "${MYDIR}"; then
     72     cat >&2 <<EOF
     73 Current directory is a git repository, downloading dependencies via git:
     74 
     75   git submodule update --init --recursive
     76 
     77 EOF
     78     git -C "${MYDIR}" submodule update --init --recursive --depth 1 --recommend-shallow
     79     return 0
     80   fi
     81 
     82   # Sources downloaded from a tarball.
     83   download_github testdata libjxl/testdata
     84   download_github third_party/brotli google/brotli
     85   download_github third_party/highway google/highway
     86   download_github third_party/sjpeg webmproject/sjpeg
     87   download_github third_party/skcms \
     88     "https://skia.googlesource.com/skcms/+archive/"
     89   download_github third_party/zlib madler/zlib
     90   download_github third_party/libpng glennrp/libpng
     91   download_github third_party/libjpeg-turbo libjpeg-turbo/libjpeg-turbo
     92   echo "Done."
     93 }
     94 
     95 main "$@"