jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
jpegxl-bot | bdde644 | 2021-05-25 19:02:18 +0200 | [diff] [blame] | 2 | # Copyright (c) the JPEG XL Project Authors. All rights reserved. |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 3 | # |
jpegxl-bot | bdde644 | 2021-05-25 19:02:18 +0200 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style |
| 5 | # license that can be found in the LICENSE file. |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 6 | |
| 7 | # This file downloads the dependencies needed to build JPEG XL into third_party. |
| 8 | # These dependencies are normally pulled by gtest. |
| 9 | |
| 10 | set -eu |
| 11 | |
| 12 | MYDIR=$(dirname $(realpath "$0")) |
| 13 | |
| 14 | # Git revisions we use for the given submodules. Update these whenever you |
jpegxl-bot | 945ad0c | 2021-01-21 20:27:02 +0100 | [diff] [blame] | 15 | # update a git submodule. |
Stephan T. Lavavej | b219fd5 | 2022-03-31 06:49:07 -0700 | [diff] [blame] | 16 | THIRD_PARTY_BROTLI="35ef5c554d888bef217d449346067de05e269b30" |
Moritz Firsching | a4d2632 | 2022-08-25 15:19:31 +0200 | [diff] [blame] | 17 | THIRD_PARTY_HIGHWAY="22e3d7276f4157d4a47586ba9fd91dd6303f441a" |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 18 | THIRD_PARTY_SKCMS="64374756e03700d649f897dbd98c95e78c30c7da" |
| 19 | THIRD_PARTY_SJPEG="868ab558fad70fcbe8863ba4e85179eeb81cc840" |
Sami Boukortt | f3fc83b | 2021-12-10 12:25:19 +0100 | [diff] [blame] | 20 | THIRD_PARTY_ZLIB="cacf7f1d4e3d44d871b605da3b647f07d718623f" |
| 21 | THIRD_PARTY_LIBPNG="a40189cf881e9f0db80511c382292a5604c3c3d1" |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 22 | |
| 23 | # Download the target revision from GitHub. |
| 24 | download_github() { |
| 25 | local path="$1" |
| 26 | local project="$2" |
| 27 | |
Evgenii Kliuchnikov | 28e3d06 | 2021-11-22 10:05:47 +0000 | [diff] [blame] | 28 | local varname=`echo "$path" | tr '[:lower:]' '[:upper:]'` |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 29 | varname="${varname/\//_}" |
| 30 | local sha |
| 31 | eval "sha=\${${varname}}" |
| 32 | |
| 33 | local down_dir="${MYDIR}/downloads" |
| 34 | local local_fn="${down_dir}/${sha}.tar.gz" |
| 35 | if [[ -e "${local_fn}" && -d "${MYDIR}/${path}" ]]; then |
| 36 | echo "${path} already up to date." >&2 |
| 37 | return 0 |
| 38 | fi |
| 39 | |
| 40 | local url |
| 41 | local strip_components=0 |
| 42 | if [[ "${project:0:4}" == "http" ]]; then |
| 43 | # "project" is a googlesource.com base url. |
| 44 | url="${project}${sha}.tar.gz" |
| 45 | else |
| 46 | # GitHub files have a top-level directory |
| 47 | strip_components=1 |
| 48 | url="https://github.com/${project}/tarball/${sha}" |
| 49 | fi |
| 50 | |
| 51 | echo "Downloading ${path} version ${sha}..." >&2 |
| 52 | mkdir -p "${down_dir}" |
| 53 | curl -L --show-error -o "${local_fn}.tmp" "${url}" |
| 54 | mkdir -p "${MYDIR}/${path}" |
| 55 | tar -zxf "${local_fn}.tmp" -C "${MYDIR}/${path}" \ |
| 56 | --strip-components="${strip_components}" |
| 57 | mv "${local_fn}.tmp" "${local_fn}" |
| 58 | } |
| 59 | |
| 60 | |
| 61 | main() { |
| 62 | if git -C "${MYDIR}" rev-parse; then |
| 63 | cat >&2 <<EOF |
Ziemowit Zabawa | 27d8a0f | 2021-07-01 16:45:13 +0200 | [diff] [blame] | 64 | Current directory is a git repository, downloading dependencies via git: |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 65 | |
| 66 | git submodule update --init --recursive |
| 67 | |
| 68 | EOF |
Leo Izen | d2b7714 | 2022-01-05 09:27:37 -0500 | [diff] [blame] | 69 | git -C "${MYDIR}" submodule update --init --recursive --depth 1 --recommend-shallow |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 70 | return 0 |
| 71 | fi |
| 72 | |
| 73 | # Sources downloaded from a tarball. |
Stephan T. Lavavej | b219fd5 | 2022-03-31 06:49:07 -0700 | [diff] [blame] | 74 | download_github third_party/brotli google/brotli |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 75 | download_github third_party/highway google/highway |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 76 | download_github third_party/sjpeg webmproject/sjpeg |
| 77 | download_github third_party/skcms \ |
| 78 | "https://skia.googlesource.com/skcms/+archive/" |
Sami Boukortt | f3fc83b | 2021-12-10 12:25:19 +0100 | [diff] [blame] | 79 | download_github third_party/zlib madler/zlib |
| 80 | download_github third_party/libpng glennrp/libpng |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 81 | echo "Done." |
| 82 | } |
| 83 | |
| 84 | main "$@" |