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. |
Jan Wassenberg | 1f9967a | 2021-06-09 11:49:33 +0200 | [diff] [blame] | 16 | THIRD_PARTY_HIGHWAY="e2397743fe092df68b760d358253773699a16c93" |
Ziemowit Zabawa | 6a3f0ce | 2021-10-06 17:28:44 +0200 | [diff] [blame] | 17 | THIRD_PARTY_LODEPNG="8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a" |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 18 | THIRD_PARTY_SKCMS="64374756e03700d649f897dbd98c95e78c30c7da" |
| 19 | THIRD_PARTY_SJPEG="868ab558fad70fcbe8863ba4e85179eeb81cc840" |
| 20 | |
| 21 | # Download the target revision from GitHub. |
| 22 | download_github() { |
| 23 | local path="$1" |
| 24 | local project="$2" |
| 25 | |
| 26 | local varname="${path^^}" |
| 27 | varname="${varname/\//_}" |
| 28 | local sha |
| 29 | eval "sha=\${${varname}}" |
| 30 | |
| 31 | local down_dir="${MYDIR}/downloads" |
| 32 | local local_fn="${down_dir}/${sha}.tar.gz" |
| 33 | if [[ -e "${local_fn}" && -d "${MYDIR}/${path}" ]]; then |
| 34 | echo "${path} already up to date." >&2 |
| 35 | return 0 |
| 36 | fi |
| 37 | |
| 38 | local url |
| 39 | local strip_components=0 |
| 40 | if [[ "${project:0:4}" == "http" ]]; then |
| 41 | # "project" is a googlesource.com base url. |
| 42 | url="${project}${sha}.tar.gz" |
| 43 | else |
| 44 | # GitHub files have a top-level directory |
| 45 | strip_components=1 |
| 46 | url="https://github.com/${project}/tarball/${sha}" |
| 47 | fi |
| 48 | |
| 49 | echo "Downloading ${path} version ${sha}..." >&2 |
| 50 | mkdir -p "${down_dir}" |
| 51 | curl -L --show-error -o "${local_fn}.tmp" "${url}" |
| 52 | mkdir -p "${MYDIR}/${path}" |
| 53 | tar -zxf "${local_fn}.tmp" -C "${MYDIR}/${path}" \ |
| 54 | --strip-components="${strip_components}" |
| 55 | mv "${local_fn}.tmp" "${local_fn}" |
| 56 | } |
| 57 | |
| 58 | |
| 59 | main() { |
| 60 | if git -C "${MYDIR}" rev-parse; then |
| 61 | cat >&2 <<EOF |
Ziemowit Zabawa | 27d8a0f | 2021-07-01 16:45:13 +0200 | [diff] [blame] | 62 | Current directory is a git repository, downloading dependencies via git: |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 63 | |
| 64 | git submodule update --init --recursive |
| 65 | |
| 66 | EOF |
| 67 | git -C "${MYDIR}" submodule update --init --recursive |
| 68 | return 0 |
| 69 | fi |
| 70 | |
| 71 | # Sources downloaded from a tarball. |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 72 | download_github third_party/highway google/highway |
| 73 | download_github third_party/lodepng lvandeve/lodepng |
| 74 | download_github third_party/sjpeg webmproject/sjpeg |
| 75 | download_github third_party/skcms \ |
| 76 | "https://skia.googlesource.com/skcms/+archive/" |
| 77 | echo "Done." |
| 78 | } |
| 79 | |
| 80 | main "$@" |