Backed out 3 changesets (bug 1790375) for causing wd failures on fetch_error.py....
[gecko.git] / third_party / jpeg-xl / deps.sh
bloba88f5f50930d8ba843f2686a733497203c603078
1 #!/usr/bin/env bash
2 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
7 # This file downloads the dependencies needed to build JPEG XL into third_party.
8 # These dependencies are normally pulled by git.
10 set -eu
12 MYDIR=$(dirname $(realpath "$0"))
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="ba0900a4957b929390ab73827235557959234fea"
19 THIRD_PARTY_SKCMS="42030a771244ba67f86b1c1c76a6493f873c5f91"
20 THIRD_PARTY_SJPEG="e5ab13008bb214deb66d5f3e17ca2f8dbff150bf"
21 THIRD_PARTY_ZLIB="cacf7f1d4e3d44d871b605da3b647f07d718623f"
22 THIRD_PARTY_LIBPNG="f135775ad4e5d4408d2e12ffcc71bb36e6b48551" # v1.6.40
23 THIRD_PARTY_LIBJPEG_TURBO="8ecba3647edb6dd940463fedf38ca33a8e2a73d1" # 2.1.5.1
25 # Download the target revision from GitHub.
26 download_github() {
27 local path="$1"
28 local project="$2"
30 local varname=`echo "$path" | tr '[:lower:]' '[:upper:]'`
31 varname="${varname//[\/-]/_}"
32 local sha
33 eval "sha=\${${varname}}"
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
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}"
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}"
62 is_git_repository() {
63 local dir="$1"
64 local toplevel=$(git rev-parse --show-toplevel)
66 [[ "${dir}" == "${toplevel}" ]]
70 main() {
71 if is_git_repository "${MYDIR}"; then
72 cat >&2 <<EOF
73 Current directory is a git repository, downloading dependencies via git:
75 git submodule update --init --recursive
77 EOF
78 git -C "${MYDIR}" submodule update --init --recursive --depth 1 --recommend-shallow
79 return 0
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."
95 main "$@"